private void buttonX1_Click(object sender, EventArgs e)
        {
            fGrid.CommitEditCurCell();
            var  _check     = new string[] { "start_date", "bank", "exp_account", "amount", };
            bool _roll_back = false;

            foreach (var k in _check)
            {
                if (fGrid.Rows[k].Cells[1].Value == null)
                {
                    MessageBox.Show("Important Field Left Blank", k);
                    fGrid.Focus();
                    fGrid.SetCurCell(k, 1);
                    return;
                }
            }

            string _str = "Are You Sure You Want To Save This Record ??";

            if (!dbm.WarningMessage(_str, "Save Warning"))
            {
                return;
            }
            buttoncreate.Enabled = false;
            buttoncancel.Enabled = false;
            fGrid.ReadOnly       = true;
            ic.bank_reconc_transC   _trans   = new ic.bank_reconc_transC();
            ic.bank_reconc_accountC _account = (fGrid.Rows["exp_account"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.bank_reconc_accountC;
            ic.bankAccountC         _bank    = (fGrid.Rows["bank"].Cells[1].AuxValue as fnn.iGComboItemEX).Tag as ic.bankAccountC;

            //
            _trans.amount          = fGrid.Rows["amount"].Cells["desc"].Value.ToInt32();
            _trans.fs_date         = System.Convert.ToDateTime(fGrid.Rows["start_date"].Cells[1].AuxValue);
            _trans.fs_id           = fn.GetFSID(_trans.fs_date);
            _trans.status          = em.voucher_statusS.valid;
            _trans.m_partition_id  = string.Format("{0}{1}", _trans.fs_date.Year, _trans.fs_date.Month).ToInt32();
            _trans.br_acc_id       = _account.br_acc_id;
            _trans.sys_account_id  = _account.sys_account_id;
            _trans.bank_account_id = _bank.un_id;
            _trans.br_acc_type     = _account.br_acc_type;
            //
            if (fGrid.Rows["desc"].Cells[1].Value != null)
            {
                _trans.desc = fGrid.Rows["desc"].Cells[1].Text;
            }

            using (var xd = new xing())
            {
                #region Insert Master Payment
                //
                var _ts_id = accn.AccountsTransaction(xd, string.Format("Being Bank Reconciliation"), _trans.fs_date);
                _trans.trans_id = _ts_id;
                _trans.un_id    = xd.SingleInsertCommandTSPInt("acc_bank_reconc_trans_tb", new string[]
                {
                    "br_acc_id",
                    "amount",
                    "transaction_id",
                    "fs_date",
                    "fs_id",
                    "m_partition_id",
                    "status",
                    "sys_account_id",
                    "description",
                    "br_acc_type_id",
                    "fs_time_stamp",
                    "lch_id",
                    "bank_account_id", "pc_us_id"
                }, new object[]
                {
                    _trans.br_acc_id,
                    _trans.amount,
                    _trans.trans_id,
                    _trans.fs_date,
                    _trans.fs_id,
                    _trans.m_partition_id,
                    _trans.status.ToInt16(),
                    _trans.sys_account_id,
                    _trans.desc,
                    _trans.br_acc_type.ToInt16(),
                    0,
                    sdata.ChurchID,
                    _trans.bank_account_id, sdata.PC_US_ID
                });
                #endregion
                switch (_account.br_acc_type)
                {
                case em.bank_reconc_typeS.addition:
                {
                    // accn.JournalBook(xd, _trans.fs_date, em.j_sectionS.income, _ts_id, _account.sys_account_id, 0, 0);
                    break;
                }

                case em.bank_reconc_typeS.deduction:
                {
                    break;
                }
                }
                xd.CommitTransaction();
            }
            fGrid.ReadOnly = false;
            ClearGrid();
            m_process = _process.after_save;
            backworker.RunWorkerAsync();
        }
Exemple #2
0
        public static bool fill_Bank_Reconciliation_Accounts(xing xd)
        {
            // if(datam.)
            //  InitBankReconciliation(xd);
            if (datam.DATA_BANK_RECONCILIATION_ACCOUNTS == null)
            {
                datam.DATA_BANK_RECONCILIATION_ACCOUNTS = new SortedList <int, ic.bank_reconc_accountC>();
            }
            string _table_name = "acc_bank_reconc_accounts_tb";

            if (wdata.TABLE_STAMP == null)
            {
                wdata.TABLE_STAMP = new SortedList <string, long>();
            }
            if (wdata.TABLE_STAMP.IndexOfKey(_table_name) == -1)
            {
                wdata.TABLE_STAMP.Add(_table_name, 0);
            }
            bool   is_new   = false;
            bool   load_all = false;
            string _str     = string.Empty;
            long   _stamp   = xd.GetTimeStamp(_table_name);

            if (DATA_BANK_RECONCILIATION_ACCOUNTS.Keys.Count == 0)
            {
                _str     = "select * from " + _table_name;
                load_all = true;
            }
            else
            {
                if (wdata.TABLE_STAMP[_table_name] == _stamp)
                {
                    return(false);
                }
                _str = string.Format("select * from " + _table_name + " where fs_time_stamp > {0}", wdata.TABLE_STAMP[_table_name]);
            }
            wdata.TABLE_STAMP[_table_name] = _stamp;
            ic.bank_reconc_accountC _obj = null;

            using (var _dr = xd.SelectCommand(_str))
            {
                while (_dr.Read())
                {
                    _obj = null;
                    if (load_all)
                    {
                        _obj   = new ic.bank_reconc_accountC();
                        is_new = true;
                    }
                    else
                    {
                        try
                        {
                            _obj   = datam.DATA_BANK_RECONCILIATION_ACCOUNTS[_dr["br_acc_id"].ToInt32()];
                            is_new = false;
                        }
                        catch (Exception ex)
                        {
                            if (_obj == null)
                            {
                                _obj   = new ic.bank_reconc_accountC();
                                is_new = true;
                            }
                        }
                    }
                    if (is_new)
                    {
                        _obj.br_acc_id      = _dr["br_acc_id"].ToInt32();
                        _obj.sys_account_id = _dr["sys_account_id"].ToInt32();
                        _obj.br_acc_name    = _dr["br_acc_name"].ToStringNullable();
                        _obj.br_acc_type    = (em.bank_reconc_typeS)_dr["br_acc_type_id"].ToInt16();
                        datam.DATA_BANK_RECONCILIATION_ACCOUNTS.Add(_obj.br_acc_id, _obj);
                    }
                }
                _dr.Close();
            }
            return(true);
        }