private void deleteGroupToolStripMenuItem_Click(object sender, EventArgs e) { string _str = "Are You Sure You Want To Delete The Selected Group"; var _c = fGrid.CurRow.Tag as ic.church_groupC; if (_c != null) { using (var xd = new xing()) { if (xd.ExecuteScalarInt("select count(uno) from church_group_members_tb where cg_id=" + _c.cg_id) > 0) { MessageBox.Show("This Record Has References In Other Tables Which will Cause The System To Become Unstable", "Delete Failure"); return; } if (xd.ExecuteScalarInt(string.Format("select TOP 1 count(account_id) from accounts_tb where owner_type_id={0} and owner_id={1}", em.AccountOwnerTypeS.CHURCH_GROUP.ToByte(), _c.cg_id)) > 0) { dbm.ErrorMessage("You Cannot Delete This Church Group,It Has References In Other Tables", "Delete Failure"); return; } if (xd.ExecuteScalarInt("select count(un_id) from off_accounts_tb where cg_id=" + _c.cg_id) > 0) { MessageBox.Show("This Record Has References In Other Tables Which will Cause The System To Become Unstable", "Delete Failure"); return; } if (_c.sys_account_id > 0) { var _child_accounts = accn.GetChildAccounts(_c.sys_account_id, em.account_typeS.All).Select(d => d.account_id).ToList(); _child_accounts.Add(_c.sys_account_id); foreach (var k in _child_accounts) { xd.SingleDeleteCommandExp("accounts_tb", new string[] { "account_id" }, new int[] { k }); datam.DATA_ACCOUNTS.Remove(k); } } 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()); if (!dbm.WarningMessage(_str, "Delete Warning")) { return; } dbm.InsertUpdateDelete("delete from church_group_tb where cg_id=" + _c.cg_id); datam.DATA_CHURCH_GROUPS.Remove(_c.cg_id); fGrid.Rows.RemoveAt(fGrid.CurRow.Index); } } }
private static void Get_OffAccountsStatement(xing xd, int start_fs_id, int end_fs_id, ic.church_sub_unitC _unit, string _account_name) { string _str = string.Format("select source_name,source_type_id,source_id,fs_date,fs_id,off_id,receipt_total,transaction_id from off_main_tb where fs_id between {0} and {1} and source_type_id={2} and source_id={3} and receipt_status=1", start_fs_id, end_fs_id, em.off_source_typeS.church_sub_unit.ToInt16(), _unit.sb_unit_id); ic.account_AL_statementC _obj = null; List <ic.account_AL_statementC> _temp_list = new List <ic.account_AL_statementC>(); using (var _dr = xd.SelectCommand(_str)) { while (_dr.Read()) { _obj = new ic.account_AL_statementC(); _obj.dr_amount = 0; _obj.description = _dr["source_name"].ToStringNullable(); _obj.fs_date = _dr.GetDateTime("fs_date"); _obj.fs_id = _dr["fs_id"].ToInt32(); _obj.reference_no = string.Format("R-{0}", _dr["off_id"].ToInt32()); _obj.reference_type = em.account_AL_referenceTypeS.receipt; _obj.statement_type = em.account_statement_typeS.income_offering; _obj.transaction_id = _dr["transaction_id"].ToInt64(); _obj.account_name = _account_name; _temp_list.Add(_obj); _obj = null; } } var _cr_account_id = accn.GetCrExpLinkAccountID(em.link_accTypes.creditor, datam.DATA_ACCOUNTS[_unit.sys_gp_account_id], xd); foreach (var k in _temp_list) { k.dr_amount = xd.ExecuteScalarInt(string.Format("select sum(cr) as _sm from journal_tb where transaction_id={0} and account_id={1}", k.transaction_id, _cr_account_id)); if (k.dr_amount > 0) { accn.DATA_ASSET_LIABILITY_STATEMENT.Add(k); } } }
private void deleteClientToolStripMenuItem_Click(object sender, EventArgs e) { var _dept = curr_node.Tag as ic.departmentC; string _str = "Are You Sure You Want To The Delete The Selected Department"; using (var xd = new xing()) { datam.InitAccount(xd); if (xd.ExecuteScalarInt(string.Format("select TOP 1 count(dept_id) from dept_member_tb where dept_id={0}", _dept.dept_id)) > 0) { dbm.ErrorMessage("You Cannot Delete This Department,It Has References In Other Tables", "Delete Failure"); return; } // if (xd.ExecuteScalarInt(string.Format("select TOP 1 count(dept_id) from acc_expense_trans_tb where dept_id={0}", _dept.dept_id)) > 0) { dbm.ErrorMessage("You Cannot Delete This Department,It Has References In Other Tables", "Delete Failure"); return; } if (xd.ExecuteScalarInt(string.Format("select TOP 1 count(dept_id) from acc_expense_accounts_tb where dept_id={0}", _dept.dept_id)) > 1) { dbm.ErrorMessage("You Cannot Delete This Department,It Has References In Other Tables", "Delete Failure"); return; } List <int> _child_accounts = new List <int>(); if (_dept.parent_id > 0) { if (_dept.cr_sys_account_id > 0) { string _int_str = null; var _ac1 = accn.GetChildAccounts(_dept.cr_sys_account_id, em.account_typeS.ActualAccount); foreach (var _p in _ac1) { _child_accounts.Add(_p.account_id); if (string.IsNullOrEmpty(_int_str)) { _int_str = "(" + _p.account_id.ToStringNullable(); } else { _int_str += string.Format(",{0}", _p.account_id); } } if (!string.IsNullOrEmpty(_int_str)) { _int_str += ")"; if (xd.ExecuteScalarInt(string.Format("select count(account_id) from journal_year_tb where account_id in {0}", _int_str)) > 0) { dbm.ErrorMessage("You Cannot Delete This Department,It Has References In Other Tables", "Delete Failure"); return; } } } if (_dept.expense_sys_account_id > 0) { string _int_str = null; var _ac1 = accn.GetChildAccounts(_dept.expense_sys_account_id, em.account_typeS.ActualAccount); foreach (var _p in _ac1) { _child_accounts.Add(_p.account_id); if (string.IsNullOrEmpty(_int_str)) { _int_str = "(" + _p.account_id.ToStringNullable(); } else { _int_str += string.Format(",{0}", _p.account_id); } } if (!string.IsNullOrEmpty(_int_str)) { _int_str += ")"; if (xd.ExecuteScalarInt(string.Format("select count(account_id) from journal_year_tb where account_id in {0}", _int_str)) > 0) { dbm.ErrorMessage("You Cannot Delete This Department,It Has References In Other Tables", "Delete Failure"); return; } } } if (_dept.income_sys_account_id > 0) { string _int_str = null; var _ac1 = accn.GetChildAccounts(_dept.income_sys_account_id, em.account_typeS.ActualAccount); foreach (var _p in _ac1) { _child_accounts.Add(_p.account_id); if (string.IsNullOrEmpty(_int_str)) { _int_str = "(" + _p.account_id.ToStringNullable(); } else { _int_str += string.Format(",{0}", _p.account_id); } } if (!string.IsNullOrEmpty(_int_str)) { _int_str += ")"; if (xd.ExecuteScalarInt(string.Format("select count(account_id) from journal_year_tb where account_id in {0}", _int_str)) > 0) { dbm.ErrorMessage("You Cannot Delete This Department,It Has References In Other Tables", "Delete Failure"); return; } } } } if (!dbm.WarningMessage(_str, "Delete Warning")) { return; } // xd.SingleDeleteCommandExp("dept_master_tb_ns", new string[] { "dept_id" }, new int[] { _dept.dept_id }); // xd.SingleDeleteCommandExp("acc_expense_accounts_tb", new string[] { "dept_id" }, new int[] { _dept.dept_id }); // List <int> _keys = datam.DATA_EXPENSE_ACCOUNTS.Values.Where(d => d.dept_id == _dept.dept_id).Select(k => k.exp_acc_id).ToList(); foreach (var s in _keys) { datam.DATA_EXPENSE_ACCOUNTS.Remove(s); } // _child_accounts.Add(_dept.income_sys_account_id); _child_accounts.Add(_dept.expense_sys_account_id); _child_accounts.Add(_dept.cr_sys_account_id); foreach (var _id in _child_accounts) { xd.SingleDeleteCommandExp("accounts_tb", new string[] { "account_id" }, new int[] { _id }); datam.DATA_ACCOUNTS.Remove(_id); } _keys = datam.DATA_ACCOUNTS.Values.Where(d => (d.account_id == _dept.expense_sys_account_id | d.account_id == _dept.income_sys_account_id | d.account_id == _dept.cr_sys_account_id)).Select(k => k.account_id).ToList(); foreach (var s in _keys) { datam.DATA_ACCOUNTS.Remove(s); } xd.CommitTransaction(); } if (!is_edited) { is_edited = true; } datam.DATA_DEPARTMENT.Remove(_dept.dept_id); advTree1.SelectedNode.Remove(); 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()); }
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(); }
private void deleteClientToolStripMenuItem_Click(object sender, EventArgs e) { if (curr_node != null) { if ((advTree1.SelectedNode.Tag != null && (advTree1.SelectedNode.Tag as ic.accountC).is_sys_account)) { MessageBox.Show("Cannot Edit This Account Because It Is A System Account", "System Account Error"); return; } var _account = curr_node.Tag as ic.accountC; if (_account != null) { using (var xd = new xing()) { if (_account.account_dept_type == em.account_d_typeS.Income) { if (xd.ExecuteScalarInt(string.Format("select count(account_id) from off_accounts_tb where account_id={0}", _account.account_id)) > 0) { string _error = "You Cannot Delete This Account Since It Has References In Some Tables, Disable It Instead"; dbm.ErrorMessage(_error, "Delete Failure"); return; } if (xd.ExecuteScalarInt(string.Format("select count(account_id) from pledge_master_tb where account_id={0}", _account.account_id)) > 0) { string _error = "You Cannot Delete This Account Since It Has References In Some Tables, Disable It Instead"; dbm.ErrorMessage(_error, "Delete Failure"); return; } string _str = "Are You Sure You Want To The Delete The Selected Account"; if (!dbm.WarningMessage(_str, "Delete Warning")) { return; } xd.SingleDeleteCommandExp("accounts_tb", new string[] { "account_id" }, new int[] { _account.account_id }); if (_account.PostType == em.postTypeS.cash_accounts_payable) { xd.SingleDeleteCommandExp("accounts_payable_tb", new string[] { "account_id" }, new int[] { _account.account_id }); } if (_account.PostType == em.postTypeS.cash_accounts_payable) { datam.DATA_ACCOUNTS_PAYABLE.Remove(_account.account_id); var _node = advTree1.FindNodeByName(string.Format("PAYABLE{0}", _account.account_id)); if (_node != null) { _node.Remove(); } } //xd.SingleUpdateCommandALL("accounts_tb", new string[] //{ // "account_status", // "account_id", //}, new object[] { em.account_statusS.Deleted.ToByte(), _account.account_id }, 1); //// //xd.SingleUpdateCommandALL("accounts_tb", new string[] //{ // "account_status", // "account_id", //}, new object[] { em.account_statusS.Deleted.ToByte(), _account.account_id }, 1); } if (_account.account_dept_type == em.account_d_typeS.Expenses) { string _str = "Are You Sure You Want To The Delete The Selected Expense Account"; if (!dbm.WarningMessage(_str, "Delete Warning")) { return; } xd.SingleDeleteCommandExp("accounts_tb", new string[] { "account_id" }, new int[] { _account.account_id }); } datam.DATA_ACCOUNTS.Remove(_account.account_id); advTree1.SelectedNode.Remove(); xd.CommitTransaction(); } } } }
private void toolStripMenuItem3_Click(object sender, EventArgs e) { string _str = "Are You Sure You Want To Delete This Transfer"; if (!dbm.WarningMessage(_str, "Delete Transfer Warning")) { return; } var m_partition = string.Format("{0}{1}", m_YEAR, m_MONTH).ToInt32(); var _obj = fGrid.SelectedRows[0].Tag as ic.cash_transferC; _obj.status = em.cashTransferStatus.deleted; if (_obj != null) { using (var xd = new xing()) { long _trans_id = xd.ExecuteScalarInt64(string.Format("select transaction_id from acc_cash_transfer_tb where un_id={0} and status={1}", _obj.un_id, em.cashTransferStatus.valid.ToByte())); if (_trans_id > 0) { _str = string.Format("update acc_cash_transfer_tb set status={0},{1},fs_time_stamp={2} where un_id={3} and status={4}", em.cashTransferStatus.deleted.ToByte(), dbm.ETS, SQLH.UnixStamp, _obj.un_id, em.cashTransferStatus.valid.ToByte()); xd.UpdateFsTimeStamp("acc_cash_transfer_tb"); if (xd.SingleUpdateCommand(_str)) { _str = string.Format("select source_id, destination_id, amount from acc_cash_transfer_tb where transaction_id={0}", _trans_id); int _source_id = 0; int _destination_id = 0; int _amount = 0; using (var _dr = xd.SelectCommand(_str)) { while (_dr.Read()) { _source_id = _dr["source_id"].ToInt32(); _destination_id = _dr["destination_id"].ToInt32(); _amount = _dr["amount"].ToInt32(); } // } #region if (accn.GetAccountBaseParent(_source_id).search_alias == "WITHDRAWN_CHEQUES") { //cheque stuff; int wdr_id = xd.ExecuteScalarInt(string.Format("select wdr_id from acc_bank_withdraw_tb where sys_account_id={0}", _source_id)); if (wdr_id > 0) { xd.UpdateFsTimeStamp("acc_bank_withdraw_tb"); var _st = string.Format("update acc_bank_withdraw_tb set cheque_balance=(cheque_balance+{0}),{1},fs_time_stamp={2} where wdr_id={3}", _amount, dbm.ETS, SQLH.UnixStamp, wdr_id); xd.SingleUpdateCommand(_st); } if (accn.GetAccountBaseParent(_destination_id).search_alias == "WITHDRAWN_CHEQUES") { xd.UpdateFsTimeStamp("acc_bank_withdraw_tb"); wdr_id = xd.ExecuteScalarInt(string.Format("select wdr_id from acc_bank_withdraw_tb where sys_account_id={0}", _destination_id)); if (wdr_id > 0) { xd.UpdateFsTimeStamp("acc_bank_withdraw_tb"); var _st = string.Format("update acc_bank_withdraw_tb set cheque_balance=(cheque_balance-{0}),{1},fs_time_stamp={2} where wdr_id={3}", _amount, dbm.ETS, SQLH.UnixStamp, wdr_id); xd.SingleUpdateCommand(_st); } } } #endregion accn.DeleteJournal(_trans_id, xd); fGrid.Rows.RemoveAt(fGrid.Rows[_obj.un_id.ToString()].Index); var _delete_id = xd.IDCtrlGet("CASH_TRANSFER_DELETE_ID"); xd.SingleUpdateCommandALL("acc_cash_transfer_tb", new string[] { "delete_id", "delete_fs_date", "delete_pc_us_id", "un_id" }, new object[] { _delete_id, sdata.CURR_DATE, sdata.PC_US_ID, _obj.un_id }, 1); xd.CommitTransaction(); } } else { MessageBox.Show("This Transfer Has Already Been Deleted", "Delete Failure"); } } CheckForUpdates(); } }
private void buttonX1_Click(object sender, EventArgs e) { if (!IsValid()) { return; } string _str = "Are You Sure You Want To Save This Record ??"; ic.pledgeC _pledge = new MTOMS.ic.pledgeC(); _pledge.amount_pledged = fGrid.Rows["pl_amount"].Cells[1].Value.ToInt32(); ic.off_source_item _source = (fGrid.Rows["owner"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.off_source_item; if (_source != null) { _pledge.source_id = _source.source_id; _pledge.source_name = _source.source_name; _pledge.source_type = (em.off_source_typeS)_source.source_type_id; } if (fGrid.Rows["other_name"].Cells[1].Value != null) { _pledge.source_name = fGrid.Rows["other_name"].Cells[1].Value.ToStringNullable(); } if (fGrid.Rows["other_phone"].Cells[1].Value != null) { _pledge.source_phone = fGrid.Rows["other_phone"].Cells[1].Value.ToStringNullable(); } _pledge.fs_date = System.Convert.ToDateTime(fGrid.Rows["start_date"].Cells[1].AuxValue); _pledge.account_id = m_pledge_settings.account_id; _pledge.pls_id = m_pledge_settings.pls_id; _pledge.pledge_mode = em.pledge_modeS.normal; _pledge.pledge_status = em.pledge_statusS.pending; _pledge.fs_id = fn.GetFSID(_pledge.fs_date); using (var xd = new xing()) { var _e_pl = xd.ExecuteScalarInt(string.Format("select TOP 1 pl_id from pledge_master_tb where source_id={0} and source_type_id={1} and pls_id={2} and pl_status<>{3}", _pledge.source_id, _pledge.source_type.ToInt16(), _pledge.pls_id, em.pledge_statusS.deleted.ToInt16())); if (_e_pl > 0) { MessageBox.Show("The Selected Member Already Made A Pledge To This Account !!", "Duplicate Pledge", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!dbm.WarningMessage(_str, "Save Warning")) { return; } _pledge.pl_id = xd.SingleInsertCommandTSPInt("pledge_master_tb", new string[] { "account_id", "source_type_id", "source_id", "source_name", "source_phone", "amount_pledged", "amount_paid", "exp_type", "fs_time_stamp", "pl_status", "collect_date", "fs_date", "fs_id", "pl_mode", "lch_id", "lch_type_id", "pls_id", "cg_id" }, new object[] { _pledge.account_id, _pledge.source_type.ToByte(), _pledge.source_id, _pledge.source_name, _pledge.source_phone, _pledge.amount_pledged, _pledge.amount_paid, emm.export_type.insert.ToByte(), 0, _pledge.pledge_status.ToByte(), _pledge.collect_date, _pledge.fs_date, _pledge.fs_id, _pledge.pledge_mode.ToByte(), datam.LCH_ID, datam.LCH_TYPE_ID, _pledge.pls_id, _pledge.cg_id }); accn.PledgeSummary(xd, _pledge.amount_pledged, _pledge.amount_paid, _pledge.pls_id); // var _retlist = (from k in datam.DATA_PENDING_PLEDGES.Values where k.pls_id == _pledge.pls_id & k.source_id == _pledge.source_id & k.source_type == _pledge.source_type select k.pls_id).Count(); if (_retlist == 0) { var _pls = datam.DATA_CURRENT_PLEDGE_SETTINGS[_pledge.pls_id]; _str = string.Format("select amount,transaction_id,sab_date,off_id,pay_mode from off_accounts_tb where sab_fs_id between {0} and {1} and source_id={2} and source_type_id={3} and account_id={4} and receipt_status={5} order by sab_fs_id", _pls.start_fs_id, _pls.end_fs_id, _pledge.source_id, _pledge.source_type.ToByte(), _pledge.account_id, em.off_receipt_statusS.Valid.ToByte()); // Correction.cr.cr_off_account _off = null; List <Correction.cr.cr_off_account> _list = null; using (var _dr = xd.SelectCommand(_str)) { while (_dr.Read()) { if (_list == null) { _list = new List <Correction.cr.cr_off_account>(); } _off = new Correction.cr.cr_off_account(); _off.amount = _dr["amount"].ToInt32(); _off.trans_id = _dr["transaction_id"].ToInt64(); _off.fs_date = _dr.GetDateTime("sab_date"); _off.off_id = _dr["off_id"].ToInt32(); _off.pay_mode = (em.off_paymodeS)_dr["pay_mode"].ToByte(); _list.Add(_off); _off = null; } } if (_list != null) { #region old pledge payments int ww_amount = 0; _pledge.fs_date = _list.Min(k => k.fs_date); _pledge.fs_id = fn.GetFSID(_pledge.fs_date); xd.SingleUpdateCommandALL("pledge_master_tb", new string[] { "fs_date", "fs_id", "pl_id" }, new object[] { _pledge.fs_date, _pledge.fs_id, _pledge.pl_id }, 1); foreach (var p in _list) { ww_amount = p.amount; if (_pledge.balance <= ww_amount) { xd.SingleUpdateCommandALL("pledge_master_tb", new string[] { "amount_paid", "pl_status", "fs_id", "pl_id", }, new object[] { _pledge.amount_pledged, em.pledge_statusS.completed.ToByte(), _pledge.fs_id, _pledge.pl_id }, 2); ww_amount -= _pledge.balance; xd.SingleInsertCommandTSP("pledge_payment_mvt_tb", new string[] { "off_id", "pl_id", "account_id", "fs_date", "fs_id", "amount", "pay_mode", "status", "lch_id", "lch_type_id", "source_type_id", "source_id", "transaction_id", "pl_fs_date", "pl_fs_id", "exp_type", "fs_time_stamp", "pls_id", "cg_id" }, new object[] { p.off_id, _pledge.pl_id, _pledge.account_id, p.fs_date, fn.GetFSID(p.fs_date), _pledge.balance, p.pay_mode, 1, datam.LCH_ID, datam.LCH_TYPE_ID, _pledge.source_type.ToByte(), _pledge.source_id, p.trans_id, _pledge.fs_date, _pledge.fs_id, 33, 0, _pledge.pls_id, _pledge.cg_id }); // _pledge.amount_paid += _pledge.balance; accn.PledgeSummary(xd, 0, _pledge.balance, _pledge.pls_id); } if (_pledge.balance > ww_amount) { xd.UpdateFsTimeStamp("pledge_master_tb"); xd.InsertUpdateDelete(string.Format("update pledge_master_tb set amount_paid=(amount_paid + {0}),fs_time_stamp={1},{2} where pl_id={3}", ww_amount, SQLH.UnixStamp, dbm.ETS, _pledge.pl_id)); xd.SingleInsertCommandTSP("pledge_payment_mvt_tb", new string[] { "off_id", "pl_id", "account_id", "fs_date", "fs_id", "amount", "pay_mode", "status", "lch_id", "lch_type_id", "source_type_id", "source_id", "transaction_id", "pl_fs_date", "pl_fs_id", "exp_type", "fs_time_stamp", "pls_id", "cg_id" }, new object[] { p.off_id, _pledge.pl_id, _pledge.account_id, p.fs_date, fn.GetFSID(p.fs_date), ww_amount, p.pay_mode, 1, datam.LCH_ID, datam.LCH_TYPE_ID, _pledge.source_type.ToByte(), _pledge.source_id, p.trans_id, _pledge.fs_date, _pledge.fs_id, 33, 0, _pledge.pls_id, _pledge.cg_id }); // _pledge.amount_paid += ww_amount; accn.PledgeSummary(xd, 0, ww_amount, _pledge.pls_id); ww_amount = 0; } } #endregion } } xd.CommitTransaction(); } datam.GetPendingPledges(); if (this.Owner is Pledge.PledgesManager) { (this.Owner as Pledge.PledgesManager).CheckUpdates(); } if (this.Owner is Pledge.ViewPledgeMembers) { (this.Owner as Pledge.ViewPledgeMembers).NewRecord(_pledge); } var _drop_down_date = fGrid.Rows["start_date"].Cells[1].DropDownControl as fnn.DropDownCalenderX; if (_drop_down_date != null) { _drop_down_date.selected_date = _pledge.fs_date;// remember last date } buttonX2.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); } }
private void toolStripMenuItem3_Click(object sender, EventArgs e) { string _str = "Are You Sure You Want To Delete This Voucher"; if (!dbm.WarningMessage(_str, "Delete Voucher Warning")) { return; } var _obj = fGrid.SelectedRows[0].Tag as ic.expense_transC; var m_partition = string.Format("{0}{1}", _obj.exp_date.Value.Year, _obj.exp_date.Value.Month).ToInt32(); datam.GetMonthExpenses(m_partition); var nlist = from k in datam.DATA_MONTH_EXPENSES[m_partition].Values where k.voucher_id == _obj.voucher_id & k.voucher_status == em.voucher_statusS.valid select k; if (_obj != null) { using (var xd = new xing()) { long _trans_id = xd.ExecuteScalarInt64(string.Format("select transaction_id from acc_expense_trans_tb where un_id={0} and voucher_status={1}", _obj.un_id, em.voucher_statusS.valid.ToByte())); if (_trans_id > 0) { _str = string.Format("update acc_expense_vouchers_tb set status={0},{1},fs_time_stamp={2} where voucher_id={3} and status={4}", em.voucher_statusS.cancelled.ToByte(), dbm.ETS, SQLH.UnixStamp, _obj.voucher_id, em.voucher_statusS.valid.ToByte()); xd.UpdateFsTimeStamp("acc_expense_vouchers_tb"); if (xd.SingleUpdateCommand(_str)) { _str = string.Format("select * from journal_tb where transaction_id in ({0})", string.Format("select transaction_id from acc_expense_trans_tb where un_id={0} and voucher_status={1}", _obj.un_id, em.voucher_statusS.valid.ToByte())); accn.DeleteJournal(_str, xd); // foreach (var _expense in nlist) { _expense.voucher_status = em.voucher_statusS.cancelled; xd.SingleUpdateCommandALL("acc_expense_trans_tb", new string[] { "voucher_status", "un_id" }, new object[] { em.voucher_statusS.cancelled.ToByte(), _expense.un_id }, 1); // xd.SingleUpdateCommandALL("acc_expense_trans_child_tb", new string[] { "voucher_status", "trans_id" }, new object[] { em.voucher_statusS.cancelled.ToByte(), _expense.un_id }, 1); if (datam.DATA_EXPENSE_ACCOUNTS[_expense.exp_acc_id].exp_acc_type == em.exp_acc_typeS.system_offertory_payment | datam.DATA_EXPENSE_ACCOUNTS[_expense.exp_acc_id].exp_acc_type == em.exp_acc_typeS.trust_fund) { accn.DeleteExpenseAccountsPayable(xd, _trans_id); } if (!string.IsNullOrEmpty(_expense.w_dr_data)) { var _cheques = _expense.w_dr_data.Split(new char[] { ',' }); xd.UpdateFsTimeStamp("acc_bank_withdraw_tb"); string _st = null; foreach (var t in _cheques) { var _val = t.Split(new char[] { ':' }); if (xd.ExecuteScalarInt(string.Format("select transfer_id from acc_bank_withdraw_tb where wdr_id={0}", _val[0].ToInt32())) > 0) { MessageBox.Show("You Have Already Closed This Cheque, This Operation Cannot Be Carried Out", "Closed Cheque Error", MessageBoxButtons.OK, MessageBoxIcon.Error); xd.RollBackTransaction(); return; } _st = string.Format("update acc_bank_withdraw_tb set cheque_balance=(cheque_balance+{0}),{1},fs_time_stamp={2} where wdr_id={3}", _val[1], dbm.ETS, SQLH.UnixStamp, _val[0]); xd.InsertUpdateDelete(_st); } } // fnn.ExecuteDeleteBase(xd, new ic.deleteBaseC() { del_fs_date = sdata.CURR_DATE, del_fs_id = sdata.CURR_FS.fs_id, del_fs_time = DateTime.Now.ToShortTimeString(), del_pc_us_id = sdata.PC_US_ID }, "acc_expense_trans_tb", "un_id", _expense.un_id); // if (!string.IsNullOrEmpty(_expense.cheque_no)) { ic.bankAccountC _bank = datam.DATA_BANK_ACCOUNTS.Values.Where(y => y.sys_account_id == _expense.source_account_id).FirstOrDefault(); xd.SingleUpdateCommandALL("acc_usedbank_cheques_tb", new string[] { "status", "bank_account_id", "cheque_no" }, new object[] { 1, _bank.un_id, _expense.cheque_no }, 2); } fGrid.Rows.RemoveAt(fGrid.Rows[_expense.un_id.ToString()].Index); } xd.CommitTransaction(); } } else { MessageBox.Show("This Expense Record Has Already Been Deleted", "Delete Failure"); } } CheckForUpdates(); } }
private void buttonsave_Click(object sender, EventArgs e) { #region get type ic.church_group_typeC _type = comboBoxEx1.SelectedItem as ic.church_group_typeC; //em.church_group_typeS _type = em.church_group_typeS.Family; //switch (comboBoxEx1.SelectedIndex) //{ // case 0: // { // _type = em.church_group_typeS.Family; break; // } // case 1: // { // _type = em.church_group_typeS.City; break; // } // case 2: // { // _type = em.church_group_typeS.LessonClass; break; // } // case 3: // { // _type = em.church_group_typeS.BuildingClass; break; // } // case 4: // { // _type = em.church_group_typeS.FellowShipGroup; break; // } // case 5: // { // _type = em.church_group_typeS.PrayerGroup; break; // } // case 6: // { // _type = em.church_group_typeS.CookingClass; break; // } //} #endregion string _str = textBoxSender.Text.Trim(); if (datam.DATA_CHURCH_GROUPS != null) { var cnt = (from v in datam.DATA_CHURCH_GROUPS.Values where v.cg_type_id == _type.cg_type_id & v.cg_name.ToLower() == _str.ToLower() select v).Count(); if (cnt > 0) { _str = "A Group Name With The Same Name Already Exists"; dbm.ErrorMessage(_str, "Duplicate Group Name"); return; } } ic.church_groupC _c = new MTOMS.ic.church_groupC(); _c.cg_type_id = _type.cg_type_id; _c.cg_name = _str.ToProperCase(); string[] _cols = new string[] { "cg_name", "cg_type_id", "exp_type", "lch_id", "lch_type_id", "fs_time_stamp" }; object[] _row = new object[] { _c.cg_name, _c.cg_type_id, 33, datam.LCH_ID, datam.LCH_TYPE_ID, 0 }; using (var xd = new xing()) { if (xd.ExecuteScalarInt(string.Format("select count(cg_type_id) as cnt from church_group_tb where cg_type_id={0}", _c.cg_type_id)) == 0) { _type.sys_account_id = accn.CreateChildGroupAccount(xd, -2368, _type.cg_type_name).account_id; xd.SingleUpdateCommandALL("church_group_types_tb", new string[] { "sys_account_id", "cg_type_id" }, new object[] { _type.sys_account_id, _type.cg_type_id }, 1); } if (_type.sys_account_id == 0) { _type.sys_account_id = xd.ExecuteScalarInt("select sys_account_id from church_group_types_tb where cg_type_id=" + _type.cg_type_id); } _c.cg_id = xd.SingleInsertCommandInt("church_group_tb", _cols, _row); _c.sys_account_id = accn.CreateChildGroupAccount(xd, _type.sys_account_id, _c.cg_name).account_id; xd.SingleUpdateCommandALL("church_group_tb", new string[] { "sys_account_id", "cg_id" }, new object[] { _c.sys_account_id, _c.cg_id }, 1); //create general expense account for this xd.CommitTransaction(); } if (datam.DATA_CHURCH_GROUPS == null) { datam.DATA_CHURCH_GROUPS = new SortedList <int, MTOMS.ic.church_groupC>(); } datam.DATA_CHURCH_GROUPS.Add(_c.cg_id, _c); if (this.Owner is ChurchGroupManager2) { (this.Owner as ChurchGroupManager2).NewGroup(_c); } sdata.ClearFormCache(em.fm.chart_of_accounts.ToInt16()); sdata.ClearFormCache(em.fm.income_accounts_settings.ToInt16()); sdata.ClearFormCache(em.fm.creditors.ToInt16()); is_edited = true; textBoxSender.Clear(); textBoxSender.Focus(); }
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 _category = _grid.Rows[e.RowIndex].Tag as ic.expense_catC; using (var xd = new xing()) { if (xd.ExecuteScalarInt("select TOP 1 exp_acc_id from acc_expense_accounts_tb where exp_cat_id=" + _category.exp_cat_id) == 0) { xd.SingleDeleteCommandExp("acc_expense_cat_tb", new string[] { "exp_cat_id" }, new int[] { _category.exp_cat_id }); xd.CommitTransaction(); } else { _grid.Rows[e.RowIndex].Cells[0].Value = _category.exp_cat_name; dbm.ErrorMessage("There Are Some Expense Accounts Which Are Attached To This Category", "Delete Operation Will Be Cancelled"); return; } } var _dp_item = (from r in (fGrid.Rows["item_cat"].Cells["desc"].DropDownControl as iGDropDownList).Items.Cast <fnn.iGComboItemEX>() where r.Tag == _category select r).FirstOrDefault(); if (_dp_item != null) { (fGrid.Rows["item_cat"].Cells["desc"].DropDownControl as iGDropDownList).Items.Remove(_dp_item); fGrid.Rows["item_cat"].Cells["desc"].AuxValue = null; fGrid.Rows["item_cat"].Cells["desc"].Value = null; } _grid.Rows[e.RowIndex].Tag = null; datam.DATA_EXPENSE_CATEGORY.Remove(_category.exp_cat_id); _grid.Rows.RemoveAt(e.RowIndex); } return; } else { if (_grid.Rows[e.RowIndex].Tag == null) { //insert if (datam.DATA_EXPENSE_CATEGORY.Values.FirstOrDefault(k => k.exp_cat_name.ToLower() == _grid.Rows[e.RowIndex].Cells[0].Text.ToLower()) != null) { dbm.ErrorMessage("Duplicate Entry Found", "Duplicate Error"); _grid.Rows[e.RowIndex].Cells[0].Value = null; return; } var _category = new ic.expense_catC(); using (var xd = new xing()) { _category.exp_cat_name = _grid.Rows[e.RowIndex].Cells[0].Text.ToProperCase(); _category.exp_cat_id = xd.SingleInsertCommandTSPInt("acc_expense_cat_tb", new string[] { "exp_cat_name", "exp_type", "fs_time_stamp", "lch_id" }, new object[] { _category.exp_cat_name, emm.export_type.insert.ToByte(), 0, datam.LCH_ID }); xd.CommitTransaction(); } _grid.Rows[e.RowIndex].Tag = _category; datam.DATA_EXPENSE_CATEGORY.Add(_category.exp_cat_id, _category); (fGrid.Rows["item_cat"].Cells["desc"].DropDownControl as iGDropDownList).Items.Add(new fnn.iGComboItemEX { Tag = _category, Text = _category.exp_cat_name, Value = _category.exp_cat_name }); } else { var _category = _grid.Rows[e.RowIndex].Tag as ic.expense_catC; _category.exp_cat_name = _grid.Rows[e.RowIndex].Cells[0].Value.ToStringNullable(); using (var xd = new xing()) { xd.SingleUpdateCommandALL("acc_expense_cat_tb", new string[] { "exp_cat_name", "exp_cat_id" }, new object[] { _category.exp_cat_name, _category.exp_cat_id }, 1); xd.CommitTransaction(); } //update } } #endregion } if (((e.RowIndex + 1) == _grid.Rows.Count)) { AddRowX(_grid); } }
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", "transfer_reason", "edate", "pc_us_id", "m_partition_id" }; var _ts_id = accn.AccountsTransaction(xd, string.Format("Being Transfer Of Account Balance from {0} To {1}", _from.account_name, _to.account_name), sdata.CURR_DATE); var _amount = fGrid.Rows["transfer_amount"].Cells[1].Value.ToInt32(); 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, m_SelectedDate, fn.GetFSID(m_SelectedDate.Value), 0, datam.LCH_ID, fGrid.Rows["reason"].Cells[1].Text, sdata.CURR_DATE, sdata.PC_US_ID, string.Format("{0}{1}", m_SelectedDate.Value.Year, m_SelectedDate.Value.Month).ToInt32() }); em.j_sectionS?source_j_section = null; em.j_sectionS?dest_j_section = null; int source_dr = 0; int source_cr = 0; int dest_dr = 0; int dest_cr = 0; switch (_from.account_dept_category) { case em.account_d_categoryS.Liablity: { source_j_section = em.j_sectionS.creditor; source_dr = _amount; break; } case em.account_d_categoryS.Asset: { source_j_section = em.j_sectionS.asset; source_cr = _amount; break; } default: { MessageBox.Show("You Have Performed An Invalid Operation", "Invalid Operation"); return; } } switch (_to.account_dept_category) { case em.account_d_categoryS.Asset: { dest_j_section = em.j_sectionS.asset; dest_dr = _amount; break; } case em.account_d_categoryS.Liablity: { dest_j_section = em.j_sectionS.creditor; dest_cr = _amount; break; } case em.account_d_categoryS.PL: { dest_j_section = em.j_sectionS.income; dest_cr = _amount; break; } } /// accn.JournalBook(xd, m_SelectedDate.Value, source_j_section.Value, _ts_id, _from.account_id, source_dr, source_cr); accn.JournalBook(xd, m_SelectedDate.Value, dest_j_section.Value, _ts_id, _to.account_id, dest_dr, dest_cr); // if (accn.GetAccountBaseParent(_from.account_id).search_alias == "WITHDRAWN_CHEQUES") { //cheque stuff; int wdr_id = xd.ExecuteScalarInt(string.Format("select wdr_id from acc_bank_withdraw_tb where sys_account_id={0}", _from.account_id)); if (wdr_id > 0) { xd.UpdateFsTimeStamp("acc_bank_withdraw_tb"); var _st = string.Format("update acc_bank_withdraw_tb set cheque_balance=(cheque_balance-{0}),{1},fs_time_stamp={2} where wdr_id={3}", _amount, dbm.ETS, SQLH.UnixStamp, wdr_id); xd.SingleUpdateCommand(_st); } if (accn.GetAccountBaseParent(_to.account_id).search_alias == "WITHDRAWN_CHEQUES") { xd.UpdateFsTimeStamp("acc_bank_withdraw_tb"); wdr_id = xd.ExecuteScalarInt(string.Format("select wdr_id from acc_bank_withdraw_tb where sys_account_id={0}", _to.account_id)); if (wdr_id > 0) { xd.UpdateFsTimeStamp("acc_bank_withdraw_tb"); var _st = string.Format("update acc_bank_withdraw_tb set cheque_balance=(cheque_balance+{0}),{1},fs_time_stamp={2} where wdr_id={3}", _amount, dbm.ETS, SQLH.UnixStamp, wdr_id); xd.SingleUpdateCommand(_st); } } } xd.CommitTransaction(); } ClearGrid(); this.Tag = 1; this.Close(); }