private void advTree1_AfterNodeSelect(object sender, DevComponents.AdvTree.AdvTreeNodeEventArgs e)
 {
     curr_node = e.Node;
     if (curr_node == null)
     {
         return;
     }
     labelclient.Text = curr_node == null ? string.Empty : curr_node.Text;
     if (curr_node.Level == 0)
     {
         label3.Text = string.Empty;
         m_account   = null;
         clear_grid_data();
         fGrid.Enabled = false;
         return;
     }
     if (curr_node.Tag != null)
     {
         if (!fGrid.Enabled)
         {
             fGrid.Enabled = true;
         }
         m_account = curr_node.Tag as ic.accountC;
         LoadAccountDetail(m_account);
         label3.Text = curr_node.Text;
     }
 }
        private void Recursive(DevComponents.AdvTree.Node _nd)
        {
            ic.accountC _acc = _nd.Tag as ic.accountC;
            iGRow       _row = null;

            foreach (var t in _nd.Nodes.Cast <DevComponents.AdvTree.Node>())
            {
                _row          = fGrid.Rows.Add();
                _row.Level    = t.Level - 1;
                _row.Font     = new Font("georgia", 12, FontStyle.Regular);
                _row.ReadOnly = iGBool.True;
                _row.Cells["Account Name"].Value  = t.Text;
                _row.Cells["Alias"].Value         = null;
                _row.Cells["section_index"].Value = _acc.account_dept_type.ToByte();
                _row.Cells["section_name"].Value  = _acc.account_dept_type.ToStringNullable();
                _row.Key = _acc.account_id.ToStringNullable();
                _row.AutoHeight();
                if (t.Nodes.Count == 0)
                {
                    continue;
                }
                _row.TreeButton = iGTreeButtonState.Visible;
                Recursive(t);
            }
        }
        private void contextMenuFile_Opening(object sender, CancelEventArgs e)
        {
            if (advTree1.SelectedNode == null || advTree1.SelectedNode.Tag == null)
            {
                e.Cancel = true; return;
            }
            ic.accountC _acc = advTree1.SelectedNode.Tag as ic.accountC;
            if (_acc != null)
            {
                e.Cancel = true;

                //if (_acc.is_sys_account)
                //{
                //    e.Cancel = true;
                //}
                if (_acc.is_sys_account & LCB_ACCOUNT.IndexOf(_acc.account_id) > -1)
                {
                    e.Cancel = false;
                }
                disableAccountToolStripMenuItem.Text = m_account.account_status == em.account_statusS.Enabled ? "Disable Account" : "Enable Account";
                if (LCB_ACCOUNT.IndexOf(_acc.account_id) > -1)
                {
                    linkToChurchGroupSharedToolStripMenuItem.Visible = true;
                }
                else
                {
                    linkToChurchGroupSharedToolStripMenuItem.Visible = false;
                }
            }
        }
 private void LoadAccountDetail(ic.accountC _acc)
 {
     clear_grid_data();
     if (_acc == null)
     {
         return;
     }
     fGrid.Rows["alias"].Cells["desc"].Value          = _acc.search_alias; fGrid.Rows["alias"].AutoHeight();
     fGrid.Rows["account_id"].Cells["desc"].Value     = _acc.account_id.ToStringNullable(); fGrid.Rows["account_id"].AutoHeight();
     fGrid.Rows["account_status"].Cells["desc"].Value = _acc.account_status == em.account_statusS.Enabled ? "Enabled" : "Disabled";
     fGrid.Rows["is_sys_account"].Cells["desc"].Value = _acc.is_sys_account ? "Yes" : "No";
 }
Ejemplo n.º 5
0
        private void MergeAccountsMaker_Load(object sender, EventArgs e)
        {
            CenterToScreen();
            m_group_account = this.Tag as ic.accountC;
            if (m_group_account == null)
            {
                return;

                this.Close();
            }
            backworker.RunWorkerAsync();
        }
        public void NewIncomeAccount(ic.accountC _inc)
        {
            if (_inc == null)
            {
                return;
            }
            var Parent_node = advTree1.FindNodeByName(string.Format("Account{0}", _inc.p_account_id));

            if (Parent_node != null)
            {
                DevComponents.AdvTree.Node _nd = new DevComponents.AdvTree.Node();
                _nd.ContextMenu = contextMenuFile;
                _nd.Text        = _inc.account_name;
                _nd.Tag         = _inc;
                _nd.Name        = string.Format("Account{0}", _inc.account_id);
                if (_inc.account_status == em.account_statusS.Disabled)
                {
                    _nd.Style = _disabled;
                }
                if (_inc.account_status == em.account_statusS.Enabled)
                {
                    _nd.Style = _file_style;
                }
                Parent_node.Nodes.Add(_nd); _nd = null;
                Parent_node.Expand();
            }
            if (_inc.PostType == em.postTypeS.cash_accounts_payable)
            {
                #region fill other_income_payable
                datam.GetAccountsPayable(null);
                var _gp = datam.GetAccountByAlias("OIPAYABLE");
                if (_gp != null)
                {
                    var parent_node = advTree1.FindNodeByName(string.Format("Account{0}", _gp.account_id));
                    DevComponents.DotNetBar.ElementStyle _tt = new DevComponents.DotNetBar.ElementStyle();
                    _tt.TextColor = Color.DeepPink;
                    _tt.Font      = new Font("verdana", 12, FontStyle.Regular);
                    DevComponents.AdvTree.Node _nd = new DevComponents.AdvTree.Node();
                    _nd.Text  = _inc.account_name;
                    _nd.Style = _tt;
                    _nd.Name  = string.Format("PAYABLE{0}", _inc.account_id);
                    parent_node.Nodes.Add(_nd);
                }
                #endregion
            }
        }
Ejemplo n.º 7
0
        private void LoadMainGrid(IEnumerable <ic.cash_transferC> _list)
        {
            fGrid.BeginUpdate();
            fGrid.Rows.Clear();
            if (_list == null)
            {
                fGrid.EndUpdate(); return;
            }
            iGRow _row = null;

            ic.accountC _acc = null;
            foreach (var n in _list)
            {
                _row                             = fGrid.Rows.Add();
                _row.ReadOnly                    = iGBool.True;
                _row.Font                        = new Font("georgia", 12, FontStyle.Regular);
                _row.Cells["date"].Value         = n.fs_date.Value.ToMyShortDate();
                _acc                             = datam.DATA_ACCOUNTS[n.source_id];
                _row.Cells["from_account"].Value = _acc.account_name;
                //
                _acc = datam.DATA_ACCOUNTS[n.destination_id];
                _row.Cells["to_account"].Value = _acc.account_name;
                if (_acc.account_id == -2355)
                {
                    _row.Cells["to_account"].Value = "LCB";
                }
                //
                _row.Cells["amount"].Value     = n.amount;
                _row.Cells["amount"].TextAlign = iGContentAlignment.MiddleCenter;
                _row.Cells["amount"].ForeColor = Color.DarkBlue;
                //
                _row.Cells["details"].Value = n.transfer_reason;
                //

                _row.Key = n.un_id.ToStringNullable();
                _row.Tag = n;
                _row.AutoHeight();

                n.is_updated = false;
            }

            fGrid.EndUpdate();
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
        }
 private void contextMenuFolder_Opening(object sender, CancelEventArgs e)
 {
     if (advTree1.SelectedNode == null || advTree1.SelectedNode.Tag == null)
     {
         e.Cancel = true; return;
     }
     ic.accountC _acc = advTree1.SelectedNode.Tag as ic.accountC;
     if (_acc != null)
     {
         if (_acc.account_dept_type != em.account_d_typeS.Expenses)
         {
             e.Cancel = true;
         }
     }
     if (curr_node != null)
     {
         toolStripMenuItem1.Visible = curr_node.Level == 2 ? false : true;
     }
     deleteToolStripMenuItem.Visible = curr_node.Nodes.Count == 0 ? true : false;
 }
        private void checkBox1_CheckedChanged_1(object sender, EventArgs e)
        {
            checkBox1.Text = checkBox1.Checked ? "UnCheck To Show Sub Departments" : "Hide Sub Departments";

            foreach (var _grid in new iGrid[] { fGrid, fGridnormal })
            {
                _grid.BeginUpdate();
                ic.accountC _acc      = null;
                iGRow       _row      = null;
                var         _row_list = from _r in _grid.Rows.Cast <iGRow>()
                                        where _r.Level == 0 & _r.Cells["has_children"].Value != null
                                        select _r;
                foreach (var k in _row_list)
                {
                    try
                    {
                        _row            = k;
                        _row.Expanded   = false;
                        _row.TreeButton = checkBox1.Checked ? iGTreeButtonState.Absent : iGTreeButtonState.Visible;
                    }
                    catch (Exception ex)
                    {
                        continue;
                    }
                    //
                    if ((_row.Index + 1) >= _grid.Rows.Count - 1)
                    {
                        break;
                    }
                    for (int j = (_row.Index + 1); j < _grid.Rows.Count; j++)
                    {
                        if (_grid.Rows[j].Level == _row.Level)
                        {
                            break;
                        }
                        _grid.Rows[j].Visible = checkBox1.Checked ? false : true;
                    }
                }
                _grid.EndUpdate();
            }
        }
Ejemplo n.º 10
0
        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 Create This Account ??";

            if (!dbm.WarningMessage(_str, "Save Warning"))
            {
                return;
            }
            ic.bank_reconc_accountC _acc = new ic.bank_reconc_accountC();
            _acc.br_acc_name = fGrid.Rows["account_name"].Cells[1].Text.ToProperCase();
            _acc.br_acc_type = (em.bank_reconc_typeS)(fGrid.Rows["account_type"].Cells[1].AuxValue as fnn.iGComboItemEX).ID;
            ic.accountC _sys_account = null;
            using (var xd = new xing())
            {
                switch (_acc.br_acc_type)
                {
                case em.bank_reconc_typeS.deduction:
                {
                    _sys_account = accn.CreateChildAccount(xd, accn.GetAccountByAlias("BANK_RECONCILIATION_EXPENSE").account_id, _acc.br_acc_name);
                    break;
                }

                case em.bank_reconc_typeS.addition:
                {
                    _sys_account = accn.CreateChildAccount(xd, accn.GetAccountByAlias("BANK_RECONCILATION_INCOME").account_id, _acc.br_acc_name);
                    break;
                }
                }
                _acc.sys_account_id = _sys_account.account_id;
                //
                _acc.br_acc_id = xd.SingleInsertCommandTSPInt("acc_bank_reconc_accounts_tb", new string[]
                {
                    "br_acc_name",
                    "br_acc_type_id",
                    "sys_account_id",
                    "lch_id",
                    "fs_time_stamp",
                }, new object[]
                {
                    _acc.br_acc_name,
                    _acc.br_acc_type.ToInt16(),
                    _acc.sys_account_id,
                    sdata.ChurchID,
                    0,
                }

                                                              );
                if (datam.DATA_BANK_RECONCILIATION_ACCOUNTS == null)
                {
                    datam.DATA_BANK_RECONCILIATION_ACCOUNTS = new SortedList <int, ic.bank_reconc_accountC>();
                }
                datam.DATA_BANK_RECONCILIATION_ACCOUNTS.Add(_acc.br_acc_id, _acc);
                xd.CommitTransaction();
            }
            this.Tag = 1;
            sdata.ClearFormCache(em.fm.chart_of_accounts.ToInt16());
            ClearGrid();
        }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (!IsValid())
            {
                return;
            }
            string _str = "Are You Sure You Want To Save This Record ??";

            if (!dbm.WarningMessage(_str, "Save Warning"))
            {
                return;
            }
            ic.pledgeSettingC _pledge = new ic.pledgeSettingC();
            _pledge.pledge_name = fGrid.Rows["pledge_name"].Cells[1].Text.Trim();
            _pledge.pledge_name.ToProperCase();
            _pledge.start_date  = System.Convert.ToDateTime(fGrid.Rows["start_date"].Cells[1].AuxValue);
            _pledge.start_fs_id = fn.GetFSID(_pledge.start_date.Value);
            _pledge.status      = em.pledge_setting_statusS.valid;
            if (fGrid.Rows["end_date"].Cells[1].AuxValue != null)
            {
                _pledge.end_date  = System.Convert.ToDateTime(fGrid.Rows["end_date"].Cells[1].AuxValue);
                _pledge.end_fs_id = fn.GetFSID(_pledge.end_date.Value);
            }
            ic.accountC account = (fGrid.Rows["account"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC;
            if (account != null)
            {
                _pledge.account_id = account.account_id;
            }
            using (var xd = new xing())
            {
                _pledge.pls_id = xd.SingleInsertCommandTSPInt("pledge_settings_tb", new string[]
                {
                    "account_id",
                    "start_date",
                    "start_fs_id",
                    "end_date",
                    "end_fs_id",
                    "fs_date",
                    "pc_us_id",
                    "exp_type",
                    "fs_time_stamp",
                    "lch_id",
                    "start_year", "pledge_name"
                }, new object[]
                {
                    _pledge.account_id,
                    _pledge.start_date,
                    _pledge.start_fs_id,
                    _pledge.end_date,
                    _pledge.end_fs_id,
                    sdata.CURR_DATE,
                    sdata.PC_US_ID,
                    emm.export_type.insert.ToByte(),
                    0,
                    datam.LCH_ID,
                    _pledge.start_date.Value.Year,
                    _pledge.pledge_name
                });
                xd.CommitTransaction();
            }
            if (this.Owner is Pledge.PledgesManagerB)
            {
                (this.Owner as Pledge.PledgesManagerB).NewRecord(_pledge);
            }
            buttonX2.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", "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();
        }
        private void FillAccountsByDate(DateTime?start_date)
        {
            m_SourceAccounts.Items.Clear();
            m_DestinationAccounts.Items.Clear();
            using (var xd = new xing())
            {
                foreach (var _alias in new string[]
                {
                    "LC_OFFERTORY_PAYABLE",
                    "DISTRICT_PAYABLE",
                    "CHURCH_SUBUNITS_PAYABLE",
                    "WITHDRAWN_CHEQUES"
                })
                {
                    var clist = accn.GetChildAccounts(accn.GetAccountByAlias(_alias).account_id, em.account_typeS.ActualAccount);
                    m_ChequeList.Clear();
                    foreach (var k in clist)
                    {
                        switch (_alias)
                        {
                        case "LC_OFFERTORY_PAYABLE":
                        case "DISTRICT_PAYABLE":
                        case "CHURCH_SUBUNITS_PAYABLE":
                        {
                            if (accn.GetFs_AccountBalance(xd, fn.GetFSID(start_date.Value), k.account_id) > 0)
                            {
                                m_SourceAccounts.Items.Add(new fnn.iGComboItemEX()
                                    {
                                        Value = k.account_name,
                                        Tag   = k
                                    });
                            }
                            m_DestinationAccounts.Items.Add(new fnn.iGComboItemEX()
                                {
                                    Value = k.account_name,
                                    Tag   = k
                                });
                            break;
                        }

                        case "WITHDRAWN_CHEQUES":
                        {
                            if (accn.GetFs_AccountBalance(xd, fn.GetFSID(sdata.CURR_DATE), k.account_id) > 0)
                            {
                                m_SourceAccounts.Items.Add(new fnn.iGComboItemEX()
                                    {
                                        Value = k.account_name,
                                        Tag   = k
                                    });
                            }
                            m_DestinationAccounts.Items.Add(new fnn.iGComboItemEX()
                                {
                                    Value = k.account_name,
                                    Tag   = k
                                });
                            m_ChequeList.Add(k.account_name);
                            break;
                        }
                        }
                    }
                }
                ic.accountC _lcb = accn.GetAccountByAlias("LCB_CREDITOR_REDUCTION_INCOME");
                m_DestinationAccounts.Items.Add(new fnn.iGComboItemEX()
                {
                    Value = "LCB",
                    Tag   = _lcb
                });
                xd.CommitTransaction();
            }
        }
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            if (fGrid.Rows[e.RowIndex].Cells["desc"].DropDownControl != null && fGrid.Rows[e.RowIndex].Cells["desc"].AuxValue == null)
            {
                fGrid.Rows[e.RowIndex].Cells["desc"].Value = null;
                for (int y = (e.RowIndex + 1); y < fGrid.Rows.Count; y++)
                {
                    fGrid.Rows[y].Cells["desc"].Value    = null;
                    fGrid.Rows[y].Cells["desc"].AuxValue = null;
                    if (fGrid.Rows[y].Cells["desc"].Selectable == iGBool.True)
                    {
                        fGrid.Rows[y].Cells["desc"].Enabled = iGBool.False;
                    }
                }
                if (fGrid.Rows[e.RowIndex].Key == "account_from")
                {
                    FilterDestinationAccounts(null);
                }
                return;
            }
            switch (fGrid.Rows[e.RowIndex].Key)
            {
            case "transfer_date":
            {
                m_SelectedDate = System.Convert.ToDateTime(fGrid.Rows["transfer_date"].Cells[1].AuxValue);
                for (int y = (e.RowIndex + 1); y < fGrid.Rows.Count; y++)
                {
                    fGrid.Rows[y].Cells["desc"].Value    = null;
                    fGrid.Rows[y].Cells["desc"].AuxValue = null;
                    if (fGrid.Rows[y].Cells["desc"].Selectable == iGBool.True)
                    {
                        fGrid.Rows[y].Cells["desc"].Enabled = iGBool.False;
                    }
                }
                FillAccountsByDate(m_SelectedDate);
                fGrid.Rows["account_from"].Cells[1].Enabled = iGBool.True;
                //
                break;
            }

            case "account_from":
            {
                ic.accountC _from = (fGrid.Rows["account_from"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC;

                for (int y = (e.RowIndex + 1); y < fGrid.Rows.Count; y++)
                {
                    fGrid.Rows[y].Cells["desc"].Value    = null;
                    fGrid.Rows[y].Cells["desc"].AuxValue = null;
                    if (fGrid.Rows[y].Cells["desc"].Selectable == iGBool.True)
                    {
                        fGrid.Rows[y].Cells["desc"].Enabled = iGBool.False;
                    }
                }
                using (var xd = new xing())
                {
                    fGrid.Rows["account_balance"].Cells[1].Value = accn.GetFs_AccountBalance(xd, fn.GetFSID(m_SelectedDate.Value), _from.account_id);
                }
                fGrid.Rows["account_to"].Cells[1].Enabled = iGBool.True;
                FilterDestinationAccounts(_from);
                break;
            }

            case "account_to":
            {
                for (int y = (e.RowIndex + 1); y < fGrid.Rows.Count; y++)
                {
                    fGrid.Rows[y].Cells["desc"].Value    = null;
                    fGrid.Rows[y].Cells["desc"].AuxValue = null;
                    if (fGrid.Rows[y].Cells["desc"].Selectable == iGBool.True)
                    {
                        fGrid.Rows[y].Cells["desc"].Enabled = iGBool.False;
                    }
                }
                fGrid.Rows["transfer_amount"].Cells[1].Enabled = iGBool.True;
                fGrid.Rows["reason"].Cells[1].Enabled          = iGBool.True;
                break;
            }

            case "transfer_amount":
            {
                if ((fGrid.Rows[e.RowIndex].Cells[1].Value.ToInt32() <= 0) | fGrid.Rows[e.RowIndex].Cells[1].Value.ToInt32() > fGrid.Rows["account_balance"].Cells[1].Value.ToInt32())
                {
                    MessageBox.Show("You Have Entered An Invalid Amount", "Invalid Amount", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    fGrid.Focus();
                    fGrid.Rows[e.RowIndex].Cells[1].Value = null;
                    fGrid.SetCurCell(e.RowIndex, 1);
                    return;
                }
                break;
            }
            }

            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].ReadOnly == iGBool.True)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
        private void FilterDestinationAccounts(ic.accountC _source)
        {
            if (m_DestinationAccounts == null || m_DestinationAccounts.Items.Count == 0)
            {
                return;
            }
            if (_source == null)
            {
                foreach (var k in m_DestinationAccounts.Items.Cast <fnn.iGComboItemEX>())
                {
                    k.Visible = true;
                }
                return;
            }
            else
            {
                ic.accountC _base_parent = accn.GetAccountBaseParent(_source.account_id);
                if (_base_parent != null)
                {
                    switch (_base_parent.search_alias)
                    {
                    case "WITHDRAWN_CHEQUES":
                    {
                        foreach (var k in m_DestinationAccounts.Items.Cast <fnn.iGComboItemEX>())
                        {
                            if (m_ChequeList.IndexOf(k.Value.ToString()) > -1)
                            {
                                k.Visible = true;
                            }
                            else
                            {
                                k.Visible = false;
                            }
                            if (k.Value.ToString() == _source.account_name)
                            {
                                k.Visible = false;
                            }
                        }
                        break;
                    }

                    case "ACC_PAYABLE":
                    {
                        foreach (var k in m_DestinationAccounts.Items.Cast <fnn.iGComboItemEX>())
                        {
                            if (m_ChequeList.IndexOf(k.Value.ToString()) > -1)
                            {
                                k.Visible = false;
                            }
                            else
                            {
                                k.Visible = true;
                            }
                            if (k.Value.ToString() == _source.account_name)
                            {
                                k.Visible = false;
                            }
                        }
                        break;
                    }
                    }
                }
            }
            //
        }
Ejemplo n.º 17
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            iGRow _row = fGrid.Rows[e.RowIndex];

            if (_row.Cells[1].DropDownControl != null && _row.Cells[1].AuxValue == null)
            {
                _row.Cells[1].Value = null;

                if (_row.Key == "account")
                {
                    fGrid.Rows["end_date"].Cells[1].Value   = null;
                    fGrid.Rows["start_date"].Cells[1].Value = null;
                    //
                    fGrid.Rows["end_date"].Cells[1].Enabled   = iGBool.False;
                    fGrid.Rows["start_date"].Cells[1].Enabled = iGBool.False;
                    //
                }
                return;
            }
            if (_row.Key == "start_date")
            {
                object _date_obj = Convert.ToDateTime(fGrid.Rows["start_date"].Cells["desc"].AuxValue);
                if (_date_obj == null)
                {
                    _row.Cells["desc"].Value = sdata.CURR_DATE;
                    return;
                }
                fGrid.Rows["end_date"].Cells[1].Value    = null;
                fGrid.Rows["end_date"].Cells[1].AuxValue = null;
                var _date      = Convert.ToDateTime(_date_obj);
                var _drop_down = fGrid.Rows["end_date"].Cells[1].DropDownControl as fnn.DropDownCalenderX;
                _drop_down.start_date    = _date.AddDays(1);
                _drop_down.selected_date = _drop_down.start_date;
                _drop_down.end_date      = _date.AddDays(366);
                //
                fGrid.Rows["end_date"].Cells[1].Enabled = iGBool.True;
            }
            //
            if (_row.Key == "account")
            {
                ic.accountC _acc = (fGrid.Rows["account"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC;
                if (_acc != null)
                {
                    var _saccount = (from k in datam.DATA_CURRENT_PLEDGE_SETTINGS.Values
                                     where k.account_id == _acc.account_id & k.status == em.pledge_setting_statusS.valid
                                     orderby k.pls_id descending
                                     select k).FirstOrDefault();
                    var _drop_down = fGrid.Rows["start_date"].Cells[1].DropDownControl  as fnn.DropDownCalenderX;
                    fGrid.Rows["start_date"].Cells[1].Value    = null;
                    fGrid.Rows["start_date"].Cells[1].AuxValue = null;
                    if (_saccount != null)
                    {
                        _drop_down.start_date    = _saccount.end_date.Value.AddDays(1);
                        _drop_down.selected_date = _drop_down.start_date;
                        _drop_down.end_date      = _drop_down.start_date.Value.AddDays(365);
                    }
                    else
                    {
                        _drop_down.start_date    = sdata.CURR_DATE.AddDays(-365);
                        _drop_down.selected_date = sdata.CURR_DATE;
                        _drop_down.end_date      = sdata.CURR_DATE.AddDays(365);
                    }
                    fGrid.Rows["start_date"].Cells[1].Enabled = iGBool.True;
                    fGrid.Rows["end_date"].Cells[1].Value     = null;
                    fGrid.Rows["end_date"].Cells[1].AuxValue  = null;
                    //
                    fGrid.Rows["end_date"].Cells[1].Enabled = iGBool.False;
                }
            }
            if (_row.Key == "end_date")
            {
                if (_row.Cells[1].Value != null)
                {
                    buttonX1.PerformClick();
                }
            }
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
Ejemplo n.º 18
0
        private void fGrid_AfterCommitEdit(object sender, iGAfterCommitEditEventArgs e)
        {
            if (fGrid.Rows[e.RowIndex].Cells["desc"].DropDownControl != null && fGrid.Rows[e.RowIndex].Cells["desc"].AuxValue == null)
            {
                fGrid.Rows[e.RowIndex].Cells["desc"].Value = null;
                if (fGrid.Rows[e.RowIndex].Key == "account_from")
                {
                    fGrid.Rows["account_to"].Cells[1].Value    = null;
                    fGrid.Rows["account_to"].Cells[1].AuxValue = null;
                    fGrid.Rows["account_to"].Cells[1].Enabled  = iGBool.False;
                }
                return;
            }
            if (fGrid.Rows[e.RowIndex].Key == "account_from")
            {
                fGrid.Rows["account_to"].Cells[1].Value    = null;
                fGrid.Rows["account_to"].Cells[1].AuxValue = null;
                fGrid.Rows["account_to"].Cells[1].Enabled  = iGBool.False;
                var icombo = fGrid.Rows["account_to"].Cells[1].DropDownControl as iGDropDownList;
                if (icombo == null)
                {
                    icombo = fnn.CreateCombo();
                    fGrid.Rows["account_to"].Cells[1].DropDownControl = icombo;
                }
                ic.accountC _from = (fGrid.Rows["account_from"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.accountC;
                icombo.Items.Clear();
                var nlist = accn.GetChildAccounts(m_group_account.account_id, em.account_typeS.ActualAccount);

                if (nlist != null)
                {
                    foreach (var k in nlist)
                    {
                        if (k.account_status == em.account_statusS.DeActivated)
                        {
                            continue;
                        }
                        if (k.account_id == _from.account_id)
                        {
                            continue;
                        }
                        icombo.Items.Add(new fnn.iGComboItemEX()
                        {
                            Value = k.account_name,
                            Tag   = k
                        });
                    }
                }
                fGrid.Rows["account_to"].Cells[1].Enabled = iGBool.True;
            }
            if (e.RowIndex != fGrid.Rows.Count - 1)
            {
                if (fGrid.Rows[e.RowIndex].Cells["desc"].Value == null)
                {
                    return;
                }
                for (int k = e.RowIndex + 1; k < fGrid.Rows.Count; k++)
                {
                    if (fGrid.Rows[k].Type == iGRowType.AutoGroupRow)
                    {
                        fGrid.Rows[k].Expanded = true;
                        continue;
                    }
                    if (!fGrid.Rows[k].Visible)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].Enabled == iGBool.False)
                    {
                        continue;
                    }
                    if (fGrid.Rows[k].Cells[1].ReadOnly == iGBool.True)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(fGrid.Rows[k].Key))
                    {
                        continue;
                    }
                    if ((e.RowIndex + 3) < fGrid.Rows.Count)
                    {
                        fGrid.Rows[(e.RowIndex + 3)].EnsureVisible();
                    }
                    fGrid.SetCurCell(k, e.ColIndex);
                    break;
                }
            }
        }
        private void LoadGrid()
        {
            var nlist = from k in datam.DATA_ACCOUNTS_PAYABLE.Values
                        where k.balance != 0 & k.objAccount.account_type == em.account_typeS.ActualAccount
                        orderby k.balance descending
                        select k;
            iGRow _row = null;

            fGrid.BeginUpdate();
            ic.accountC _acc = null;
            foreach (var r in nlist)
            {
                _row          = fGrid.Rows.Add();
                _row.Font     = new Font("georgia", 12, FontStyle.Regular);
                _row.ReadOnly = iGBool.True;
                _acc          = datam.DATA_ACCOUNTS[r.account_id];
                if (r.account_id < 0)
                {
                    _row.Cells["owner"].Value  = "CUC";
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                }
                _row.Cells["account"].Value      = _acc.account_name;
                _row.Cells["balance"].Value      = r.balance;
                _row.Cells["balance"].Font       = new Font("verdana", 11, FontStyle.Regular);
                _row.Cells["balance"].ForeColor  = Color.DarkBlue;
                _row.Cells["acc_category"].Value = datam.DATA_ACCOUNTS[_acc.p_account_id].account_name;
                // _row.Cells["owner"].Value = _acc.owner_name;
                switch (_acc.owner_type)
                {
                case em.AccountOwnerTypeS.CUC:
                {
                    _row.Cells["owner"].Value  = "CUC";
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 1;
                    break;
                }

                case em.AccountOwnerTypeS.CHURCH:
                {
                    _row.Cells["owner"].Value  = "Church";
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 3;
                    break;
                }

                case em.AccountOwnerTypeS.CHURCH_GROUP:
                {
                    try
                    {
                        _row.Cells["owner"].Value = datam.DATA_CHURCH_GROUPS[_acc.owner_id].cg_name;
                    }
                    catch (Exception)
                    {
                        _row.Cells["owner"].Value = "Church Group";
                    }
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 5;
                    break;
                }

                case em.AccountOwnerTypeS.CHURCH_MEMBER:
                {
                    try
                    {
                        _row.Cells["owner"].Value = datam.DATA_MEMBER[_acc.owner_id].mem_name;
                    }
                    catch (Exception)
                    {
                        _row.Cells["owner"].Value = "Church Member";
                    }
                    _row.Cells["svalue"].Value = "Church Members";
                    _row.Cells["s_id"].Value   = 7;
                    break;
                }

                case em.AccountOwnerTypeS.DEPARTMENT:
                {
                    try
                    {
                        _row.Cells["owner"].Value = datam.DATA_DEPARTMENT[_acc.owner_id].dept_name;
                        if (_row.Cells["owner"].Text.IndexOf("department") == -1)
                        {
                            _row.Cells["owner"].Value = _row.Cells["owner"].Text + " Department";
                        }
                    }
                    catch (Exception)
                    {
                        _row.Cells["owner"].Value = "Department";
                    }
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 4;

                    break;
                }

                case em.AccountOwnerTypeS.DISTRICT:
                {
                    _row.Cells["owner"].Value  = "District";
                    _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                    _row.Cells["s_id"].Value   = 2;
                    break;
                }

                case em.AccountOwnerTypeS.OTHER:
                {
                    _row.Cells["owner"].Value  = _acc.owner_name;
                    _row.Cells["svalue"].Value = "Others";
                    _row.Cells["s_id"].Value   = 6;
                    break;
                }
                }
                if (r.objAccount.owner_id > 0)
                {
                    try
                    {
                        var _cg = datam.DATA_CHURCH_GROUPS[r.objAccount.owner_id];
                        if (_cg != null)
                        {
                            _row.Cells["account"].Value = string.Format("{0} :: {1}", _acc.account_name, _cg.cg_name);
                            _row.Cells["owner"].Value   = _cg.cg_name;
                            _row.Cells["svalue"].Value  = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value    = 5;
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }
                _row.AutoHeight();
                _row.Key     = string.Format("{0}{1}", r.account_id.ToString(), r.objAccount.owner_id);
                _row.Tag     = r;
                r.is_updated = false;
            }
            ShowTotalCreditors();
            fGrid.Cols.AutoWidth();
            fGrid.AutoResizeCols = false;
            var Gtotal = from k in fGrid.Rows.Cast <iGRow>()
                         group k by k.Cells["svalue"].Text
                         into nw_gp
                         select new
            {
                gp_name  = nw_gp.Key,
                gp_total = nw_gp.Sum(p => p.Cells["balance"].Value.ToInt32())
            };

            m_GroupTotal.Clear();
            foreach (var t in Gtotal)
            {
                m_GroupTotal.Add(t.gp_name, t.gp_total);
            }
            if (fGrid.GroupObject.Count == 0)
            {
                fGrid.GroupObject.Add("svalue");
            }
            fGrid.Group();
            fGrid.PerformAction(iGActions.CollapseAll);
            fGrid.EndUpdate();
        }
        private void CheckUpdates()
        {
            using (var _xd = new xing())
            {
                datam.InitAccount(_xd);
                _xd.CommitTransaction();
            }
            wdata.TABLE_STAMP["accounts_current_balance_tb"] = m_LastStamp;
            if (datam.GetAccountsPayable(null))
            {
                m_LastStamp = wdata.TABLE_STAMP["accounts_current_balance_tb"];
                var nlist = from k in datam.DATA_ACCOUNTS_PAYABLE.Values
                            where k.is_updated & k.objAccount.account_type == em.account_typeS.ActualAccount
                            select k;
                if (nlist.Count() == 0)
                {
                    return;
                }
                var   _selected_cell = fGrid.CurCell;
                var   ex_list        = fGrid.Rows.Cast <iGRow>().Where(t => t.Type == iGRowType.AutoGroupRow & t.Expanded).Select(p => p.Key).ToList();
                iGRow _row           = null;
                fGrid.BeginUpdate();
                fGrid.GroupObject.Clear();
                fGrid.Group();
                ic.accountC _acc = null;
                foreach (var r in nlist)
                {
                    try
                    {
                        _row = fGrid.Rows[string.Format("{0}{1}", r.account_id.ToString(), r.objAccount.owner_id)];
                        _acc = datam.DATA_ACCOUNTS[r.account_id];
                        _row.Cells["balance"].Value = r.balance;
                    }
                    catch (Exception ex)
                    {
                        #region new_row
                        _row          = fGrid.Rows.Add();
                        _row.Font     = new Font("georgia", 12, FontStyle.Regular);
                        _row.ReadOnly = iGBool.True;
                        _acc          = datam.DATA_ACCOUNTS[r.account_id];
                        if (r.account_id < 0)
                        {
                            _row.Cells["owner"].Value  = "CUC";
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                        }
                        _row.Cells["account"].Value      = _acc.account_name;
                        _row.Cells["balance"].Value      = r.balance;
                        _row.Cells["balance"].Font       = new Font("verdana", 11, FontStyle.Regular);
                        _row.Cells["balance"].ForeColor  = Color.DarkBlue;
                        _row.Cells["acc_category"].Value = datam.DATA_ACCOUNTS[_acc.p_account_id].account_name;
                        // _row.Cells["owner"].Value = _acc.owner_name;
                        switch (_acc.owner_type)
                        {
                        case em.AccountOwnerTypeS.CUC:
                        {
                            _row.Cells["owner"].Value  = "CUC";
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 1;
                            break;
                        }

                        case em.AccountOwnerTypeS.CHURCH:
                        {
                            _row.Cells["owner"].Value  = "Church";
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 3;
                            break;
                        }

                        case em.AccountOwnerTypeS.CHURCH_GROUP:
                        {
                            try
                            {
                                _row.Cells["owner"].Value = datam.DATA_CHURCH_GROUPS[_acc.owner_id].cg_name;
                            }
                            catch (Exception)
                            {
                                _row.Cells["owner"].Value = "Church Group";
                            }
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 5;
                            break;
                        }

                        case em.AccountOwnerTypeS.CHURCH_MEMBER:
                        {
                            try
                            {
                                _row.Cells["owner"].Value = datam.DATA_MEMBER[_acc.owner_id].mem_name;
                            }
                            catch (Exception)
                            {
                                _row.Cells["owner"].Value = "Church Member";
                            }
                            _row.Cells["svalue"].Value = "Church Members";
                            _row.Cells["s_id"].Value   = 7;
                            break;
                        }

                        case em.AccountOwnerTypeS.DEPARTMENT:
                        {
                            try
                            {
                                _row.Cells["owner"].Value = datam.DATA_DEPARTMENT[_acc.owner_id].dept_name;
                                if (_row.Cells["owner"].Text.IndexOf("department") == -1)
                                {
                                    _row.Cells["owner"].Value = _row.Cells["owner"].Text + " Department";
                                }
                            }
                            catch (Exception)
                            {
                                _row.Cells["owner"].Value = "Department";
                            }
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 4;

                            break;
                        }

                        case em.AccountOwnerTypeS.DISTRICT:
                        {
                            _row.Cells["owner"].Value  = "District";
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            _row.Cells["s_id"].Value   = 2;
                            break;
                        }

                        case em.AccountOwnerTypeS.OTHER:
                        {
                            _row.Cells["owner"].Value  = _acc.owner_name;
                            _row.Cells["svalue"].Value = "Others";
                            _row.Cells["s_id"].Value   = 6;
                            break;
                        }

                        case em.AccountOwnerTypeS.CHURCH_GROUP_SHARED:
                        {
                            if (r.objAccount.owner_id == 0)
                            {
                                _row.Cells["owner"].Value = "Church";
                                _row.Cells["s_id"].Value  = 3;
                            }
                            else
                            {
                                try
                                {
                                    var _cg = datam.DATA_CHURCH_GROUPS[r.objAccount.owner_id];
                                    if (_cg != null)
                                    {
                                        _row.Cells["account"].Value = string.Format("{0} :: {1}", _acc.account_name, _cg.cg_name);
                                        _row.Cells["owner"].Value   = _cg.cg_name;
                                        _row.Cells["s_id"].Value    = 5;
                                    }
                                }
                                catch (Exception er)
                                {
                                }
                            }
                            _row.Cells["svalue"].Value = _row.Cells["owner"].Value;
                            break;
                        }
                        }
                        #endregion
                        _row.AutoHeight();
                        _row.Key = string.Format("{0}{1}", r.account_id.ToString(), r.objAccount.owner_id);
                        _row.Tag = r;
                    }
                    r.is_updated = false;
                }
                ShowTotalCreditors();
                fGrid.Cols.AutoWidth();
                fGrid.AutoResizeCols = false;
                var Gtotal = from k in fGrid.Rows.Cast <iGRow>()
                             group k by k.Cells["svalue"].Text
                             into nw_gp
                             select new
                {
                    gp_name  = nw_gp.Key,
                    gp_total = nw_gp.Sum(p => p.Cells["balance"].Value.ToInt32())
                };
                m_GroupTotal.Clear();
                foreach (var t in Gtotal)
                {
                    m_GroupTotal.Add(t.gp_name, t.gp_total);
                }
                if (fGrid.GroupObject.Count == 0)
                {
                    fGrid.GroupObject.Add("svalue");
                }
                fGrid.Group();
                fGrid.PerformAction(iGActions.CollapseAll);
                foreach (var y in ex_list)
                {
                    try
                    {
                        fGrid.Rows[y].Expanded = true;
                    }
                    catch (Exception ex)
                    {
                    }
                }
                fGrid.EndUpdate();
            }
        }
        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();
                    }
                }
            }
        }
Ejemplo n.º 22
0
        public static void Get_AssetLiabilityAccountStatement(xing xd, int start_fs_id, int end_fs_id, int account_id, string _account_name)
        {
            datam.InitAccount(xd);
            datam.LoadCrExpOffItems(xd);
            ic.accountC PrimaryAccount = datam.DATA_ACCOUNTS[account_id];

            switch (PrimaryAccount.account_dept_category)
            {
            case em.account_d_categoryS.Liablity:
            {
                var _cr_inc_item = datam.DATA_CR_EXP_OFFITEMS.Values.Where(k => k.gen_account_id == account_id & k._type == em.link_accTypes.creditor).FirstOrDefault();
                if (_cr_inc_item == null)
                {
                    return;
                }

                int         cg_id          = _cr_inc_item.cg_id;
                int         _income_acc_id = _cr_inc_item.account_id;
                ic.accountC _parent        = datam.DATA_ACCOUNTS[_income_acc_id].p_account_id == 0 ? null : datam.DATA_ACCOUNTS[datam.DATA_ACCOUNTS[_income_acc_id].p_account_id];
                if (_parent != null && _parent.account_id == -2360)
                {
                    ic.church_sub_unitC _unit = (from c in datam.DATA_CHURCH_SUB_UNIT.Values
                                                 where c.sys_gp_account_id == _income_acc_id
                                                 select c).FirstOrDefault();
                    if (_unit != null)
                    {
                        int _expense_acc_id = datam.DATA_CR_EXP_OFFITEMS.Values.Where(k => k.link_id == _cr_inc_item.link_id & k._type == em.link_accTypes.expense_accrued).FirstOrDefault().gen_account_id;
                        //
                        Get_OffAccountsStatement(xd, start_fs_id, end_fs_id, _unit, _account_name);
                        Get_CreditorExpenseStatement(xd, start_fs_id, end_fs_id, _expense_acc_id);
                        Get_AccountTransfers(xd, start_fs_id, end_fs_id, account_id);
                        //
                    }
                }
                else
                {
                    int _expense_acc_id = datam.DATA_CR_EXP_OFFITEMS.Values.Where(k => k.link_id == _cr_inc_item.link_id & k._type == em.link_accTypes.expense_accrued).FirstOrDefault().gen_account_id;
                    //
                    var _income_account = datam.DATA_ACCOUNTS[_income_acc_id];
                    if (_income_account.owner_type == em.AccountOwnerTypeS.CHURCH_GROUP_SHARED | _income_account.account_id == -2435)
                    {
                        cg_id = _cr_inc_item.cg_id;
                    }
                    else
                    {
                        cg_id = -1;
                    }
                    Get_OffAccountsStatement(xd, start_fs_id, end_fs_id, _income_acc_id, cg_id, _account_name);
                    Get_CreditorExpenseStatement(xd, start_fs_id, end_fs_id, _expense_acc_id);
                    Get_AccountTransfers(xd, start_fs_id, end_fs_id, account_id);
                    //
                }
                break;
            }

            case em.account_d_categoryS.Asset:
            {
                ic.accountC _account = datam.DATA_ACCOUNTS[account_id];
                switch (_account.p_account_id)
                {
                case -2499:           //accn.GetAccountByAlias("BANK_ACCOUNT").account_id:
                {
                    datam.GetBankAccounts(xd);
                    ic.bankAccountC _bank = (from k in datam.DATA_BANK_ACCOUNTS.Values
                                             where k.sys_account_id == account_id
                                             select k).FirstOrDefault();
                    if (_bank != null)
                    {
                        Get_BankingStatement(xd, start_fs_id, end_fs_id, _bank.un_id);
                        Get_BankingWithDrawStatement(xd, start_fs_id, end_fs_id, _bank.un_id);
                        Get_BankExpenseStatement(xd, start_fs_id, end_fs_id, account_id);
                    }
                    break;
                }

                case -2404:           // accn.GetAccountByAlias("UNBANKED").account_id:
                {
                    break;
                }
                }

                break;
            }
            }
        }