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();
        }
Ejemplo n.º 2
0
        public static bool GetMonthBankReconcilition(int m_partition_id)
        {
            if (DATA_MONTH_BANK_RECONCILIATION == null)
            {
                DATA_MONTH_BANK_RECONCILIATION = new SortedList <int, SortedList <int, ic.bank_reconc_transC> >();
            }
            if (DATA_MONTH_BANK_RECONCILIATION.Keys.IndexOf(m_partition_id) == -1)
            {
                DATA_MONTH_BANK_RECONCILIATION.Add(m_partition_id, new SortedList <int, ic.bank_reconc_transC>());
            }
            if (wdata.DATA_MONTH_STAMP == null)
            {
                wdata.DATA_MONTH_STAMP = new SortedList <string, SortedList <int, long> >();
            }

            string _table_name = "acc_bank_reconc_trans_tb";

            if (wdata.DATA_MONTH_STAMP.IndexOfKey(_table_name) == -1)
            {
                wdata.DATA_MONTH_STAMP.Add(_table_name, new SortedList <int, long>());
                wdata.DATA_MONTH_STAMP[_table_name].Add(m_partition_id, 0);
            }
            string _str       = null;
            bool   load_all   = false;
            bool   is_new     = false;
            bool   is_updated = false;
            long   _stamp     = 0;

            using (var xd = new xing())
            {
                _stamp = xd.GetTimeStamp(_table_name);
                if (datam.DATA_MONTH_BANK_RECONCILIATION[m_partition_id].Keys.Count == 0)
                {
                    _str     = string.Format("select * from " + _table_name + " where m_partition_id={0} and status={1}", m_partition_id, em.voucher_statusS.valid.ToByte());
                    load_all = true;
                    is_new   = true;
                }
                else
                {
                    if (_stamp == wdata.DATA_MONTH_STAMP[_table_name][m_partition_id])
                    {
                        xd.RollBackTransaction();
                        return(false);
                    }
                    _str = string.Format("select * from " + _table_name + " where m_partition_id={0} and fs_time_stamp > {1}", m_partition_id, wdata.DATA_MONTH_STAMP[_table_name][m_partition_id]);
                }
                wdata.DATA_MONTH_STAMP[_table_name][m_partition_id] = _stamp;
                using (var _dr = xd.SelectCommand(_str))
                {
                    if (_dr == null)
                    {
                        return(false);
                    }
                    ic.bank_reconc_transC _obj = null;
                    while (_dr.Read())
                    {
                        if (!is_updated)
                        {
                            is_updated = true;
                        }
                        _obj = null;
                        if (load_all)
                        {
                            _obj = new ic.bank_reconc_transC();
                        }
                        else
                        {
                            try
                            {
                                _obj   = DATA_MONTH_BANK_RECONCILIATION[m_partition_id][_dr["un_id"].ToInt32()];
                                is_new = false;
                            }
                            catch (Exception)
                            {
                                if (_obj == null)
                                {
                                    _obj   = new ic.bank_reconc_transC();
                                    is_new = true;
                                }
                            }
                        }
                        //
                        if (is_new)
                        {
                            _obj.un_id           = _dr["un_id"].ToInt32();
                            _obj.br_acc_id       = _dr["br_acc_id"].ToInt32();
                            _obj.br_acc_type     = (em.bank_reconc_typeS)_dr["br_acc_type_id"].ToInt32();
                            _obj.bank_account_id = _dr["bank_account_id"].ToInt32();
                            _obj.amount          = _dr["amount"].ToInt32();
                            _obj.desc            = _dr["description"].ToStringNullable();
                            _obj.status          = (em.voucher_statusS)_dr["status"].ToInt16();
                            _obj.m_partition_id  = _dr["m_partition_id"].ToInt32();
                            _obj.sys_account_id  = _dr["sys_account_id"].ToInt32();
                            _obj.fs_id           = _dr["fs_id"].ToInt32();
                            _obj.fs_date         = _dr.GetDateTime("fs_date");
                            //
                            _obj.objReconcAccount = datam.DATA_BANK_RECONCILIATION_ACCOUNTS[_obj.br_acc_id];
                            _obj.objBankAccount   = datam.DATA_BANK_ACCOUNTS[_obj.bank_account_id];
                        }
                        _obj.status     = (em.voucher_statusS)_dr["status"].ToInt16();
                        _obj.is_updated = true;
                        //if (_dr["del_fs_date"] != null)
                        //{
                        //    //if (_obj.objDelInfo == null) { _obj.objDelInfo = new ic.deleteBaseC(); }
                        //    //_obj.objDelInfo.del_fs_date = _dr.GetDateTime("del_fs_date");
                        //    //_obj.objDelInfo.del_fs_id = fn.GetFSID(_obj.objDelInfo.del_fs_date.Value);
                        //    //_obj.objDelInfo.del_fs_time = _dr["del_fs_time"].ToString()Nullable()();
                        //    //_obj.objDelInfo.del_pc_us_id = _dr["del_pc_us_id"].ToInt32();
                        //}
                        if (is_new)
                        {
                            DATA_MONTH_BANK_RECONCILIATION[m_partition_id].Add(_obj.un_id, _obj);
                        }
                    }
                }

                xd.CommitTransaction();
            }
            return(is_updated);
        }