public bool InsertOwner(PersonModel newPerson) { SqlConnection con = null; try { con = new SqlConnection("server=.;database=RMS;integrated security=true"); SqlCommand com = new SqlCommand("insert into RMS_Person (FIRSTNAME,LASTNAME,ADDRESS1,ADDRESS2,PIN_NO,PH_NO,MOBILE_NO,EMAIL) values ('" + newPerson.FirstName + "','" + newPerson.lastName + "','" + newPerson.Address1 + "','" + newPerson.Address2 + "','" + newPerson.PinNo + "','" + newPerson.PhoneNo + "','" + newPerson.MobileNo + "','" + newPerson.Email + "')", con); con.Open(); int count = com.ExecuteNonQuery(); if (count>0) { return true; } else { return false; } } catch (Exception ex) { con.Close(); throw; } finally { con.Close(); } }
public void InsertOwner(PersonModel newPerson) { DaoOwner daOwner = new DaoOwner(); daOwner.InsertOwner(newPerson); }
protected void SaveOwner_Click(object sender, EventArgs e) { PersonModel newPerson = new PersonModel(); newPerson.FirstName = txtFirstName.Text; newPerson.lastName = txtLastName.Text; newPerson.Address1 = txtAddress1.Text; newPerson.Address2 = txtAddress2.Text; newPerson.PinNo = Int32.Parse(txtOwnerPinNo.Text); newPerson.MobileNo = Int64.Parse(txtOwnerMobNo.Text); newPerson.PhoneNo = Int64.Parse(txtOwnerPhNo.Text); newPerson.Email = txtOwnerEmail.Text; BaoOwner baOwner = new BaoOwner(); baOwner.InsertOwner(newPerson); }