Documente Academic
Documente Profesional
Documente Cultură
(Practical No:-2.1)
AIM:- Develop Standard Calculator with mathematical functionalities like addition,
multiplication, division and Subtraction
INPUT:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace S_calculator
{
public partial class vishal_131043107006 : Form
{
int sign = 0;
double variable1;
double variable2;
int add = 0;
int sub = 0;
int mul = 0;
int div = 0;
int mod = 0;
Boolean fl = false;
String s, x;
public vishal_131043107006()
{
InitializeComponent();
}
private void btn1_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(1);
}
OUTPUT:-
INPUT:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
listBox1.Items.Add(txt1.Text);
listBox1.Items.Add(txt2.Text);
txt1.Clear();
txt2.Clear();
}
private void btnRemove_Click(object sender, EventArgs e)
{
while (listBox1.SelectedItems.Count != 0)
{
listBox1.Items.Remove(listBox1.SelectedItems[0]);
}
}
private void btnExit_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
OUTPUT:-
(Practical No:-3)
AIM:- Develop photo viewer using C#.NET.
INPUT:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PictureViewer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "jpg(*.jpg)|*.jpg|bmp(*.bmp)|*.bmp|png(*.png)|*.png";
if (ofd.ShowDialog() == DialogResult.OK && ofd.FileName.Length > 0)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
pictureBox1.Image = Image.FromFile(ofd.FileName);
}
}
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Filter = "jpg(*.jpg)|*.jpg|bmp(*.bmp)|*.bmp|png(*.png)|*.png";
if (sfd.ShowDialog() == DialogResult.OK && sfd.FileName.Length > 0)
Name: Senjaliya Vishal D.
OUTPUT:-
(Practical No:-4)
AIM:- Create a main menu named as File and members of file menu are save,
close, open, new print and Exit and also implement functionalities of those
menu members.
INPUT:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Notpad
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
private void openToolStripMenuItem_Click(object sender, EventArgs e)
{
OpenFileDialog op = new OpenFileDialog();
if (op.ShowDialog() == DialogResult.OK)
{
richTextBox1.LoadFile(op.FileName, RichTextBoxStreamType.PlainText);
this.Text = op.FileName;
}
}
if (fd.ShowDialog() == DialogResult.OK)
{
richTextBox1.SelectionFont = fd.Font;
}
}
private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog cr = new ColorDialog();
if (cr.ShowDialog() == DialogResult.OK)
{
richTextBox1.BackColor = cr.Color;
}
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Devloped By vishal senjaliya");
}
private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.SelectAll();
}
}
}
(Practical No:-5)
AIM:- Develop Login page, which should fetch username and password from text
file, and perform validation if it matches username and password.
INPUT:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace LoginForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
TextReader uname = new StreamReader(@"C:\Users\user\Documents\Visual Studio
2012\Projects\LoginForm\username.txt");
string name = uname.ReadLine();
uname.Close();
TextReader psd = new StreamReader(@"C:\Users\user\Documents\Visual Studio
2012\Projects\LoginForm\password.txt");
string pnm = psd.ReadLine();
psd.Close();
if (name.Equals(textBox1.Text))
{
if (pnm.Equals(textBox2.Text))
{
MessageBox.Show("Successfully Login....Congratulation");
}
Name: Senjaliya Vishal D.
INPUT:
Form1.cs : Registration,Login,Changepassword,admin
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace LoginSystem
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SqlConnection conn = new SqlConnection(@"Data Source=ADMIN\SQLEXPRESS;Initial
Catalog=student1;Integrated Security=True");
private void btnSub_Click(object sender, EventArgs e)
{
if (txtPass.Text == txtConfirmPass.Text)
{
SqlDataAdapter sd = new SqlDataAdapter("insert into
detail(studentname,password,confirmpassword,collegename,mobileno,gender) values('" +
txtName.Text + "','" + txtPass.Text +
"','"+txtConfirmPass.Text+"','"+txtCollegeName.Text+"','"+txtMobile.Text+"','"+cmbGender.Tex
t+"')", conn);
DataTable ss = new DataTable();
sd.Fill(ss);
MessageBox.Show("Your account successfully created.....");
}
private void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection conn1 = new SqlConnection(@"Data
Source=ADMIN\SQLEXPRESS;Initial Catalog=student1;Integrated Security=True");
conn1.Open();
SqlCommand cmd = new SqlCommand("select * from detail where studentname ='" +
txtLog.Text + "' and password='" + txtLogPass.Text + "'",conn1);
SqlDataReader dr;
dr = cmd.ExecuteReader();
int count = 0;
while (dr.Read())
{
count += 1;
}
if (count == 1)
{
this.Hide();
Form2 fr = new Form2();
fr.Show();
}
else if (count > 0)
{
MessageBox.Show("Duplicate Studentname and Password");
Form2.cs : Registration,Login,Changepassword,admin
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace LoginSystem
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void PictureBox1_Click(object sender, EventArgs e)
{
DialogResult a =MessageBox.Show("Do you realy want to Logout?", "Response",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (a == DialogResult.Yes)
{
MessageBox.Show("Thank you....");
this.Hide();
Form1 fr1 = new Form1();
fr1.Show();
}
else if(a==DialogResult.No)
{
this.Hide();
Form2 fr2 = new Form2();
fr2.Show();
}
}
private void btnOther_Click(object sender, EventArgs e)
{
this.Hide();
Form3 fr4 = new Form3();
fr4.Show();
}
}
}
Form3.cs :admin(gridview,updatedatabase,showdatabase)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace LoginSystem
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
SqlConnection conn3 = new SqlConnection(@"Data
Source=ADMIN\SQLEXPRESS;Initial Catalog=student1;Integrated Security=True");
SqlDataAdapter sd3;
DataTable dt3;
SqlCommandBuilder bd;
private void btnViewDatabase_Click(object sender, EventArgs e)
{
sd3 = new SqlDataAdapter("select * from detail",conn3);
dt3 = new DataTable();
sd3.Fill(dt3);
dataGridView1.DataSource = dt3;
}
private void btnUpdate_Click(object sender, EventArgs e)
{
try
{
bd = new SqlCommandBuilder(sd3);
sd3.Update(dt3);
MessageBox.Show("Record successfully updated.....!");
}
catch (Exception ex)
{
MessageBox.Show("Error detected.....!");
Name: Senjaliya Vishal D.
INPUT:
Default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
public partial class _Default : System.Web.UI.Page
{
protected void btnLogin_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data
Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\user\Documents\Visual Studio
2010\WebSites\WebSite7\App_Data\131043107006.mdf;Integrated Security=True;User
Instance=True");
SqlCommand cmd = new SqlCommand("select * from login where username=@username
and password=@password",conn);
cmd.Parameters.AddWithValue("@username",TxtUsername.Text);
cmd.Parameters.AddWithValue("@password",TxtPassword.Text);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
conn.Open();
int i = cmd.ExecuteNonQuery();
conn.Close();
if (dt.Rows.Count > 0)
Default2.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Session["id"] != null)
{
Label3.Text ="Welcome dear...." + Session["id"].ToString();
}
else
{
Label3.Text = "Wrong username....";
}
}
protected void btnLogout_Click(object sender, EventArgs e)
{
Session.RemoveAll();
Response.Redirect("Default.aspx");
}
}
OUTPUT
OUTPUT: