public DataTable SaveCreditVoucherCheque(DebitCreditVoucherBLL debitCreditVoucher, LumexDBPlayer db)
        {
            try
            {
                db.AddParameters("@ManualVoucherNumber", debitCreditVoucher.ManualVoucherNumber.Trim());
                db.AddParameters("@AccountId", debitCreditVoucher.AccountId.Trim());
                db.AddParameters("@CounterAccountId", debitCreditVoucher.CounterAccountId.Trim());
                db.AddParameters("@Amount", debitCreditVoucher.Amount.Trim());
                db.AddParameters("@Bank", debitCreditVoucher.Bank.Trim());
                db.AddParameters("@BankBranch", debitCreditVoucher.BankBranch.Trim());
                db.AddParameters("@ChequeNumber", debitCreditVoucher.ChequeNumber.Trim());
                db.AddParameters("@ChequeDate", debitCreditVoucher.ChequeDate.Trim());
                db.AddParameters("@PayToFromCompany", debitCreditVoucher.PayToFromCompany.Trim());
                db.AddParameters("@Narration", debitCreditVoucher.Narration.Trim());
                db.AddParameters("@OfficeBranchId", debitCreditVoucher.SalesCenterId);
                db.AddParameters("@CreatedBy", LumexSessionManager.Get("ActiveUserId").ToString());
                db.AddParameters("@CreatedFrom", LumexLibraryManager.GetTerminal());

                DataTable dt = db.ExecuteDataTable("INSERT_CREDIT_VOUCHER_CHEQUE", true);
                return dt;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                debitCreditVoucher = null;
            }
        }
        protected void updateButton_Click(object sender, EventArgs e)
        {
            DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();

            try
            {
                if (accountHeadDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Account Head field is required.";
                }
                else if (amountTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Amount field is required.";
                }
                else if (bankAccountHeadDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Bank Account Head field is required.";
                }
                else if (voucherNumberTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Voucher Number field is required.";
                }
                else if (chequeNumberTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Cheque Number field is required.";
                }
                else if (chequeDateTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Cheque Date field is required.";
                }
                else if (bankDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Bank Name field is required.";
                }
                else if (bankBranchTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Bank Branch Name field is required.";
                }
                else if (payToFromCompanyDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Pay To/From Company field is required.";
                }
                else if (narrationTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Narration field is required.";
                }
                else
                {
                    debitCreditVoucher.JournalNumber = journalNumberForUpdateHiddenField.Value;
                    debitCreditVoucher.ManualVoucherNumber = voucherNumberTextBox.Text.Trim();
                    debitCreditVoucher.AccountId = accountHeadDropDownList.SelectedValue.Trim();
                    debitCreditVoucher.CounterAccountId = bankAccountHeadDropDownList.SelectedValue.Trim();
                    debitCreditVoucher.Amount = amountTextBox.Text.Trim();
                    debitCreditVoucher.Bank = bankDropDownList.SelectedValue.Trim();
                    debitCreditVoucher.BankBranch = bankBranchTextBox.Text.Trim();
                    debitCreditVoucher.ChequeNumber = chequeNumberTextBox.Text.Trim();
                    debitCreditVoucher.ChequeDate = LumexLibraryManager.ParseAppDate(chequeDateTextBox.Text.Trim());
                    debitCreditVoucher.PayToFromCompany = payToFromCompanyDropDownList.SelectedValue.Trim();
                    debitCreditVoucher.Narration = narrationTextBox.Text.Trim();

                    debitCreditVoucher.UpdateCreditVoucherCheque();

                    string message = "Credit Voucher Cheque <span class='actionTopic'>Updated</span> Successfully.";
                    MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/AccUI/CreditVoucher/CreditVoucherChequeList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                debitCreditVoucher = null;
            }
        }
        protected void GetCreditVoucherChequeByJournal(string journalNumber)
        {
            DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();

            try
            {
                DataTable dt = debitCreditVoucher.GetCreditVoucherApprovalByJournal("Cheque", journalNumber);

                if (dt.Rows.Count > 0)
                {
                    voucherNumberTextBox.Text = dt.Rows[0]["ManualVoucherNumber"].ToString();
                    accountHeadDropDownList.SelectedValue = dt.Rows[0]["AccountId"].ToString();
                    bankAccountHeadDropDownList.SelectedValue = dt.Rows[0]["CounterAccountId"].ToString();
                    amountTextBox.Text = dt.Rows[0]["Amount"].ToString();
                    bankDropDownList.SelectedValue = dt.Rows[0]["Bank"].ToString();
                    bankBranchTextBox.Text = dt.Rows[0]["BankBranch"].ToString();
                    chequeNumberTextBox.Text = dt.Rows[0]["ChequeNumber"].ToString();
                    chequeDateTextBox.Text = LumexLibraryManager.GetAppDateView(dt.Rows[0]["ChequeDate"].ToString());
                    payToFromCompanyDropDownList.SelectedValue = dt.Rows[0]["PayToFromCompany"].ToString();
                    narrationTextBox.Text = dt.Rows[0]["Narration"].ToString();
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Credit Voucher Cheque Data Not Found!!!"; msgDetailLabel.Text = "";
                    msgbox.Attributes.Add("class", "alert alert-warning");
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                debitCreditVoucher = null;
            }
        }
        protected void rejectLinkButton_Click(object sender, EventArgs e)
        {
            DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();

            try
            {
                debitCreditVoucher.RejectDebitCreditJournalVoucherByJournal(journalNumberForApproveHiddenField.Value.Trim());

                GetApprovalList();
                string message = "Debit Voucher Cheque <span class='actionTopic'>Rejected</span> Successfully.";
                MyAlertBox("SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", \"\");");
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                debitCreditVoucher = null;
                MyAlertBox("MyOverlayStop();");
            }
        }
        protected void rejectButton_Click(object sender, EventArgs e)
        {
            DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();
            CheckBox selectCheckBox;
            int count = 0;

            try
            {
                for (int i = 0; i < voucherListGridView.Rows.Count; i++)
                {
                    selectCheckBox = (CheckBox)voucherListGridView.Rows[i].Cells[5].FindControl("selectCheckBox");

                    if (selectCheckBox.Checked)
                    {
                        debitCreditVoucher.RejectDebitCreditJournalVoucherByJournal(voucherListGridView.Rows[i].Cells[0].Text.Trim());
                        count++;
                    }
                }

                if (count > 0)
                {
                    GetApprovalList();
                    string message = count.ToString() + " Debit Voucher Cheque(s) <span class='actionTopic'>Rejected</span> Successfully.";
                    MyAlertBox("SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", \"\");");
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "No Voucher(s) are selected to Reject.";
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                debitCreditVoucher = null;
                MyAlertBox("MyOverlayStop();");
            }
        }
        public static string GetDebitVoucherViewByJournal(string journalNumber)
        {
            try
            {
                DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();

                string json = JsonConvert.SerializeObject(debitCreditVoucher.GetDebitVoucherApprovalByJournal("Cheque", journalNumber));
                json = json.Substring(1, json.Length - 2);

                return json;
            }
            catch (Exception)
            {
                throw;
            }
        }
        protected void GetApprovalList()
        {
            DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();

            try
            {
                string fromDate = LumexLibraryManager.ParseAppDate("");
                string toDate = LumexLibraryManager.ParseAppDate("");

                DataTable dt = debitCreditVoucher.GetDebitVoucherApprovalListByDateRangeAndAll(drpdwnSalesCenterOrWarehouse.SelectedValue, fromDate, toDate, "Cheque", "All");

                voucherListGridView.DataSource = dt;
                voucherListGridView.DataBind();

                if (voucherListGridView.Rows.Count > 0)
                {
                    voucherListGridView.UseAccessibleHeader = true;
                    voucherListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;

                    approveButton.Enabled = true;
                    rejectButton.Enabled = true;
                }
                else
                {
                    approveButton.Enabled = false;
                    rejectButton.Enabled = false;

                    msgbox.Visible = true; msgTitleLabel.Text = "Debit Voucher Cheque Approval List Data Not Found!!!"; msgDetailLabel.Text = "";
                    msgbox.Attributes.Add("class", "alert alert-warning");
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                debitCreditVoucher = null;
            }
        }
        protected void voucherListButton_Click(object sender, EventArgs e)
        {
            DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();

            try
            {
                if (fromDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim()) == "False")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date From field is required.";
                }
                else if (toDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim()) == "False")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date To field is required.";
                }
                else
                {
                    string fromDate = LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim());
                    string toDate = LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim());

                    DataTable dt = debitCreditVoucher.GetDebitVoucherApprovalListByDateRangeAndAll(drpdwnSalesCenterOrWarehouse.SelectedValue, fromDate, toDate, "Cheque", "");

                    voucherListGridView.DataSource = dt;
                    voucherListGridView.DataBind();

                    if (voucherListGridView.Rows.Count > 0)
                    {
                        voucherListGridView.UseAccessibleHeader = true;
                        voucherListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                    }
                    else
                    {
                        msgbox.Visible = true; msgTitleLabel.Text = "Debit Voucher Cheque List Data Not Found!!!"; msgDetailLabel.Text = "";
                        msgbox.Attributes.Add("class", "alert alert-info");
                    }
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                debitCreditVoucher = null;
                MyAlertBox("MyOverlayStop();");
            }
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();
            Button btn = (Button)sender;
            string cmdarg = btn.CommandArgument;

            try
            {
                if (accountHeadDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Account Head field is required.";
                }
                else if (amountTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Amount field is required.";
                }
                else if (cashAccountHeadDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Cash Account Head field is required.";
                }
                else if (voucherNumberTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Voucher Number field is required.";
                }
                else if (payToFromCompanyDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Pay To/From Company field is required.";
                }
                else if (narrationTextBox.Text.Trim() == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Narration field is required.";
                }
                else
                {
                    debitCreditVoucher.ManualVoucherNumber = voucherNumberTextBox.Text.Trim();
                    debitCreditVoucher.AccountId = accountHeadDropDownList.SelectedValue.Trim();
                    debitCreditVoucher.CounterAccountId = cashAccountHeadDropDownList.SelectedValue.Trim();
                    debitCreditVoucher.Amount = amountTextBox.Text.Trim();
                    debitCreditVoucher.PayToFromCompany = payToFromCompanyDropDownList.SelectedValue.Trim();
                    debitCreditVoucher.Narration = narrationTextBox.Text.Trim();
                    debitCreditVoucher.SalesCenterId = drpdwnSalesCenterOrWarehouse.SelectedValue;

                    DataTable dt = debitCreditVoucher.SaveDebitVoucherCash();

                    if (dt.Rows.Count > 0)
                    {
                        if (cmdarg == "2")
                        {
                            IPOSReportBLL iposReport = new IPOSReportBLL();
                            iposReport.GetCreditOrDebitVoucherByVoucherId(dt.Rows[0][0].ToString(), debitCreditVoucher.SalesCenterId.ToString(),cmdarg);
                            ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "ViewReportForm();", true);
                        }
                        

                        string message = "Debit Voucher Cash <span class='actionTopic'>Created</span> Successfully with Voucher Number: <span class='actionTopic'>" + dt.Rows[0][0].ToString() + "</span>.";
                        MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/AccUI/DebitVoucher/DebitVoucherCashList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                    }
                    else
                    {
                        string message = "<span class='actionTopic'>Failed</span> to Create Debit Voucher Cash.";
                        MyAlertBox("ErrorAlert(\"" + "Process Failed" + "\", \"" + message + "\");");
                    }

                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                debitCreditVoucher = null;
            }
        }
        protected void rejectButton_Click(object sender, EventArgs e)
        {
            DebitCreditVoucherBLL debitCreditVoucher = new DebitCreditVoucherBLL();

            try
            {
                debitCreditVoucher.RejectDebitCreditJournalVoucherByJournal(numberLabel.Text.Trim());

                string message = "Journal Voucher <span class='actionTopic'>Rejected</span> Successfully.";
                MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/AccUI/JournalVoucher/JournalVoucherApprovalList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                debitCreditVoucher = null;
            }
        }
예제 #11
0
        public void UpdateDebitVoucherCash(DebitCreditVoucherBLL debitCreditVoucher, LumexDBPlayer db)
        {
            try
            {
                db.AddParameters("@JournalNumber", debitCreditVoucher.JournalNumber.Trim());
                db.AddParameters("@ManualVoucherNumber", debitCreditVoucher.ManualVoucherNumber.Trim());
                db.AddParameters("@AccountId", debitCreditVoucher.AccountId.Trim());
                db.AddParameters("@CounterAccountId", debitCreditVoucher.CounterAccountId.Trim());
                db.AddParameters("@Amount", debitCreditVoucher.Amount.Trim());
                db.AddParameters("@PayToFromCompany", debitCreditVoucher.PayToFromCompany.Trim());
                db.AddParameters("@Narration", debitCreditVoucher.Narration.Trim());
                db.AddParameters("@OfficeBranchId", LumexSessionManager.Get("UserSalesCenterId").ToString());
                db.AddParameters("@ModifiedBy", LumexSessionManager.Get("ActiveUserId").ToString());
                db.AddParameters("@ModifiedFrom", LumexLibraryManager.GetTerminal());

                db.ExecuteNonQuery("UPDATE_DEBIT_VOUCHER_CASH", true);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                debitCreditVoucher = null;
            }
        }