private void btnSaveNew_Click(object sender, EventArgs e) { PersonalContact personalContact = new PersonalContact(); personalContact.contactFname = txbFname.Text; personalContact.ContactLname = txbLname.Text; personalContact.contactEmail = txbEmail.Text; personalContact.PersonalTel = txbPtel.Text; personalContact.contactAddr1 = txbAddr1.Text; personalContact.contactAddr2 = txbAddr2.Text; personalContact.contactAddr3 = txbAddr3.Text; personalContact.contactPostcode = txbPostcode.Text; personalContact.contactCity = txbCity.Text; dconn.InsertPersonal(personalContact); dataRefresh(); txbFname.Enabled = false; txbLname.Enabled = false; txbEmail.Enabled = false; txbPtel.Enabled = false; txbAddr1.Enabled = false; txbAddr2.Enabled = false; txbAddr3.Enabled = false; txbPostcode.Enabled = false; txbCity.Enabled = false; btnUpdateSelected.Enabled = true; btnDelete.Enabled = true; btnSaveNew.Enabled = false; dataRefresh(); }
private void btnSaveSelected_Click(object sender, EventArgs e) { int index = Int32.Parse(PersonalGrid.SelectedCells[0].Value.ToString()); PersonalContact personalContact = new PersonalContact(); personalContact.ContactID = index; personalContact.contactFname = txbFname.Text; personalContact.ContactLname = txbLname.Text; personalContact.contactEmail = txbEmail.Text; personalContact.PersonalTel = txbPtel.Text; personalContact.contactAddr1 = txbAddr1.Text; personalContact.contactAddr2 = txbAddr2.Text; personalContact.contactAddr3 = txbAddr3.Text; personalContact.contactPostcode = txbPostcode.Text; personalContact.contactCity = txbCity.Text; dconn.UpdatetPersonal(personalContact); dataRefresh(); txbFname.Enabled = false; txbLname.Enabled = false; txbEmail.Enabled = false; txbPtel.Enabled = false; txbAddr1.Enabled = false; txbAddr2.Enabled = false; txbAddr3.Enabled = false; txbPostcode.Enabled = false; txbCity.Enabled = false; btnUpdateSelected.Enabled = true; btnDelete.Enabled = true; btnSaveSelected.Enabled = false; btnAddNew.Enabled = false; }
private void btnMBus_Click(object sender, EventArgs e) { string caption = "Important"; string message = "Migrate" + " " + BusinessGrid.SelectedCells[1].Value.ToString() + " " + BusinessGrid.SelectedCells[2].Value.ToString() + "?"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == DialogResult.Yes) { PersonalContact personalContact = new PersonalContact(); personalContact.contactFname = txbFname.Text; personalContact.ContactLname = txbLname.Text; personalContact.contactEmail = txbEmail.Text; personalContact.PersonalTel = txbBtel.Text; personalContact.contactAddr1 = txbAddr1.Text; personalContact.contactAddr2 = txbAddr2.Text; personalContact.contactAddr3 = txbAddr3.Text; personalContact.contactPostcode = txbPostcode.Text; personalContact.contactCity = txbCity.Text; dconn.InsertPersonal(personalContact); dataRefresh(); dconn.DeleteBusiness(Int32.Parse(BusinessGrid.SelectedCells[0].Value.ToString())); dataRefresh(); } }
////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////////////////// public async void InsertPersonal(PersonalContact personalContact) { using (var conn = new MySqlConnection(connString)) { await conn.OpenAsync(); using (var mysqlcmd = new MySqlCommand()) { mysqlcmd.Connection = conn; mysqlcmd.CommandText = "CALL insertPersonal(@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9);"; mysqlcmd.Parameters.AddWithValue("p1", personalContact.contactFname); mysqlcmd.Parameters.AddWithValue("p2", personalContact.ContactLname); mysqlcmd.Parameters.AddWithValue("p3", personalContact.contactEmail); mysqlcmd.Parameters.AddWithValue("p4", personalContact.PersonalTel); mysqlcmd.Parameters.AddWithValue("p5", personalContact.contactAddr1); mysqlcmd.Parameters.AddWithValue("p6", personalContact.contactAddr2); mysqlcmd.Parameters.AddWithValue("p7", personalContact.contactAddr3); mysqlcmd.Parameters.AddWithValue("p8", personalContact.contactPostcode); mysqlcmd.Parameters.AddWithValue("p9", personalContact.contactCity); await mysqlcmd.ExecuteNonQueryAsync(); } } }