private void buttonsave_Click(object sender, EventArgs e) { if (!IsOkay()) { return; } using (var xd = new xing()) { var ret_val = xd.ExecuteScalerInt(new string[] { "exp_acc_name" }, string.Format("select count(exp_acc_id) as cnt from acc_expense_accounts_tb where lower(exp_acc_name)=@exp_acc_name"), new object[] { fGrid.Rows["account"].Cells["desc"].Text.Trim().ToLower() }); if (ret_val > 0) { MessageBox.Show("You Have Already Entered This Expense Account", "Duplicate Item Entry"); return; } xd.CommitTransaction(); } if (!dbm.WarningMessage("Are You Sure You Want To Create This Expense Account ??", "Save Warning")) { return; } ic.expense_accountC _exp = new ic.expense_accountC(); _exp.exp_acc_status = em.exp_acc_statusS.valid; _exp.exp_acc_name = fGrid.Rows["account"].Cells["desc"].Text.ToProperCase(); _exp.exp_acc_type = em.exp_acc_typeS.user_defined; if (fGrid.Rows["item_cat"].Cells["desc"].AuxValue != null) { var _cat = (fGrid.Rows["item_cat"].Cells["desc"].AuxValue as fnn.iGComboItemEX).Tag as ic.expense_catC; _exp.exp_cat_id = _cat.exp_cat_id; _exp.objCategory = _cat; } if (fGrid.Rows["department"].Cells["desc"].AuxValue != null) { var _dept = ((fGrid.Rows["department"].Cells["desc"].AuxValue as fnn.iGComboItemEX).Tag as ic.departmentC); _exp.dept_id = _dept.dept_id; _exp.dept_parent_id = _dept.parent_id; _exp.dept_sys_account_id = _dept.expense_sys_account_id; _exp.objDepartment = _dept; } using (var xd = new xing()) { accn.CreateExpenseAccount(_exp, xd); xd.CommitTransaction(); } sdata.ClearFormCache(em.fm.chart_of_accounts.ToInt16()); if (this.Owner is ExpensesManager) { (this.Owner as ExpensesManager).CreateNewRow(_exp, true); } this.Tag = 1; buttoncancel.PerformClick(); }
void iGridCategory_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e) { iGrid _grid = sender as iGrid; if (_grid.Rows[e.RowIndex].Cells[0].Value != null) { _grid.Rows[e.RowIndex].Cells[0].Value = _grid.Rows[e.RowIndex].Cells[0].Value.ToProperCase(); } if (sender == iGridCategory) { #region Item Category if (_grid.Rows[e.RowIndex].Cells[0].Value == null) { if (_grid.Rows[e.RowIndex].Tag != null) { var _cg = _grid.Rows[e.RowIndex].Tag as ic.church_group_typeC; using (var xd = new xing()) { if (xd.ExecuteScalarInt("select TOP 1 cg_id from church_group_tb where cg_type_id=" + _cg.cg_type_id) == 0) { xd.SingleDeleteCommandExp("church_group_types_tb", new string[] { "cg_type_id" }, new int[] { _cg.cg_type_id }); xd.CommitTransaction(); } else { _grid.Rows[e.RowIndex].Cells[0].Value = _cg.cg_type_name; dbm.ErrorMessage("There Are Some Church Groups Which Are Attached To This Church Group Type", "Delete Operation Will Be Cancelled"); return; } } _grid.Rows[e.RowIndex].Tag = null; datam.DATA_CG_TYPES.Remove(_cg.cg_type_id); _grid.Rows.RemoveAt(e.RowIndex); this.Tag = 1; } return; } else { if (_grid.Rows[e.RowIndex].Tag == null) { //insert using (var xd = new xing()) { var ret_val = xd.ExecuteScalerInt(new string[] { "cg_type_name" }, string.Format("select count(cg_type_id) as cnt from church_group_types_tb where lower(cg_type_name)=@cg_type_name"), new object[] { _grid.Rows[e.RowIndex].Cells[0].Text.ToLower() }); if (ret_val > 0) { MessageBox.Show("You Have Already Entered This Item", "Duplicate Item Entry"); _grid.Rows[e.RowIndex].Cells[0].Value = null; return; } } var _cg = new ic.church_group_typeC(); using (var xd = new xing()) { _cg.cg_type_name = _grid.Rows[e.RowIndex].Cells[0].Text.ToProperCase(); _cg.cg_type_id = xd.SingleInsertCommandTSPInt("church_group_types_tb", new string[] { "cg_type_name", "fs_time_stamp", "lch_id" }, new object[] { _cg.cg_type_name, 0, datam.LCH_ID }); xd.CommitTransaction(); } _grid.Rows[e.RowIndex].Tag = _cg; datam.DATA_CG_TYPES.Add(_cg.cg_type_id, _cg); this.Tag = 1; } else { var _cg = _grid.Rows[e.RowIndex].Tag as ic.church_group_typeC; _cg.cg_type_name = _grid.Rows[e.RowIndex].Cells[0].Value.ToStringNullable(); using (var xd = new xing()) { xd.SingleUpdateCommandALL("church_group_types_tb", new string[] { "cg_type_name", "cg_type_id" }, new object[] { _cg.cg_type_name, _cg.cg_type_id }, 1); xd.CommitTransaction(); } this.Tag = 1; //update } Application.DoEvents(); using (var xd = new xing()) { datam.fill_church_group_types(xd); xd.CommitTransaction(); } } #endregion } if (((e.RowIndex + 1) == _grid.Rows.Count)) { AddRowX(_grid); } }
void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e) { var _cell = fGrid.Cells[e.RowIndex, e.ColIndex]; var _exp = fGrid.Rows[e.RowIndex].Tag as ic.expense_accountC; string _edit_col = null; object _edit_val = null; switch (_cell.Col.Key) { case "exp_name": { if (!string.IsNullOrEmpty(_cell.Text)) { using (var xd = new xing()) { var ret_val = xd.ExecuteScalerInt(new string[] { "exp_acc_name", "exp_acc_id" }, string.Format("select count(exp_acc_id) as cnt from acc_expense_accounts_tb where lower(exp_acc_name)=@exp_acc_name and exp_acc_id<>@exp_acc_id"), new object[] { _cell.Text.Trim().ToLower(), _exp.exp_acc_id }); if (ret_val > 0) { MessageBox.Show("You Have Already Entered This Expense Account Name", "Duplicate Item Entry"); return; } xd.CommitTransaction(); } } _exp.exp_acc_name = string.IsNullOrEmpty(_cell.Text) ? _exp.exp_acc_name : _cell.Text.ToProperCase(); _edit_col = "exp_acc_name"; _edit_val = _exp.exp_acc_name; break; } case "dept": { if (_cell.AuxValue != null) { var _dept = ((_cell.AuxValue as fnn.iGComboItemEX).Tag as ic.departmentC); _exp.dept_id = _dept.dept_id; _exp.dept_parent_id = _dept.parent_id; _exp.dept_sys_account_id = _dept.expense_sys_account_id; } else { _cell.Value = _exp.objDepartment.dept_name; return; } _edit_col = "dept_id"; _edit_val = _exp.dept_id; break; } case "category": { _exp.exp_cat_id = (_cell.AuxValue == null) ? 0 : ((_cell.AuxValue as fnn.iGComboItemEX).Tag as ic.expense_catC).exp_cat_id; if (_cell.AuxValue == null) { _cell.Value = null; } if (_exp.exp_cat_id == 0) { _exp.objCategory = null; } else { _exp.objCategory = datam.DATA_EXPENSE_CATEGORY[_exp.exp_cat_id]; } _edit_col = "exp_cat_id"; _edit_val = _exp.exp_cat_id; sdata.ClearFormCache(em.fm.lcb_periodic_statement.ToInt16()); break; } } using (var xd = new xing()) { if (_edit_col.ToLower() != "dept_id") { if (_edit_col == "exp_name") { xd.SingleUpdateCommandALL("acc_expense_accounts_tb", new string[] { _edit_col, "exp_acc_id" }, new object[] { _edit_val, _exp.exp_acc_id }, 1); xd.SingleUpdateCommandALL("accounts_tb", new string[] { "account_name", "account_id" }, new object[] { _edit_val.ToProperCase(), _exp.sys_account_id }, 1); } else { xd.SingleUpdateCommandALL("acc_expense_accounts_tb", new string[] { _edit_col, "exp_acc_id" }, new object[] { _edit_val, _exp.exp_acc_id }, 1); } } else { xd.SingleUpdateCommandALL("acc_expense_accounts_tb", new string[] { _edit_col, "dept_parent_id", "dept_sys_account_id", "exp_acc_id" }, new object[] { _edit_val, _exp.dept_parent_id, _exp.dept_sys_account_id, _exp.exp_acc_id }, 1); // xd.SingleUpdateCommandALL("accounts_tb", new string[] { "p_account_id", "account_id" }, new object[] { _exp.dept_sys_account_id, _exp.sys_account_id }, 1); } xd.CommitTransaction(); } EditRow(_exp); fGrid.Cols[e.ColIndex].AutoWidth(); }