private void btnConfirm_Click(object sender, EventArgs e) //private void btnSave_Click_1(object sender, EventArgs e) { try { taxcode tc = new taxcode(); TaxCodeDB taxcodedb = new TaxCodeDB(); tc.TaxCode = txtID.Text; tc.Description = txtDescription.Text; tc.status = ComboFIll.getStatusCode(cmbStatus.SelectedItem.ToString()); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btnSave.Text; if (taxcodedb.validateTaxCode(tc)) { if (btnText.Equals("Update")) { if (taxcodedb.updateTaxCode(tc)) { createAndUpdateTaxCodeWorking(); MessageBox.Show("Tax Code updated"); closeAllPanels(); ListTaxCode(); pnlBottomButtons.Visible = true; } else { MessageBox.Show("Failed to update tax Code"); } } else if (btnText.Equals("Save")) { if (taxcodedb.insertTaxCode(tc)) { createAndUpdateTaxCodeWorking(); MessageBox.Show("Tax Code Added"); closeAllPanels(); ListTaxCode(); pnlBottomButtons.Visible = true; } else { MessageBox.Show("Failed to Insert Tax Code"); } } } else { MessageBox.Show("Tax Code Data Validation failed"); } } catch (Exception) { MessageBox.Show("Failed Adding / Editing Tax Code"); } }
private void ListTaxCode() { try { grdList.Rows.Clear(); TaxCodeDB taxcodedb = new TaxCodeDB(); List <taxcode> TaxCodes = taxcodedb.getTaxCode(); foreach (taxcode tc in TaxCodes) { grdList.Rows.Add(tc.TaxCode, tc.Description, ComboFIll.getStatusString(tc.status)); } } catch (Exception) { MessageBox.Show("Error in Tax Code listing"); } enableBottomButtons(); pnlList.Visible = true; }