private void btnMBus_Click(object sender, EventArgs e) { string caption = "Important"; string message = "Migrate" + " " + PersonalGrid.SelectedCells[1].Value.ToString() + " " + PersonalGrid.SelectedCells[2].Value.ToString() + "?"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(message, caption, buttons); if (result == DialogResult.Yes) { BusinessContact businessContact = new BusinessContact(); businessContact.contactFname = txbFname.Text; businessContact.ContactLname = txbLname.Text; businessContact.contactEmail = txbEmail.Text; businessContact.BusinessTel = txbPtel.Text; businessContact.contactAddr1 = txbAddr1.Text; businessContact.contactAddr2 = txbAddr2.Text; businessContact.contactAddr3 = txbAddr3.Text; businessContact.contactPostcode = txbPostcode.Text; businessContact.contactCity = txbCity.Text; dconn.InsertBusiness(businessContact); dconn.DeletePersonal(Int32.Parse(PersonalGrid.SelectedCells[0].Value.ToString())); dataRefresh(); } }
private void btnSaveNew_Click(object sender, EventArgs e) { BusinessContact businessContact = new BusinessContact(); businessContact.contactFname = txbFname.Text; businessContact.ContactLname = txbLname.Text; businessContact.contactEmail = txbEmail.Text; businessContact.BusinessTel = txbBtel.Text; businessContact.contactAddr1 = txbAddr1.Text; businessContact.contactAddr2 = txbAddr2.Text; businessContact.contactAddr3 = txbAddr3.Text; businessContact.contactPostcode = txbPostcode.Text; businessContact.contactCity = txbCity.Text; dconn.InsertBusiness(businessContact); dataRefresh(); txbFname.Enabled = false; txbLname.Enabled = false; txbEmail.Enabled = false; txbBtel.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; }
private void btnSaveSelected_Click(object sender, EventArgs e) { int index = Int32.Parse(BusinessGrid.SelectedCells[0].Value.ToString()); BusinessContact businessContact = new BusinessContact(); businessContact.ContactID = index; businessContact.contactFname = txbFname.Text; businessContact.ContactLname = txbLname.Text; businessContact.contactEmail = txbEmail.Text; businessContact.BusinessTel = txbBtel.Text; businessContact.contactAddr1 = txbAddr1.Text; businessContact.contactAddr2 = txbAddr2.Text; businessContact.contactAddr3 = txbAddr3.Text; businessContact.contactPostcode = txbPostcode.Text; businessContact.contactCity = txbCity.Text; dconn.UpdatetBusiness(businessContact); dataRefresh(); txbFname.Enabled = false; txbLname.Enabled = false; txbEmail.Enabled = false; txbBtel.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; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public async void InsertBusiness(BusinessContact businessContact) { using (var conn = new MySqlConnection(connString)) { await conn.OpenAsync(); using (var mysqlcmd = new MySqlCommand()) { mysqlcmd.Connection = conn; mysqlcmd.CommandText = "CALL insertBusiness (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9);"; mysqlcmd.Parameters.AddWithValue("p1", businessContact.contactFname); mysqlcmd.Parameters.AddWithValue("p2", businessContact.ContactLname); mysqlcmd.Parameters.AddWithValue("p3", businessContact.contactEmail); mysqlcmd.Parameters.AddWithValue("p4", businessContact.BusinessTel); mysqlcmd.Parameters.AddWithValue("p5", businessContact.contactAddr1); mysqlcmd.Parameters.AddWithValue("p6", businessContact.contactAddr2); mysqlcmd.Parameters.AddWithValue("p7", businessContact.contactAddr3); mysqlcmd.Parameters.AddWithValue("p8", businessContact.contactPostcode); mysqlcmd.Parameters.AddWithValue("p9", businessContact.contactCity); await mysqlcmd.ExecuteNonQueryAsync(); } } }