Sunteți pe pagina 1din 41

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

(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);
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


else if (sign == 1)
{
txtInput.Text = Convert.ToString(1);
sign = 0;
}
fl = true;
}
private void btn2_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(2);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(2);
sign = 0;
}
fl = true;
}
private void btn3_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(3);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(3);
sign = 0;
}
fl = true;
}
private void btn4_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(4);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(4);
sign = 0;

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


}
fl = true;
}
private void btn5_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(5);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(5);
sign = 0;
}
fl = true;
}
private void btn6_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(6);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(6);
sign = 0;
}
fl = true;
}
private void btn7_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(7);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(7);
sign = 0;
}
fl = true;
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


private void btn8_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(8);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(8);
sign = 0;
}
fl = true;
}
private void btn9_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(9);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(9);
sign = 0;
}
fl = true;
}
private void btn0_Click(object sender, EventArgs e)
{
if (sign == 0)
{
txtInput.Text = txtInput.Text + Convert.ToString(0);
}
else if (sign == 1)
{
txtInput.Text = Convert.ToString(0);
sign = 0;
}
fl = true;
}
private void reset()
{
add = 0;
sub = 0;

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


mul = 0;
div = 0;
mod = 0;
fl = false;
}
private void btnDot_Click(object sender, EventArgs e)
{
int i = 0;
char chr = '\0';
int decimal_Indicator = 0;
int l = txtInput.Text.Length - 1;
if (sign != 1)
{
for (i = 0; i <= l; i++)
{
chr = txtInput.Text[i];
if (chr == '.')
{
decimal_Indicator = 1;
}
}
if (decimal_Indicator != 1)
{
txtInput.Text = txtInput.Text + Convert.ToString(".");
}
}
}
private void btnAdd_Click_1(object sender, EventArgs e)
{
if (txtInput.Text.Length != 0)
{
calculate();
reset();
add = 1;
sign = 1;
}
}
private void btnSub_Click(object sender, EventArgs e)
{
if (txtInput.Text.Length != 0)

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


{
variable2 = Convert.ToDouble(txtInput.Text);
calculate();
reset();
sub = 1;
sign = 1;
}
}
private void btnDiv_Click(object sender, EventArgs e)
{
if (txtInput.Text.Length != 0)
{
calculate();
reset();
div = 1;
sign = 1;
}
}
private void btnMul_Click(object sender, EventArgs e)
{
if (txtInput.Text.Length != 0)
{
calculate();
reset();
mul = 1;
sign = 1;
}
}
private void btnEqual_Click(object sender, EventArgs e)
{
if (txtInput.Text.Length != 0)
{
calculate();
reset();
}
sign = 1;
}
private void button17_Click(object sender, EventArgs e)
{
s = txtInput.Text;
int l = s.Length;
for (int i = 0; i < l - 1; i++)

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


{
x += s[i];
}
txtInput.Text = x;
x = "";
}
private void calculate()
{
if (txtInput.Text != ".")
{
variable2 = Convert.ToDouble(txtInput.Text);
if (fl == false)
{
variable1 = variable2;
}
else if (add == 1)
{
variable1 = variable1 + variable2;
}
else if (sub == 1)
{
variable1 = variable1 - variable2;
}
else if (mul == 1)
{
variable1 = variable1 * variable2;
}
else if (div == 1)
{
variable1 = variable1 / variable2;
}
else if (mod == 1)
{
variable2 = Convert.ToInt32(txtInput.Text);
variable1 = Convert.ToInt32(variable1 % variable2);
}
else
{
variable1 = variable2;
}
txtInput.Text = Convert.ToString(variable1);
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


}
private void button1_Click(object sender, EventArgs e)
{
if (txtInput.Text.Length != 0)
{
calculate();
reset();
mod = 1;
sign = 1;
}
}
private void btnReset_Click(object sender, EventArgs e)
{
txtInput.Clear();
sign = 0;
variable1 = 0;
variable2 = 0;
reset();
}
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

OUTPUT:-

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


(Practical No:-2.2)
AIM:- Develop window application with add and remove button. Clicking the
add button should prompt user input , and that input should be added to the
ListBox, and delete the selected item from ListBox on click of remove button.

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();
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


}

OUTPUT:-

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

(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.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


{
pictureBox1.Image.Save(sfd.FileName);
MessageBox.Show("Congratulation!! Image save Successfully");
}
}
private void button1_Click(object sender, EventArgs e)
{
RotateImage("clockwise");
}
private void RotateImage(string angle)
{
Bitmap image = new Bitmap(pictureBox1.Image);
if (angle == "clockwise")
{
image.RotateFlip(RotateFlipType.Rotate90FlipNone);
}
if (angle == "anticlockwise")
{
image.RotateFlip(RotateFlipType.Rotate90FlipXY);
}
pictureBox1.Image = image;
}
private void button2_Click(object sender, EventArgs e)
{
RotateImage("anticlockwise");
}
private void pictureBox1_Click(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources.not;
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button4_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._1;
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


private void button5_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._2;
}
private void button6_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._3;
}
private void button7_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._4;
}
private void button8_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._5;
}
private void button9_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._6;
}
private void button10_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._7;
}
private void button11_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._8;
}
private void button12_MouseHover(object sender, EventArgs e)
{

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._9;
}
private void button13_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._10;
}
private void button14_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources._11;
}
private void button3_Click_1(object sender, EventArgs e)
{
pictureBox1.Image = null;
}
private void button15_MouseHover(object sender, EventArgs e)
{
pictureBox1.SizeMode = PictureBoxSizeMode.Zoom;
this.pictureBox1.Image = global::PictureViewer.Properties.Resources.giphy;
}
private void button16_Click(object sender, EventArgs e)
{
pictureBox1.Top = (int)(pictureBox1.Top - (pictureBox1.Height * 0.025));
pictureBox1.Left = (int)(pictureBox1.Left - (pictureBox1.Width * 0.025));
pictureBox1.Height = (int)(pictureBox1.Height + (pictureBox1.Height * 0.05));
pictureBox1.Width = (int)(pictureBox1.Width + (pictureBox1.Width * 0.05));
}
private void button17_Click(object sender, EventArgs e)
{
pictureBox1.Top = (int)(pictureBox1.Top + (pictureBox1.Height * 0.025));
pictureBox1.Left = (int)(pictureBox1.Left + (pictureBox1.Width * 0.025));
pictureBox1.Height = (int)(pictureBox1.Height - (pictureBox1.Height * 0.05));
pictureBox1.Width = (int)(pictureBox1.Width - (pictureBox1.Width * 0.05));
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show("Devloped By Vishal Senjaliya");
}
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

OUTPUT:-

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

(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;
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sv = new SaveFileDialog();
sv.Filter = "Text File(*.txt)|*.txt|All files(*.*)|*.*";
if (sv.ShowDialog() == DialogResult.OK)
{
richTextBox1.SaveFile(sv.FileName, RichTextBoxStreamType.PlainText);
this.Text = sv.FileName;
}
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void cutToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Cut();
}
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Copy();
}
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Paste();
}
private void undoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Undo();
}
private void redoToolStripMenuItem_Click(object sender, EventArgs e)
{
richTextBox1.Redo();
}
private void fontToolStripMenuItem_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
fd.Font = richTextBox1.SelectionFont;

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

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();
}
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


OUTPUT:-

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

(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.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


else
{
MessageBox.Show("Enter a valid password");
textBox1.Text = "";
textBox2.Text = "";
}
}
else
{
MessageBox.Show("invalid username");
textBox1.Text = "";
textBox2.Text = "";
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Text = null;
textBox2.Text = null;
}
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


OUTPUT:-

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


(Practical No:-6)
AIM:- Develop Standard Window application which includes functionalities for user
login and profile management.

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.....");

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


}
else
{
MessageBox.Show("Error detected......Fill correct");
}
txtName.Clear();
txtPass.Clear();
txtConfirmPass.Clear();
txtCollegeName.Clear();
txtMobile.Clear();

}
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");

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


}
else
{
MessageBox.Show("StudentName and Password does not match");
}
txtLog.Clear();
txtLogPass.Clear();
}
private void btnChange_Click(object sender, EventArgs e)
{
SqlConnection conn2 = new SqlConnection(@"Data
Source=ADMIN\SQLEXPRESS;Initial Catalog=student1;Integrated
Security=True");
conn2.Open();
SqlDataAdapter sd1 = new SqlDataAdapter("select count(*) from detail where '"
+ txtSnameChange.Text + "' and password='" + txtOldPass.Text + "'",conn2 );
DataTable ds = new DataTable();
sd1.Fill(ds);
errorProvider1.Clear();
if (ds.Rows[0][0].ToString() == "1")
{
if (txtNewPass.Text == txtConfirmPassChange.Text)
{
SqlDataAdapter cc = new SqlDataAdapter("update detail set
password='"+txtNewPass.Text"',confirmpassword='"+txtConfirmP
assChange.Text+"' where studentname='" + txtSnameChange.Text
+ "' and password='" + txtOldPass.Text + "'", conn2);
DataTable df = new DataTable();
cc.Fill(df);
MessageBox.Show("Password Changed successfully.....",
"message", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
else
{
errorProvider1.SetError(txtNewPass, "Does not match password");
errorProvider1.SetError(txtConfirmPassChange, "Does not match password");
}
}
else
{

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


errorProvider1.SetError(txtSnameChange, "Incorrect Student name");
errorProvider1.SetError(txtOldPass, "Incorrect Old Password");
}
}

private void button1_Click(object sender, EventArgs e)


{
txtName.Clear();
txtPass.Clear();
txtConfirmPass.Clear();
txtCollegeName.Clear();
txtMobile.Clear();
}

private void PictureBox1_Click(object sender, EventArgs e)


{
DialogResult a = MessageBox.Show("Do you realy want to close?", "Response",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (a == DialogResult.Yes)
{
MessageBox.Show("Thank you for visiting....");
this.Close();
}
else if (a == DialogResult.No)
{
this.Hide();
Form1 fr3 = new Form1();
fr3.Show();
}
}
private void button2_Click(object sender, EventArgs e)
{
this.Hide();
Form3 fr4 = new Form3();
fr4.Show();
}
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

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();
}
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

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.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


}
}
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();
Form3 fr2 = new Form3();
fr2.Show();
}
}
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


OUTPUT:-

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


(Practical No:-7)
AIM:- Design web page to demonstrate validation controls
OUTPUT: compareValidator,regularexpressionValidator,requiredfieldvalidator

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


(Practical No:-8)
AIM:- Develop web page and bind the data to Gridview control
OUTPUT:Edit,Update,Delete,Select

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


(Practical No:-9.1)
AIM:- Devlop web application which demonstrate session functionality in login
kind of event to pass username and password from one webpage to another
webpage and to ensure that null session redirect to the login page.web application
could be able to validate the user from the database which should be named by
your enrollment number and table name should be login.

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)

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


{
Session["id"] = TxtUsername.Text;
Response.Redirect("Default2.aspx");
Session.RemoveAll();
}
else
{
Label2.Text = "Your username and password is incorrect";
Label2.ForeColor = System.Drawing.Color.Red;
}
}
}

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");
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

OUTPUT

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE


(Practical No:-9.1)
AIM:- Develop web application which demonstrate count down timer.
INPUT:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default3 : System.Web.UI.Page
{
protected void Timer1_Tick(object sender, EventArgs e)
{
Label2.Text = DateTime.Now.ToString();
}
}

Name: Senjaliya Vishal D.

Enr No: 131043107006

GUJARAT POWER ENGINEERING AND RESEARCH INSTITUTE

OUTPUT:

Name: Senjaliya Vishal D.

Enr No: 131043107006

S-ar putea să vă placă și