private void grdList_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { if (e.RowIndex < 0) { return; } if (e.ColumnIndex == 5) { int rowID = e.RowIndex; btnSave.Text = "Update"; pnlInner.Visible = true; pnlOuter.Visible = true; pnlList.Visible = false; txtID.Enabled = false; txtAccountCodeIN.Enabled = false; txtAccountNameIN.Enabled = false; txtDescription.Enabled = true; cmbStatus.Enabled = true; TaxItemDB tdb = new TaxItemDB(); txtID.Text = grdList.Rows[e.RowIndex].Cells[0].Value.ToString(); txtDescription.Text = grdList.Rows[e.RowIndex].Cells[1].Value.ToString(); txtAccountCodeIN.Text = grdList.Rows[e.RowIndex].Cells[2].Value.ToString(); txtAccountNameIN.Text = tdb.getaccountname(txtAccountCodeIN.Text); txtAccountCodeOUT.Text = grdList.Rows[e.RowIndex].Cells[3].Value.ToString(); txtAccountNameOut.Text = tdb.getaccountname(txtAccountCodeOUT.Text); cmbStatus.SelectedIndex = cmbStatus.FindStringExact(grdList.Rows[e.RowIndex].Cells[4].Value.ToString()); disableBottomButtons(); } } catch (Exception) { } }
private void btnSave_Click(object sender, EventArgs e) { try { taxitem ti = new taxitem(); TaxItemDB taxitemdb = new TaxItemDB(); ti.TaxItemID = txtID.Text; ti.Description = txtDescription.Text; ti.AccountCodeIN = txtAccountCodeIN.Text; ti.AccountNameIN = txtAccountNameIN.Text; ti.AccountCodeOUT = txtAccountCodeOUT.Text; ti.AccountNameOUT = txtAccountNameOut.Text; ti.status = ComboFIll.getStatusCode(cmbStatus.SelectedItem.ToString()); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btn.Text; if (taxitemdb.validateTaxItem(ti)) { if (btnText.Equals("Update")) { if (taxitemdb.updateTaxItem(ti)) { MessageBox.Show("Tax Item updated"); closeAllPanels(); ListTaxItem(); } else { MessageBox.Show("Failed to Tax Item"); } } else if (btnText.Equals("Save")) { if (taxitemdb.insertTaxItem(ti)) { MessageBox.Show("Tax Item Added"); closeAllPanels(); ListTaxItem(); } else { MessageBox.Show("Failed to Insert Tax Item"); } } } else { MessageBox.Show("Tax Item Data Validation failed"); } } catch (Exception) { MessageBox.Show("Failed Adding / Editing Tax Item"); } }
private void ListTaxItem() { try { grdList.Rows.Clear(); TaxItemDB taxitemdb = new TaxItemDB(); List <taxitem> TaxItems = taxitemdb.getTaxItems(); foreach (taxitem ti in TaxItems) { grdList.Rows.Add(ti.TaxItemID, ti.Description, ti.AccountCodeIN, ti.AccountCodeOUT, ComboFIll.getStatusString(ti.status)); } } catch (Exception) { MessageBox.Show("Error in Tax Item listing"); } enableBottomButtons(); pnlList.Visible = true; grdList.Visible = true; }
private Boolean AddTaxWorkingRow() { Boolean status = true; try { if (grdTaxCodeWorking.Rows.Count > 1) { verifyAndReworkTaxGridRows(); } grdTaxCodeWorking.Rows.Add(); int kount = grdTaxCodeWorking.RowCount; grdTaxCodeWorking.Rows[kount - 1].Cells[0].Value = kount; DataGridViewComboBoxCell ComboColumn1 = (DataGridViewComboBoxCell)(grdTaxCodeWorking.Rows[kount - 1].Cells[2]); string firstValue1 = fillArithmetcGridViewCombo(ComboColumn1); ComboColumn1.DropDownWidth = 200; DataGridViewComboBoxCell ComboColumn2 = (DataGridViewComboBoxCell)(grdTaxCodeWorking.Rows[kount - 1].Cells[7]); TaxItemDB.fillTaxItemGridViewCombo(ComboColumn2); ComboColumn2.Items.Add("Dummy"); ComboColumn2.DropDownWidth = 200; DataGridViewComboBoxCell ComboColumn3 = new DataGridViewComboBoxCell(); DataGridViewComboBoxCell ComboColumn4 = new DataGridViewComboBoxCell(); for (int i = 1; i < kount; i++) { ComboColumn3.Items.Add(i.ToString()); ComboColumn4.Items.Add(i.ToString()); } grdTaxCodeWorking.Rows[kount - 1].Cells[3] = ComboColumn3; grdTaxCodeWorking.Rows[kount - 1].Cells[4] = ComboColumn4; //grdCustomerBank.Rows[kount-1].Cells[0].Value = firstValue; } catch (Exception ex) { MessageBox.Show("AddTaxWorkingRow() : Error"); } return(status); }