public void EditRow(ic.expense_accountC _obj) { if (_obj == null) { return; } fGrid.BeginUpdate(); iGRow _row = null; try { _row = fGrid.Rows[_obj.exp_acc_id.ToString()]; } catch (Exception) { CreateNewRow(_obj, true); fGrid.EndUpdate(); return; } _row.Cells["exp_name"].Value = _obj.exp_acc_name.ToProperCase(); if (_obj.objCategory != null) { _row.Cells["category"].Value = _obj.objCategory.exp_cat_name; } if (_obj.dept_id > 0) { _row.Cells["dept"].Value = datam.DATA_DEPARTMENT[_obj.dept_id].dept_name; } _row.Cells["exp_type"].Value = fnn.GetExpenseTypeName(_obj.exp_acc_type); _row.Cells["colSearch"].Value = string.Format("{0} {1} {2} {3}", _obj.exp_acc_name.ToLower(), _row.Cells["exp_type"].Text, _row.Cells["dept"].Text, _row.Cells["category"].Text).ToLower();; fGrid.Cols.AutoWidth(); fGrid.AutoResizeCols = false; fGrid.EndUpdate(); }
public void CreateNewRow(ic.expense_accountC _obj, bool update_mode) { iGRow _row = null; fGrid.BeginUpdate(); _row = fGrid.Rows.Add(); _row.Font = new Font("georgia", 12, FontStyle.Regular); _row.TextAlign = iGContentAlignment.BottomLeft; _row.ReadOnly = iGBool.True; _row.Cells["exp_name"].Value = _obj.exp_acc_name.ToProperCase(); if (_obj.objCategory != null) { _row.Cells["category"].Value = _obj.objCategory.exp_cat_name; } if ((_obj.dept_id > 0 | _obj.dept_id == -5000)) { _row.Cells["dept"].Value = datam.DATA_DEPARTMENT[_obj.dept_id].dept_name; } _row.Cells["exp_type"].Value = fnn.GetExpenseTypeName(_obj.exp_acc_type); _row.Cells["exp_type"].AuxValue = _obj.exp_acc_type.ToByte(); _row.Cells["colSearch"].Value = string.Format("{0} {1} {2} {3}", _obj.exp_acc_name.ToLower(), _row.Cells["exp_type"].Text, _row.Cells["dept"].Text, _row.Cells["category"].Text).ToLower();; _row.Tag = _obj; _row.Key = _obj.exp_acc_id.ToStringNullable(); _row.AutoHeight(); _row.Height += 2; fGrid.EndUpdate(); }
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(); }
private void buttonadd_Click(object sender, EventArgs e) { if (m_action == action_type.create) { #region Insert Region ic.departmentC _dept = new MTOMS.ic.departmentC(); _dept.dept_name = textBox1.Text.Trim().ToProperCase(); if (curr_node.Level == 1) { _dept.parent_id = curr_node.Parent.Tag == null ? 0 : curr_node.Parent.Tag.ToInt32(); } if (curr_node.Level == 2) { _dept.parent_id = curr_node.Parent.Tag == null ? 0 : (curr_node.Parent.Tag as ic.departmentC).dept_id; } _dept.is_visible = true; _dept.level = curr_node.Level; _dept.index = curr_node.Index; string[] _cols = new string[] { "exp_type", "is_visible", "lch_id", "fs_time_stamp", "dept_name", "parent_id", "s_level", "s_index" }; object[] _row = new object[] { emm.export_type.insert.ToByte(), 1, sdata.ChurchID, 0, _dept.dept_name, _dept.parent_id, _dept.level, _dept.index }; using (var xd = new xing()) { if (datam.DuplicateDepartmentName(_dept.dept_name, xd)) { MessageBox.Show("The Department Name You Have Entered Already Exists", "Duplicate Department Name"); buttonclose.PerformClick(); return; } _dept.dept_id = xd.SingleInsertCommandTSPInt("dept_master_tb_ns", _cols, _row); curr_node.Tag = _dept; curr_node.Text = _dept.dept_name; curr_node.Name = string.Format("DEPT{0}", _dept.dept_id); if (_dept.parent_id > 0) { _dept.expense_sys_account_id = accn.CreateChildGroupAccount(xd, datam.DATA_DEPARTMENT[_dept.parent_id].expense_sys_account_id, _dept.dept_name).account_id; _dept.cr_sys_account_id = datam.DATA_DEPARTMENT[_dept.parent_id].cr_sys_account_id; _dept.income_sys_account_id = datam.DATA_DEPARTMENT[_dept.parent_id].income_sys_account_id; } else { _dept.expense_sys_account_id = accn.CreateChildGroupAccount(xd, -2386, _dept.dept_name).account_id; _dept.income_sys_account_id = accn.CreateChildGroupAccount(xd, -2370, _dept.dept_name).account_id; _dept.cr_sys_account_id = accn.CreateChildGroupAccount(xd, -2369, _dept.dept_name).account_id; xd.UpdateFsTimeStamp("accounts_tb"); xd.SingleUpdateCommand(string.Format("update accounts_tb set link_id={0},{1},fs_time_stamp={2} where account_id in ({3},{4},{5})", _dept.expense_sys_account_id, dbm.ETS, SQLH.UnixStamp, _dept.expense_sys_account_id, _dept.income_sys_account_id, _dept.cr_sys_account_id)); } // xd.SingleUpdateCommandALL("dept_master_tb_ns", new string[] { "sys_account_id", "inc_sys_account_id", "cr_sys_account_id", "dept_id" }, new object[] { _dept.expense_sys_account_id, _dept.income_sys_account_id, _dept.cr_sys_account_id, _dept.dept_id }, 1); // ic.expense_accountC _exp = new ic.expense_accountC(); _exp.dept_id = _dept.dept_id; _exp.dept_parent_id = _dept.parent_id; _exp.dept_sys_account_id = _dept.expense_sys_account_id; _exp.exp_acc_name = string.Format("GE :: {0}", _dept.dept_name); _exp.exp_acc_status = em.exp_acc_statusS.valid; _exp.exp_acc_type = em.exp_acc_typeS.system_department; datam.DATA_DEPARTMENT.Add(_dept.dept_id, _dept); accn.CreateExpenseAccount(_exp, xd); if (_dept.parent_id < 0) { #region ic.accountC _inc_dept = new MTOMS.ic.accountC(); _inc_dept.account_name = string.Format("GI :: {0}", _dept.dept_name); _inc_dept.account_status = em.account_statusS.Enabled; _inc_dept.opening_balance = 0; _inc_dept.start_date = sdata.CURR_DATE; _inc_dept.owner_type = em.AccountOwnerTypeS.DEPARTMENT; _inc_dept.owner_id = _dept.dept_id; _inc_dept.owner_name = _dept.dept_name; _inc_dept.PostType = em.postTypeS.cash_accounts_payable; ic.accountC parent_account = datam.DATA_ACCOUNTS[_dept.income_sys_account_id]; _inc_dept.account_dept_type = parent_account.account_dept_type; _inc_dept.account_dept_category = parent_account.account_dept_category; _inc_dept.account_status = em.account_statusS.Enabled; _inc_dept.account_type = em.account_typeS.ActualAccount; _inc_dept.p_account_id = parent_account.account_id; _inc_dept.a_level = (parent_account.a_level + 1).ToInt16(); _inc_dept.a_index = ((datam.DATA_ACCOUNTS.Values.Count(l => l.p_account_id == parent_account.account_id & l.account_type == em.account_typeS.ActualAccount)) + 1).ToInt16(); _cols = new string[] { "acc_d_cat_id", "acc_d_type_id", "account_name", "account_type_id", "account_alias", "a_level", "a_index", "p_account_id", "exp_type", "fs_time_stamp", "edate", "pc_us_id", "account_status_id", "search_alias", "is_sys_account", "post_type_id", "owner_type_id", "owner_id", "owner_name", "start_date", "end_date", "opening_balance", "account_short_name", "account_code", "description", "lch_id", "ex_cg_type_ids", "accounts_ext_purpose" }; xd.UpdateFsTimeStamp("accounts_tb"); _row = new object[] { _inc_dept.account_dept_category.ToByte(), _inc_dept.account_dept_type.ToByte(), _inc_dept.account_name, _inc_dept.account_type.ToByte(), _inc_dept.account_alias, _inc_dept.a_level, _inc_dept.a_index, _inc_dept.p_account_id, emm.export_type.insert.ToByte(), 0, datam.CURR_DATE, datam.PC_US_ID, _inc_dept.account_status.ToByte(), null, //search_alias 0, // is_sys_account _inc_dept.PostType.ToByte(), //post_type _inc_dept.owner_type.ToByte(), //owner_type _inc_dept.owner_id, //owner_id _inc_dept.owner_name, //owner name _inc_dept.start_date, _inc_dept.end_date, //end_date _inc_dept.opening_balance, //opening balance _inc_dept.account_short_name, //account_short_name _inc_dept.account_code, _inc_dept.description, //description sdata.ChurchID, null, _inc_dept.extension_purpose.ToByte() }; _inc_dept.account_id = xd.SingleInsertCommandTSPInt("accounts_tb", _cols, _row); xd.UpdateFsTimeStamp("accounts_tb"); xd.SingleUpdateCommand(string.Format("update accounts_tb set link_id={0},{1},fs_time_stamp={2} where account_id in ({3},{4})", _dept.expense_sys_account_id, dbm.ETS, SQLH.UnixStamp, _inc_dept.account_id, _exp.sys_account_id)); if (datam.DATA_ACCOUNTS != null) { try { datam.DATA_ACCOUNTS.Add(_inc_dept.account_id, _inc_dept); } catch (Exception) { } } #endregion } switch (curr_node.Level) { case 1: { curr_node.Style = _sb_dept_style; break; } case 2: { curr_node.Style = _sb_dept_style2; break; } } curr_node.ContextMenu = contextMenuFile; xd.CommitTransaction(); } #endregion _dept = null; m_action = action_type.none; if (!is_edited) { is_edited = true; } sdata.ClearFormCache(em.fm.expense_account_settings.ToInt16()); sdata.ClearFormCache(em.fm.chart_of_accounts.ToInt16()); // sdata.ClearFormCache(em.fm.income_accounts_settings.ToInt16()); sdata.ClearFormCache(em.fm.creditors.ToInt16()); buttonclose.PerformClick(); } if (m_action == action_type.update) { if (curr_node != null && curr_node.Tag != null) { var _dept = curr_node.Tag as ic.departmentC; if (_dept != null) { using (var xd = new xing()) { if (datam.DuplicateDepartmentName(textBox1.Text.Trim().ToProperCase(), xd, _dept.dept_id)) { MessageBox.Show("The Department Name You Have Entered Already Exists", "Duplicate Department Name"); buttonclose.PerformClick(); return; } xd.SingleUpdateCommandALL("dept_master_tb_ns", new string[] { "dept_name", "dept_id" }, new object[] { textBox1.Text.Trim().ToProperCase(), _dept.dept_id }, 1); xd.SingleUpdateCommandALL("accounts_tb", new string[] { "account_name", "account_id" }, new object[] { textBox1.Text.Trim().ToProperCase(), _dept.expense_sys_account_id }, 1); xd.CommitTransaction(); } _dept.dept_name = textBox1.Text.Trim().ToProperCase(); curr_node.Text = _dept.dept_name; if (!is_edited) { is_edited = true; } sdata.ClearFormCache(em.fm.expense_account_settings.ToInt16()); sdata.ClearFormCache(em.fm.chart_of_accounts.ToInt16()); buttonclose.PerformClick(); } } } }
private void buttoncreate_Click(object sender, EventArgs e) { if (fGrid.CurCell != null) { fGrid.CommitEditCurCell(); } if (!IsValid()) { return; } string _str = "Are You Sure You Want To Perform This Operation ??"; if (!dbm.WarningMessage(_str, "Save Warning")) { return; } ic.accountC _from = (fGrid.Rows["account_from"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC; ic.accountC _to = (fGrid.Rows["account_to"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC; // using (var xd = new xing()) { string[] _cols = new string[] { "source_type_id", "source_id", "transaction_id", "destination_type_id", "destination_id", "amount", "fs_date", "fs_id", "fs_time_stamp", "lch_id" }; var _ts_id = accn.AccountsTransaction(xd, string.Format("Being Transfer Of Account Balance for {0} To {1}", _from.account_name, _to.account_name), sdata.CURR_DATE); var _amount = accn.GetFs_AccountBalance(xd, sdata.CURR_FS.fs_id, _from.account_id); var _ret_id = xd.SingleInsertCommandTSPInt("acc_cash_transfer_tb", _cols, new object[] { em.CashTransferSourceType.account, _from.account_id, _ts_id, em.CashTransferDestinationType.account, _to.account_id, _amount, sdata.CURR_DATE, sdata.CURR_FS.fs_id, 0, datam.LCH_ID }); // switch (m_group_account.account_dept_category) { case em.account_d_categoryS.Liablity: { accn.JournalBook(xd, sdata.CURR_DATE, em.j_sectionS.creditor, _ts_id, _from.account_id, _amount, 0); accn.JournalBook(xd, sdata.CURR_DATE, em.j_sectionS.creditor, _ts_id, _to.account_id, 0, _amount); // _from.account_status = em.account_statusS.DeActivated; datam.LoadCrExpOffItems(xd); var to_exp_link_obj = datam.DATA_CR_EXP_OFFITEMS.Values.Where(k => k.gen_account_id == _to.account_id & k._type == em.link_accTypes.creditor).FirstOrDefault(); var to_exp_sys_account_id = 0; ic.expense_accountC to_expense_account = null; if (to_exp_link_obj != null) { to_exp_sys_account_id = datam.DATA_CR_EXP_OFFITEMS.Values.Where(k => k.link_id == to_exp_link_obj.link_id & k._type == em.link_accTypes.expense_accrued).FirstOrDefault().gen_account_id; to_expense_account = datam.DATA_EXPENSE_ACCOUNTS.Values.Where(p => p.sys_account_id == to_exp_sys_account_id).FirstOrDefault(); } #region From var from_cr_inc_item = datam.DATA_CR_EXP_OFFITEMS.Values.Where(k => k.gen_account_id == _from.account_id & k._type == em.link_accTypes.creditor).FirstOrDefault(); if (from_cr_inc_item != null && from_cr_inc_item.cg_id == 0) { xd.SingleUpdateCommandALL("accounts_tb", new string[] { "account_status_id", "account_id" }, new object[] { em.account_statusS.DeActivated.ToInt16(), from_cr_inc_item.account_id }, 1); // xd.SingleUpdateCommandALL("accounts_tb", new string[] { "account_status_id", "account_id" }, new object[] { em.account_statusS.DeActivated.ToInt16(), _from.account_id }, 1); // var _exp_setting = datam.DATA_CR_EXP_OFFITEMS.Values.Where(k => k.link_id == from_cr_inc_item.link_id & k._type == em.link_accTypes.expense_accrued).FirstOrDefault(); if (_exp_setting != null) { ic.expense_accountC from_exp_account = (from k in datam.DATA_EXPENSE_ACCOUNTS.Values where k.sys_account_id == _exp_setting.gen_account_id select k).FirstOrDefault(); if (from_exp_account != null) { if (xd.ExecuteScalarInt(string.Format("select count(un_id) as cnt from acc_expense_trans_tb where exp_acc_id={0}", from_exp_account.exp_acc_id)) > 0) { if (to_expense_account != null) { string _upd_str = string.Format("update acc_expense_trans_tb set exp_cat_id={0},dept_id={1},dept_parent_id={2},exp_acc_id={3},sys_account_id={4},{5},fs_time_stamp={6} where exp_acc_id={7}", to_expense_account.exp_cat_id, to_expense_account.dept_id, to_expense_account.dept_parent_id, to_expense_account.exp_acc_id, to_expense_account.sys_account_id, dbm.ETS, SQLH.UnixStamp, from_exp_account.exp_acc_id); xd.SingleUpdateCommand(_upd_str); } } from_exp_account.exp_acc_status = em.exp_acc_statusS.invalid; xd.SingleUpdateCommandALL("acc_expense_accounts_tb", new string[] { "exp_acc_status", "exp_acc_id" }, new object[] { from_exp_account.exp_acc_status.ToInt16(), from_exp_account.exp_acc_id }, 1); } } } #endregion // break; } } xd.CommitTransaction(); } ClearGrid(); this.Close(); }
public static void FillExpenseAccounts(xing xd) { if (DATA_EXPENSE_ACCOUNTS == null) { DATA_EXPENSE_ACCOUNTS = new SortedList <int, ic.expense_accountC>(); } string _table_name = "acc_expense_accounts_tb"; if (wdata.TABLE_STAMP == null) { wdata.TABLE_STAMP = new SortedList <string, long>(); } if (wdata.TABLE_STAMP.IndexOfKey(_table_name) == -1) { wdata.TABLE_STAMP.Add(_table_name, 0); } bool is_new = false; bool load_all = false; string _str = string.Empty; long _stamp = xd.GetTimeStamp(_table_name); if (DATA_EXPENSE_ACCOUNTS.Keys.Count == 0) { _str = "select * from acc_expense_accounts_tb"; load_all = true; } else { if (wdata.TABLE_STAMP[_table_name] == _stamp) { return; } _str = string.Format("select * from acc_expense_accounts_tb where fs_time_stamp > {0}", wdata.TABLE_STAMP[_table_name]); load_all = false; } wdata.TABLE_STAMP[_table_name] = _stamp; ic.expense_accountC _obj = null; #region database fill using (var _dr = xd.SelectCommand(_str)) { while (_dr.Read()) { _obj = null; if (load_all) { _obj = new ic.expense_accountC(); is_new = true; } else { try { _obj = datam.DATA_EXPENSE_ACCOUNTS[_dr["exp_acc_id"].ToInt32()]; is_new = false; } catch (Exception ex) { if (_obj == null) { _obj = new ic.expense_accountC(); is_new = true; } } } if (is_new) { _obj.exp_acc_id = _dr["exp_acc_id"].ToInt32(); _obj.exp_acc_type = (em.exp_acc_typeS)_dr["exp_acc_type_id"].ToByte(); datam.DATA_EXPENSE_ACCOUNTS.Add(_obj.exp_acc_id, _obj); } // _obj.sys_account_id = _dr["sys_account_id"].ToInt32(); _obj.cr_account_id = _dr["cr_account_id"].ToInt32(); _obj.inc_cg_id = _dr["cr_cg_id"].ToInt32(); _obj.cr_un_id = _dr["cr_un_id"].ToInt32(); // _obj.inc_sys_account_id = _dr["inc_sys_account_id"].ToInt32(); _obj.cuc_account_id = _dr["cuc_account_id"].ToInt32(); _obj.exp_acc_name = _dr["exp_acc_name"].ToStringNullable(); _obj.exp_cat_id = _dr["exp_cat_id"].ToInt32(); if (datam.DATA_EXPENSE_CATEGORY.IndexOfKey(_obj.exp_cat_id) > -1) { _obj.objCategory = (_obj.exp_cat_id == 0) ? null : datam.DATA_EXPENSE_CATEGORY[_obj.exp_cat_id]; } _obj.exp_acc_status = (em.exp_acc_statusS)_dr["exp_acc_status"].ToByte(); _obj.dept_id = _dr["dept_id"].ToInt32(); _obj.dept_parent_id = _dr["dept_parent_id"].ToInt32(); _obj.dept_sys_account_id = _dr["dept_sys_account_id"].ToInt32(); _obj.objDepartment = (_obj.dept_id == 0) ? null : datam.DATA_DEPARTMENT[_obj.dept_id]; _obj.is_updated = true; } _dr.Close(); _dr.Dispose(); } #endregion }