Вы находитесь на странице: 1из 37

A Project Report On Automation of Gas Agency(New Connection Module)

Submitted To:Lect. Ram Sir Su bmitted By: Nam e: Atul Kumar Chaturvedi Regis tration No: 11006547

Cour se Code: CAP612T Ro ll No.: A08 G1

Introduction:-

The project is about the new connection of gas cylinder. In this project there are different module which has designed for the Administrator and The employee of the gas agency. The Administrator can view the connection info,delete it and also can add an employee and transfer the connection. In the employee module, the employee can add a new connection , remove a connection,update connection information , change his password, view the information of a particular connection by entering its connection ID .

Module Of Project:
developed in this project.They are: 1) Employee a)Add New Connection b)Delete Connection c)Update Connection

There

are

different

module

d)View Connection Information e)Product Price f)View All Connections g)Change Password

2) Administrator a)Transfer Connection b)View Connection Information c)Delete Connection d)Employee Management

Employee Login

Coding Of Login Form


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; using System.Data.Sql; namespace Proj_Gas_Agency { public partial class Login_Form : Form { SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); int x, y; public Login_Form() { InitializeComponent(); }

private void Login_Form_Load(object sender, EventArgs e) { x = label1.Location.X; y = label1.Location.Y; } //private void button1_Click(object sender, EventArgs e) //{ //} private void btnRst_Click(object sender, EventArgs e) { txtPass.Text = ""; txtUID.Text = ""; txtUID.Focus(); }

private void btnExt_Click(object sender, EventArgs e) { this.Close(); } private void btnGo_Click(object sender, EventArgs e) { if (txtUID.Text == "" || txtPass.Text == "") { MessageBox.Show("Please Fill All The Details"); txtUID.Focus(); } else { if (cmbDeprt.SelectedItem == "Admin") { SqlCommand cmd = new SqlCommand("Select uid,passwrd from admin_login where uid='" + txtUID.Text + "' and passwrd='" + txtPass.Text + "'", objConn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 1) { this.Hide(); Admin adm = new Admin(); adm.Show(); } else { MessageBox.Show("Invalid User Name Or Password!"); txtPass.Text = ""; txtUID.Text = ""; txtUID.Focus(); } objConn.Open(); cmd.ExecuteNonQuery(); objConn.Close(); } else {

SqlCommand cmd = new SqlCommand("Select uid,passwrd from employee_login where uid='" + txtUID.Text + "' and passwrd='" + txtPass.Text + "'", objConn); SqlDataAdapter da = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 1) { this.Hide(); Form2 mdi = new Form2(); mdi.Show(); } else { MessageBox.Show("Invalid User Name Or Password!"); txtPass.Text = ""; txtUID.Text = ""; txtUID.Focus(); } objConn.Open(); cmd.ExecuteNonQuery(); objConn.Close(); } } } private void panel2_Paint(object sender, PaintEventArgs e) { }

} }

Description:

Using the login form the employee can login and then he can perform the various task like insertion , deletion and updation.

Employee MDI

Coding Of MDI Form


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 Proj_Gas_Agency { public partial class Form2 : Form { Login_Form log = new Login_Form(); New_Connection newc = new New_Connection(); View_Cons_Info view = new View_Cons_Info(); Delete_Connection del = new Delete_Connection(); Update_Connection update = new Update_Connection(); Product_Price pp = new Product_Price(); Change_Password change = new Change_Password(); Commercial_Use commercial = new Commercial_Use(); public Form2() { InitializeComponent(); } private void statusStrip1_MouseMove(object sender, MouseEventArgs e) { } private void exitToolStripMenuItem_Click(object sender, EventArgs e) { ActiveForm.Hide(); log.Show(); } private void viewInformationToolStripMenuItem_Click(object sender, EventArgs e) { view.MdiParent = this; newc.Hide(); del.Hide(); change.Hide(); commercial.Hide(); update.Hide(); view.Show(); }

private void addConnectionToolStripMenuItem_Click(object sender, EventArgs e) {

} private void Form2_Load(object sender, EventArgs e) { } private void deleteConnectionToolStripMenuItem_Click(object sender, EventArgs e) { del.MdiParent = this; update.Hide(); pp.Hide(); newc.Hide(); view.Hide(); change.Hide(); commercial.Hide(); del.Show(); } private void updateConsumerInfoToolStripMenuItem_Click(object sender, EventArgs e) { update.MdiParent = this; change.Hide(); pp.Hide(); newc.Hide(); commercial.Hide(); view.Hide(); del.Hide(); update.Show(); } private void productPriceToolStripMenuItem_Click(object sender, EventArgs e) { pp.MdiParent = this;

change.Hide(); newc.Hide(); view.Hide(); del.Hide(); commercial.Hide(); update.Hide(); pp.Show(); } private void forHomeUseToolStripMenuItem_Click(object sender, EventArgs e) { del.Hide(); view.Hide(); pp.Hide(); change.Hide(); commercial.Hide(); newc.MdiParent = this; update.Hide(); newc.Show(); } private void changePasswordToolStripMenuItem_Click(object sender, EventArgs e) { del.Hide(); view.Hide(); newc.Hide(); pp.Hide(); commercial.Hide(); change.MdiParent = this; update.Hide(); change.Show(); } private void forBusinessUseToolStripMenuItem_Click(object sender, EventArgs e) { del.Hide(); view.Hide(); newc.Hide(); pp.Hide(); change.Hide(); update.Hide();

commercial.MdiParent = this; commercial.Show(); } private void printToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("Please Attach The Printer First..!"); } } }

Description:

Using this mdi form the employee can select the various option to perform a particular task.

New Connection

Coding Of New Connection Form


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 Proj_Gas_Agency { public partial class New_Connection : Form { SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); Login_Form log = new Login_Form(); // New_Connection newc = new New_Connection(); public New_Connection() { InitializeComponent(); } private void btnRst_Click(object sender, EventArgs e) { txtAdd1.Text = ""; txtAdd2.Text = ""; txtAdd3.Text = ""; txtConId.Text = ""; txtContNo.Text = ""; txtFname.Text = ""; txtLname.Text = ""; txtMname.Text = ""; txtPcode.Text = ""; cmbTitle.Text = "Select"; cmbDd.Text = "[DATE]"; cmbMm.Text = "[MONTH]"; cmbYer.Text = "[YEAR]"; cmbIdProof.Text = "[SELECT IDENTIFICATION DOCUMENT]"; txtSecDepst.Text = "3000"; Random rand = new Random();

txtConId.Text = "" + rand.Next(12345, 99999); } private void New_Connection_Load(object sender, EventArgs e) { txtSecDepst.Enabled = false; txtSecDepst.Text = "3000"; Random rand = new Random(); txtConId.Text = "" + rand.Next(12345, 99999); txtConId.Enabled = false; cmbTitle.Focus(); } private void btnBack_Click(object sender, EventArgs e) { this.Close(); } private void button1_Click(object sender, EventArgs e) { ActiveForm.Hide(); log.Show(); } private void btnSbmit_Click(object sender, EventArgs e) { try { objDA.InsertCommand = new SqlCommand(); objDA.InsertCommand.CommandText = @"insert into new_con(con_id ,title ,fname ,mname,lname ,dob,address ,pcode,cont_info,id_proof,security_deposit) values(" + txtConId.Text + ",'" + cmbTitle.SelectedItem + "','" + txtFname.Text + "','" + txtMname.Text + "','" + txtLname.Text + "','" + cmbDd.SelectedItem + '-' + cmbMm.SelectedItem + '-' + cmbYer.SelectedItem + "','" + txtAdd1.Text + ',' + txtAdd2.Text + ',' + txtAdd3.Text + "'," + txtPcode.Text + ",'" + txtContNo.Text + "','" + cmbIdProof.SelectedItem + "'," + txtSecDepst.Text + ")"; objDA.InsertCommand.Connection = objConn; objConn.Open(); objDA.InsertCommand.ExecuteNonQuery(); objConn.Close();

MessageBox.Show("Saved Successfully !"); txtAdd1.Text = ""; txtAdd2.Text = ""; txtAdd3.Text = ""; txtConId.Text = ""; txtContNo.Text = ""; txtFname.Text = ""; txtLname.Text = ""; txtMname.Text = ""; txtPcode.Text = ""; cmbTitle.Text = "Select"; cmbDd.Text = "[DATE]"; cmbMm.Text = "[MONTH]"; cmbYer.Text = "[YEAR]"; cmbIdProof.Text = "[SELECT IDENTIFICATION DOCUMENT]"; txtSecDepst.Text = "3000"; } catch (Exception g) { MessageBox.Show("Please Fill All Details!"); txtAdd1.Text = ""; txtAdd2.Text = ""; txtAdd3.Text = ""; txtConId.Text = ""; txtContNo.Text = ""; txtFname.Text = ""; txtLname.Text = ""; txtMname.Text = ""; txtPcode.Text = ""; cmbTitle.Text = "Select"; cmbDd.Text = "[DATE]"; cmbMm.Text = "[MONTH]"; cmbYer.Text = "[YEAR]"; cmbIdProof.Text = "[SELECT IDENTIFICATION DOCUMENT]"; txtSecDepst.Text = "3000"; Random rand = new Random(); txtConId.Text = "" + rand.Next(12345, 99999); } } private void panel3_Paint(object sender, PaintEventArgs e) { } private void textBox1_TextChanged(object sender, EventArgs e)

{ } } }

Description: In this the data of the user will be inserted


and the new connection ID will be generated.

Delete connection

Coding Of Deleting Connection


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 Proj_Gas_Agency { public partial class Delete_Connection : Form { SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); int x, y; Login_Form log = new Login_Form(); public Delete_Connection() { InitializeComponent(); } private void btnClr_Click(object sender, EventArgs e) { txtID.Text = ""; txtname.Text = ""; txtAdd.Text = ""; txtMob.Text = ""; btnShow.Enabled = true; } private void panel2_Paint(object sender, PaintEventArgs e) { } private void Delete_Connection_Load(object sender, EventArgs e) { }

private void btnShow_Click(object sender, EventArgs e) { if (txtID.Text == "") { MessageBox.Show("Please Enter The Consumer Id !"); } else { objDA.SelectCommand = new SqlCommand(); objDA.SelectCommand.Connection = objConn; objDA.SelectCommand.CommandText = "select * from new_con where con_id='" + txtID.Text +"'"; objDA.SelectCommand.CommandType = CommandType.Text; objConn.Open(); objDA.SelectCommand.CommandText = "Select fname from new_con Where con_id='" + txtID.Text + "'" ; txtname.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select address from new_con Where con_id='" + txtID.Text + "'"; txtAdd.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select cont_info from new_con Where con_id='" + txtID.Text + "'"; txtMob.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objConn.Close(); btnShow.Enabled = false; } } private void btnDlt_Click(object sender, EventArgs e) { if (txtID.Text == "") { MessageBox.Show("Please Enter The Consumer Id !"); } else { objDA.DeleteCommand = new SqlCommand(); objDA.DeleteCommand.Connection = objConn; objDA.DeleteCommand.CommandText = "Delete from new_con where con_id = " + txtID.Text; objDA.DeleteCommand.CommandType = CommandType.Text;

objConn.Open(); objDA.DeleteCommand.ExecuteNonQuery(); objConn.Close(); MessageBox.Show("One Record Deleted Successfully"); txtID.Text = ""; txtname.Text = ""; txtAdd.Text = ""; txtMob.Text = ""; txtID.Focus(); } }

private void btnBack_Click(object sender, EventArgs e) { this.Hide(); } } }

Update connection:

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 Proj_Gas_Agency { public partial class Update_Connection : Form { SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); public Update_Connection() {

InitializeComponent(); } private void panel1_Paint(object sender, PaintEventArgs e) { } private void btnUpdate_Click(object sender, EventArgs e) { if (textID.Text == "") { MessageBox.Show("Please Enter The Connection ID !"); } else { txtName.Enabled = true; txtConNo.Enabled = true; txtLname.Enabled = true; txtName.Enabled = true; txtPcode.Enabled = true; txtMname.Enabled = true; txtAd1.Enabled = true; cmbIDprof.Enabled = true; txtDob.Enabled = true; cmbTitle.Enabled = true; } } private void Update_Connection_Load(object sender, EventArgs e) { textID.Focus(); txtName.Enabled = false; txtConNo.Enabled = false; txtLname.Enabled = false; txtName.Enabled = false; txtPcode.Enabled = false; txtMname.Enabled = false; txtAd1.Enabled = false; cmbIDprof.Enabled = false; txtDob.Enabled = false; cmbTitle.Enabled = false;

} private void btnRst_Click(object sender, EventArgs e) { textID.Text = ""; txtAd1.Text = ""; txtConNo.Text = ""; txtDob.Text = ""; txtLname.Text = ""; txtMname.Text = ""; txtName.Text = ""; txtPcode.Text = ""; cmbIDprof.Text = "[SELECT IDENTIFICATION DOCUMENT]"; cmbTitle.Text = "[Select]"; textID.Focus(); txtName.Enabled = false; txtConNo.Enabled = false; txtLname.Enabled = false; txtName.Enabled = false; txtPcode.Enabled = false; txtMname.Enabled = false; txtAd1.Enabled = false; cmbIDprof.Enabled = false; txtDob.Enabled = false; cmbTitle.Enabled = false; } private void btnSerch_Click(object sender, EventArgs e) { if (textID.Text == "") { MessageBox.Show("Please Enter The Consumer Id !"); } else { try { objDA.SelectCommand = new SqlCommand(); objDA.SelectCommand.Connection = objConn; objDA.SelectCommand.CommandText = "select * from new_con where con_id=" + textID.Text; objDA.SelectCommand.CommandType = CommandType.Text; objConn.Open(); objDA.SelectCommand.CommandText = "Select title from new_con Where con_id='" + textID.Text + "'";

cmbTitle.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + textID.Text + "'"; txtName.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + textID.Text + "'"; txtMname.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + textID.Text + "'"; txtLname.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + textID.Text + "'"; txtDob.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + textID.Text + "'"; txtPcode.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + textID.Text + "'"; txtAd1.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + textID.Text + "'"; txtConNo.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + textID.Text + "'"; cmbIDprof.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objConn.Close(); }

fname from

mname from

lname from

dob from

pcode from

address from

cont_info from

id_proof from

catch (Exception ex) { MessageBox.Show("Consumer ID Does Not Exist !"); textID.Text = ""; } } }

private void btnBack_Click(object sender, EventArgs e) { this.Hide(); } private void btnSbmt_Click(object sender, EventArgs e) { objDA.UpdateCommand = new SqlCommand(); objDA.UpdateCommand.Connection = objConn; objDA.UpdateCommand.CommandText = @"update new_con set title='"+cmbTitle.SelectedItem+"' ,fname='"+txtName.Text+"' ,mname='"+txtMname.Text+"',lname='"+txtLname.Text+"' ,dob='"+txtDob.Text+"',address='"+txtAd1.Text+"' ,pcode='"+txtPcode.Text+"',cont_info='"+txtConNo.Text+"',id_proof='"+cmbI Dprof.SelectedItem+"' where con_id='"+textID.Text+"'"; objConn.Open(); objDA.UpdateCommand.ExecuteNonQuery(); objConn.Close(); MessageBox.Show("Record Updated Successfully !"); } } }

View connection info:

View connection Coding:


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 Proj_Gas_Agency { public partial class View_Cons_Info : Form { SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); Login_Form log = new Login_Form(); public View_Cons_Info() { InitializeComponent(); }

private void panel3_Paint(object sender, PaintEventArgs e) { } private void View_Cons_Info_Load(object sender, EventArgs e) { txtFname.Enabled = false; txtMname.Enabled = false; txtLname.Enabled = false; txtPcode.Enabled = false; txtSecdeposit.Enabled = false; txtTitle.Enabled = false; txtDOB.Enabled = false; txtContact.Enabled = false; txtAdd.Enabled = false; txtIdproof.Enabled = false; } private void button1_Click(object sender, EventArgs e) { if (txtId.Text == "") { MessageBox.Show("Please Enter The Consumer Id !"); } else { try { objDA.SelectCommand = new SqlCommand(); objDA.SelectCommand.Connection = objConn; // objDA.SelectCommand.CommandText = "select * from new_con where con_id=" + txtId.Text; // objDA.SelectCommand.CommandType = CommandType.Text; objConn.Open(); objDA.SelectCommand.CommandText = "Select title from new_con Where con_id='" + txtId.Text + "'"; txtTitle.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select fname from new_con Where con_id='" + txtId.Text + "'"; txtFname.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar());

objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + txtId.Text + "'"; txtMname.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + txtId.Text + "'"; txtLname.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + txtId.Text + "'"; txtDOB.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + txtId.Text + "'"; txtAdd.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + txtId.Text + "'"; txtPcode.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + txtId.Text + "'"; txtAdd.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + txtId.Text + "'"; txtContact.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select new_con Where con_id='" + txtId.Text + "'"; txtIdproof.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select from new_con Where con_id='" + txtId.Text + "'"; txtSecdeposit.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objConn.Close(); }

mname from

lname from

dob from

address from

pcode from

address from

cont_info from

id_proof from

security_deposit

catch (Exception ex) { MessageBox.Show("Consumer ID Does Not Exist !"); txtId.Text = ""; } button1.Enabled = false;

} } private void button2_Click(object sender, EventArgs e) { txtFname.Text = ""; txtMname.Text = ""; txtLname.Text = ""; txtIdproof.Text = ""; txtId.Text = ""; txtDOB.Text = ""; txtContact.Text = ""; txtAdd.Text = ""; txtPcode.Text = ""; txtSecdeposit.Text = ""; txtTitle.Text = ""; button1.Enabled = true; txtId.Focus(); } private void button4_Click(object sender, EventArgs e) { ActiveForm.Hide(); log.Show(); } } }

Changing of password :

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 Proj_Gas_Agency { public partial class Change_Password : Form { SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); public Change_Password() { InitializeComponent(); } private void button2_Click(object sender, EventArgs e)

{ txtID.Text = ""; txtCurPass.Text = ""; txtNewPass.Text = ""; txtRePass.Text = ""; txtID.Focus(); } private void btnChange_Click(object sender, EventArgs e) { if (txtNewPass.Text == txtRePass.Text) { objDA.UpdateCommand = new SqlCommand(); objDA.UpdateCommand.Connection = objConn; objDA.UpdateCommand.CommandText = @"update employee_login set passwrd='" + txtRePass.Text + "' where uid='" + txtID.Text + "'"; objConn.Open(); objDA.UpdateCommand.ExecuteNonQuery(); objConn.Close(); MessageBox.Show("Password Changed Successfully !"); txtID.Text = ""; txtCurPass.Text = ""; txtNewPass.Text = ""; txtRePass.Text = ""; txtID.Focus(); } else { MessageBox.Show("Password Is Not Same !"); txtID.Text = ""; txtCurPass.Text = ""; txtNewPass.Text = ""; txtRePass.Text = ""; txtID.Focus(); } } } }

Administartor:-

Transfer Connection:

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 Proj_Gas_Agency { public partial class Transfer_Connection : Form { SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); Login_Form log = new Login_Form();

public Transfer_Connection() { InitializeComponent(); } private void btnRst_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { objDA.SelectCommand = new SqlCommand(); objDA.SelectCommand.Connection = objConn; objDA.SelectCommand.CommandText = "select * from new_con where con_id=" + txtConID.Text; objDA.SelectCommand.CommandType = CommandType.Text; objConn.Open(); objDA.SelectCommand.CommandText = "Select fname from new_con Where con_id='" + txtConID.Text + "'"; txtName.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select address from new_con Where con_id='" + txtConID.Text + "'"; txtAdd.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select cont_info from new_con Where con_id='" + txtConID.Text + "'"; txtMobNo.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objDA.SelectCommand.CommandText = "Select id_proof from new_con Where con_id='" + txtConID.Text + "'"; txtIDProof.Text = Convert.ToString(objDA.SelectCommand.ExecuteScalar()); objConn.Close(); } private void btnSave_Click(object sender, EventArgs e) { objDA.InsertCommand = new SqlCommand(); objDA.InsertCommand.CommandText = @"insert into transfered_connection(conn_id,title,Name, DOB,address,pcode, cont_info,id_proof) values('"+txtTrCid.Text+"','"+cmbTitle.SelectedItem+"','"+txtTrName.Text+"',

'"+txtTrDob.Text+"','"+txtTrAddrs.Text+"','"+txtTrPcode.Text+"','"+txtTrMob No.Text+"','"+cmbTrIdproof.SelectedItem+"')"; objDA.InsertCommand.Connection = objConn; objConn.Open(); objDA.InsertCommand.ExecuteNonQuery(); objConn.Close();

MessageBox.Show("Connection Transfered Successfully !"); } private void btnTrnsfr_Click(object sender, EventArgs e) { txtTrCid.Text = txtConID.Text; objDA.DeleteCommand = new SqlCommand(); objDA.DeleteCommand.Connection = objConn; objDA.DeleteCommand.CommandText = "Delete from new_con where con_id = " + txtConID.Text; objDA.DeleteCommand.CommandType = CommandType.Text; objConn.Open(); objDA.DeleteCommand.ExecuteNonQuery(); objConn.Close(); } } }

ADD Employee

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 Proj_Gas_Agency { public partial class Add_Emp : Form {

SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); public Add_Emp() { InitializeComponent(); } private void panel1_Paint(object sender, PaintEventArgs e) { txtDprt.Enabled=false; } private void button1_Click(object sender, EventArgs e) { if(txtName.Text=="" ||txtPass.Text==""|| txtUid.Text=="") { MessageBox.Show("Please Fill All The Information !"); txtName.Text = ""; txtPass.Text = ""; txtUid.Text = ""; txtName.Focus(); } else { objDA.InsertCommand = new SqlCommand(); objDA.InsertCommand.CommandText = @"insert into employee_login (name,department,uid,passwrd) values ('"+txtName.Text+"','"+txtDprt.Text+"','"+txtUid.Text+"','"+txtPass.Text+"' ) "; objDA.InsertCommand.Connection = objConn; objConn.Open(); objDA.InsertCommand.ExecuteNonQuery(); objConn.Close(); MessageBox.Show("Saved Successfully !"); txtName.Text = ""; txtPass.Text = ""; txtUid.Text = ""; txtName.Focus(); }

} private void btnReset_Click(object sender, EventArgs e) { txtName.Text = ""; txtPass.Text = ""; txtUid.Text = ""; txtName.Focus(); } private void btnExit_Click(object sender, EventArgs e) { this.Close(); } } }

Remove emp:

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 Proj_Gas_Agency { public partial class Remove : Form { SqlConnection objConn = new SqlConnection("Data Source=ATULPC\\SQLEXPRESS;Initial Catalog=gas_agency;trusted_connection=yes"); SqlDataAdapter objDA = new SqlDataAdapter(); DataSet objDS = new DataSet(); DataTable objDT = new DataTable(); public Remove() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { objDA.DeleteCommand = new SqlCommand(); objDA.DeleteCommand.Connection = objConn; objDA.DeleteCommand.CommandText = "Delete from employee_login where uid =' " + txtEID.Text+ "'"; objDA.DeleteCommand.CommandType = CommandType.Text; objConn.Open(); objDA.DeleteCommand.ExecuteNonQuery(); objConn.Close(); MessageBox.Show("One Record Deleted Successfully !"); txtEID.Text = ""; txtEID.Focus(); } private void btnCancl_Click(object sender, EventArgs e) { this.Close(); } } }

Вам также может понравиться