private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            string _str = "Are You Sure You Want To Delete This Entry";

            if (!dbm.WarningMessage(_str, "Delete Entry Warning"))
            {
                return;
            }
            var m_partition = string.Format("{0}{1}", m_YEAR, m_MONTH).ToInt32();
            var _obj        = fGrid.SelectedRows[0].Tag as ic.bank_reconc_transC;

            if (_obj != null)
            {
                using (var xd = new xing())
                {
                    long _trans_id = xd.ExecuteScalarInt64(string.Format("select transaction_id from acc_foreign_exchange_tb where un_id={0} and status={1}", _obj.un_id, em.voucher_statusS.valid.ToByte()));
                    if (_trans_id > 0)
                    {
                        accn.DeleteJournal(_trans_id, xd);
                        //
                        xd.SingleUpdateCommandALL("acc_bank_reconc_trans_tb",
                                                  new string[]
                        {
                            "status",
                            "un_id",
                        }, new object[]
                        {
                            em.voucher_statusS.cancelled.ToByte(),
                            _obj.un_id
                        }, 1);
                        //
                        //fnn.ExecuteDeleteBase(xd, new ic.deleteBaseC()
                        //{
                        //    del_fs_date = sdata.CURR_DATE,
                        //    del_fs_id = sdata.CURR_FS.fs_id,
                        //    del_fs_time = DateTime.Now.ToShortTimeString(),
                        //    del_pc_us_id = sdata.PC_US_ID
                        //}, "acc_foreign_exchange_tb", "un_id", _obj.un_id);
                        //
                        xd.CommitTransaction();
                        fGrid.Rows.RemoveAt(fGrid.Rows[_obj.un_id.ToString()].Index);
                    }
                    else
                    {
                        MessageBox.Show("This Record Has Already Been Cancelled", "Cancel Failure");
                    }
                }
                CheckForUpdates();
            }
        }
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            string _str = "Are You Sure You Want To Delete This Voucher";

            if (!dbm.WarningMessage(_str, "Delete Voucher Warning"))
            {
                return;
            }
            var _obj = fGrid.SelectedRows[0].Tag as ic.expense_transC;

            var m_partition = string.Format("{0}{1}", _obj.exp_date.Value.Year, _obj.exp_date.Value.Month).ToInt32();

            datam.GetMonthExpenses(m_partition);
            var nlist = from k in datam.DATA_MONTH_EXPENSES[m_partition].Values
                        where k.voucher_id == _obj.voucher_id & k.voucher_status == em.voucher_statusS.valid
                        select k;

            if (_obj != null)
            {
                using (var xd = new xing())
                {
                    long _trans_id = xd.ExecuteScalarInt64(string.Format("select transaction_id from acc_expense_trans_tb where un_id={0} and voucher_status={1}", _obj.un_id, em.voucher_statusS.valid.ToByte()));
                    if (_trans_id > 0)
                    {
                        _str = string.Format("update acc_expense_vouchers_tb set status={0},{1},fs_time_stamp={2} where voucher_id={3} and status={4}", em.voucher_statusS.cancelled.ToByte(), dbm.ETS, SQLH.UnixStamp, _obj.voucher_id, em.voucher_statusS.valid.ToByte());
                        xd.UpdateFsTimeStamp("acc_expense_vouchers_tb");
                        if (xd.SingleUpdateCommand(_str))
                        {
                            _str = string.Format("select * from journal_tb where transaction_id in ({0})",
                                                 string.Format("select transaction_id from acc_expense_trans_tb where un_id={0} and voucher_status={1}", _obj.un_id, em.voucher_statusS.valid.ToByte()));
                            accn.DeleteJournal(_str, xd);
                            //

                            foreach (var _expense in nlist)
                            {
                                _expense.voucher_status = em.voucher_statusS.cancelled;
                                xd.SingleUpdateCommandALL("acc_expense_trans_tb", new string[]
                                {
                                    "voucher_status",
                                    "un_id"
                                }, new object[]
                                {
                                    em.voucher_statusS.cancelled.ToByte(),
                                    _expense.un_id
                                }, 1);
                                //
                                xd.SingleUpdateCommandALL("acc_expense_trans_child_tb", new string[]
                                {
                                    "voucher_status",
                                    "trans_id"
                                }, new object[]
                                {
                                    em.voucher_statusS.cancelled.ToByte(),
                                    _expense.un_id
                                }, 1);
                                if (datam.DATA_EXPENSE_ACCOUNTS[_expense.exp_acc_id].exp_acc_type == em.exp_acc_typeS.system_offertory_payment |
                                    datam.DATA_EXPENSE_ACCOUNTS[_expense.exp_acc_id].exp_acc_type == em.exp_acc_typeS.trust_fund)
                                {
                                    accn.DeleteExpenseAccountsPayable(xd, _trans_id);
                                }
                                if (!string.IsNullOrEmpty(_expense.w_dr_data))
                                {
                                    var _cheques = _expense.w_dr_data.Split(new char[] { ',' });
                                    xd.UpdateFsTimeStamp("acc_bank_withdraw_tb");
                                    string _st = null;
                                    foreach (var t in _cheques)
                                    {
                                        var _val = t.Split(new char[] { ':' });
                                        if (xd.ExecuteScalarInt(string.Format("select transfer_id from acc_bank_withdraw_tb where wdr_id={0}", _val[0].ToInt32())) > 0)
                                        {
                                            MessageBox.Show("You Have Already Closed This Cheque, This Operation Cannot Be Carried Out", "Closed Cheque Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                            xd.RollBackTransaction();
                                            return;
                                        }
                                        _st = string.Format("update acc_bank_withdraw_tb set cheque_balance=(cheque_balance+{0}),{1},fs_time_stamp={2} where wdr_id={3}", _val[1],
                                                            dbm.ETS, SQLH.UnixStamp, _val[0]);
                                        xd.InsertUpdateDelete(_st);
                                    }
                                }

                                //
                                fnn.ExecuteDeleteBase(xd, new ic.deleteBaseC()
                                {
                                    del_fs_date  = sdata.CURR_DATE,
                                    del_fs_id    = sdata.CURR_FS.fs_id,
                                    del_fs_time  = DateTime.Now.ToShortTimeString(),
                                    del_pc_us_id = sdata.PC_US_ID
                                }, "acc_expense_trans_tb", "un_id", _expense.un_id);
                                //
                                if (!string.IsNullOrEmpty(_expense.cheque_no))
                                {
                                    ic.bankAccountC _bank = datam.DATA_BANK_ACCOUNTS.Values.Where(y => y.sys_account_id == _expense.source_account_id).FirstOrDefault();
                                    xd.SingleUpdateCommandALL("acc_usedbank_cheques_tb", new string[]
                                    {
                                        "status",
                                        "bank_account_id",
                                        "cheque_no"
                                    }, new object[]
                                    {
                                        1,
                                        _bank.un_id,
                                        _expense.cheque_no
                                    }, 2);
                                }
                                fGrid.Rows.RemoveAt(fGrid.Rows[_expense.un_id.ToString()].Index);
                            }

                            xd.CommitTransaction();
                        }
                    }
                    else
                    {
                        MessageBox.Show("This Expense Record Has Already Been Deleted", "Delete Failure");
                    }
                }
                CheckForUpdates();
            }
        }
Beispiel #3
0
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            string _str = "Are You Sure You Want To Delete This Transfer";

            if (!dbm.WarningMessage(_str, "Delete Transfer Warning"))
            {
                return;
            }
            var m_partition = string.Format("{0}{1}", m_YEAR, m_MONTH).ToInt32();
            var _obj        = fGrid.SelectedRows[0].Tag as ic.cash_transferC;

            _obj.status = em.cashTransferStatus.deleted;
            if (_obj != null)
            {
                using (var xd = new xing())
                {
                    long _trans_id = xd.ExecuteScalarInt64(string.Format("select transaction_id from acc_cash_transfer_tb where un_id={0} and status={1}", _obj.un_id, em.cashTransferStatus.valid.ToByte()));
                    if (_trans_id > 0)
                    {
                        _str = string.Format("update acc_cash_transfer_tb set status={0},{1},fs_time_stamp={2} where un_id={3} and status={4}", em.cashTransferStatus.deleted.ToByte(), dbm.ETS, SQLH.UnixStamp, _obj.un_id, em.cashTransferStatus.valid.ToByte());
                        xd.UpdateFsTimeStamp("acc_cash_transfer_tb");
                        if (xd.SingleUpdateCommand(_str))
                        {
                            _str = string.Format("select source_id, destination_id, amount from acc_cash_transfer_tb where transaction_id={0}", _trans_id);
                            int _source_id      = 0;
                            int _destination_id = 0;
                            int _amount         = 0;
                            using (var _dr = xd.SelectCommand(_str))
                            {
                                while (_dr.Read())
                                {
                                    _source_id      = _dr["source_id"].ToInt32();
                                    _destination_id = _dr["destination_id"].ToInt32();
                                    _amount         = _dr["amount"].ToInt32();
                                }
                                //
                            }
                            #region
                            if (accn.GetAccountBaseParent(_source_id).search_alias == "WITHDRAWN_CHEQUES")
                            {
                                //cheque stuff;
                                int wdr_id = xd.ExecuteScalarInt(string.Format("select wdr_id from acc_bank_withdraw_tb where sys_account_id={0}", _source_id));
                                if (wdr_id > 0)
                                {
                                    xd.UpdateFsTimeStamp("acc_bank_withdraw_tb");
                                    var _st = string.Format("update acc_bank_withdraw_tb set cheque_balance=(cheque_balance+{0}),{1},fs_time_stamp={2} where wdr_id={3}", _amount,
                                                            dbm.ETS, SQLH.UnixStamp, wdr_id);
                                    xd.SingleUpdateCommand(_st);
                                }
                                if (accn.GetAccountBaseParent(_destination_id).search_alias == "WITHDRAWN_CHEQUES")
                                {
                                    xd.UpdateFsTimeStamp("acc_bank_withdraw_tb");
                                    wdr_id = xd.ExecuteScalarInt(string.Format("select wdr_id from acc_bank_withdraw_tb where sys_account_id={0}", _destination_id));
                                    if (wdr_id > 0)
                                    {
                                        xd.UpdateFsTimeStamp("acc_bank_withdraw_tb");
                                        var _st = string.Format("update acc_bank_withdraw_tb set cheque_balance=(cheque_balance-{0}),{1},fs_time_stamp={2} where wdr_id={3}", _amount,
                                                                dbm.ETS, SQLH.UnixStamp, wdr_id);
                                        xd.SingleUpdateCommand(_st);
                                    }
                                }
                            }
                            #endregion
                            accn.DeleteJournal(_trans_id, xd);
                            fGrid.Rows.RemoveAt(fGrid.Rows[_obj.un_id.ToString()].Index);
                            var _delete_id = xd.IDCtrlGet("CASH_TRANSFER_DELETE_ID");
                            xd.SingleUpdateCommandALL("acc_cash_transfer_tb", new string[]
                            {
                                "delete_id",
                                "delete_fs_date",
                                "delete_pc_us_id",
                                "un_id"
                            }, new object[]
                            {
                                _delete_id,
                                sdata.CURR_DATE,
                                sdata.PC_US_ID,
                                _obj.un_id
                            }, 1);
                            xd.CommitTransaction();
                        }
                    }
                    else
                    {
                        MessageBox.Show("This Transfer Has Already Been Deleted", "Delete Failure");
                    }
                }
                CheckForUpdates();
            }
        }
        private void toolStripMenuItem3_Click(object sender, EventArgs e)
        {
            string _str = "Are You Sure You Want To Delete This Entry";

            if (!dbm.WarningMessage(_str, "Delete Entry Warning"))
            {
                return;
            }
            var m_partition = string.Format("{0}{1}", m_YEAR, m_MONTH).ToInt32();
            var _obj        = fGrid.SelectedRows[0].Tag as ic.foreign_exchange_convC;

            if (dbm.ExecuteScalarInt(string.Format("select last_exchange_id from acc_foreign_currency_tb where fr_currency_id={0}", _obj.currency_id)) != _obj.un_id)
            {
                MessageBox.Show("You Cannot Delete This Entry As It Is Not The Last Record", "Delete Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (_obj != null)
            {
                using (var xd = new xing())
                {
                    long _trans_id = xd.ExecuteScalarInt64(string.Format("select transaction_id from acc_foreign_exchange_tb where un_id={0} and status={1}", _obj.un_id, em.foreign_exch_statusS.valid.ToByte()));
                    if (_trans_id > 0)
                    {
                        accn.DeleteJournal(_trans_id, xd);
                        //
                        xd.SingleUpdateCommandALL("acc_foreign_exchange_tb",
                                                  new string[]
                        {
                            "status",
                            "un_id",
                        }, new object[]
                        {
                            em.foreign_exch_statusS.invalid.ToByte(),
                            _obj.un_id
                        }, 1);
                        //
                        fnn.ExecuteDeleteBase(xd, new ic.deleteBaseC()
                        {
                            del_fs_date  = sdata.CURR_DATE,
                            del_fs_id    = sdata.CURR_FS.fs_id,
                            del_fs_time  = DateTime.Now.ToShortTimeString(),
                            del_pc_us_id = sdata.PC_US_ID
                        }, "acc_foreign_exchange_tb", "un_id", _obj.un_id);
                        //
                        var _last_id = dbm.ExecuteScalarInt(string.Format("select TOP 1 un_id from acc_foreign_exchange_tb where currency_id={0} and un_id<>{1} and status=0 order by un_id desc", _obj.currency_id, _obj.un_id));
                        if (_last_id > 0)
                        {
                            xd.SingleUpdateCommandALL("acc_foreign_currency_tb",
                                                      new string[]
                            {
                                "last_exchange_id",
                                "fr_currency_id",
                                "lch_id"
                            }, new object[]
                            {
                                _last_id,
                                _obj.currency_id,
                                datam.LCH_ID
                            }, 2);
                        }
                        else
                        {
                            xd.SingleUpdateCommandALL("acc_foreign_currency_tb",
                                                      new string[]
                            {
                                "last_exchange_date",
                                "last_exchange_id",
                                "fr_currency_id",
                                "lch_id"
                            }, new object[]
                            {
                                null,
                                _last_id,
                                _obj.currency_id,
                                datam.LCH_ID
                            }, 2);
                        }
                        //
                        accn.ForeignCurrencyMVT(xd, datam.DATA_FOREIGN_CURRENCY[_obj.currency_id], 0, (_obj.exchanged_amount * -1), _obj.fs_date);
                        //
                        xd.CommitTransaction();
                        fGrid.Rows.RemoveAt(fGrid.Rows[_obj.un_id.ToString()].Index);
                    }

                    else
                    {
                        MessageBox.Show("This Record Has Already Been Deleted", "Delete Failure");
                    }
                }

                CheckForUpdates();
            }
        }