private void btnSubmit_Click(object sender, EventArgs e) { string empid = txtemid.Text.Trim(); string frontOfficefname = txtfrontfname.Text.Trim(); string frontOfficelname = txtfrontlname.Text.Trim(); string addressl1 = txtaddli1.Text.Trim(); string street = txtstreet.Text.Trim(); string city = txtcity.Text.Trim(); string gender; if (this.rdbmale.Checked == true) { gender = "Male"; } else { gender = "Female"; } string dob = dtpdate.Text; int age = int.Parse(txtage.Text.Trim()); FrontOffice frontOffice = new FrontOffice(empid, frontOfficefname, frontOfficelname, addressl1, street, city, gender, dob, age); FrontOfficeDBOper fdbo = new FrontOfficeDBOper(); ArrayList list = new ArrayList(); list.Add(txtcontactmob.Text.Trim()); list.Add(txtcontacthome.Text.Trim()); fdbo.RegFrontOffice(frontOffice, list); MessageBox.Show("Successfully Registered the Front Officer", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public void RegFrontOffice(FrontOffice frontOffice, ArrayList contactno) { string empid = frontOffice.getempid(); string frontOfficefname = frontOffice.getfname(); string frontOfficelname = frontOffice.getlname(); string addressl1 = frontOffice.getaddressl1(); string street = frontOffice.getstreet(); string city = frontOffice.getcity(); string gender = frontOffice.getgender(); string dob = frontOffice.getdob(); int age = frontOffice.getage(); conn.Open(); SqlCommand cmd = new SqlCommand("Insert into FrontOffices values ('" + empid + "', '" + frontOfficefname + "','" + frontOfficelname + "','" + addressl1 + "', '" + street + "', '" + city + "', '" + gender + "', '" + dob + "', '" + age + "')", conn); cmd.ExecuteNonQuery(); SqlCommand cmd1 = new SqlCommand("Insert into EmployeeContacts values ('" + empid + "', '" + contactno[0] + "')", conn); cmd1.ExecuteNonQuery(); SqlCommand cmd2 = new SqlCommand("Insert into EmployeeContacts values ('" + empid + "', '" + contactno[1] + "')", conn); cmd2.ExecuteNonQuery(); conn.Close(); }