protected void GetJournalVoucherEntryListByJournalNumber(string journalNumber)
        {
            JournalVoucherBLL journalVoucher = new JournalVoucherBLL();

            try
            {
                DataTable dt = journalVoucher.GetJournalVoucherEntryListByJournal(journalNumber);

                if (dt.Rows.Count > 0)
                {
                    transactionDateLabel.Text = dt.Rows[0]["TransactionDate"].ToString();
                    autoVoucherNumberLabel.Text = dt.Rows[0]["AutoVoucherNumber"].ToString() + " - T" + dt.Rows.Count.ToString();
                    voucherStatusLabel.Text = dt.Rows[0]["Status"].ToString();
                    totalEntryLabel.Text = dt.Rows.Count.ToString();

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

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

                    CalculateTotalDebitCreditAmount(dt);
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Journal Voucher Entry 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
            {
                journalVoucher = null;
            }
        }
Exemplo n.º 2
0
        public void UpdateJournalVoucherEntryByJournalAndTransactionNumber(JournalVoucherBLL journalVoucher, LumexDBPlayer db)
        {
            try
            {
                db.AddParameters("@JournalNumber", journalVoucher.JournalNumber.Trim());
                db.AddParameters("@TransactionNumber", journalVoucher.TransactionNumber.Trim());
                db.AddParameters("@Description", journalVoucher.Description.Trim());
                db.AddParameters("@ManualVoucherNumber", journalVoucher.ManualVoucherNumber.Trim());
                db.AddParameters("@AccountId", journalVoucher.AccountId.Trim());
                db.AddParameters("@DebitCredit", journalVoucher.DebitCredit.Trim());
                db.AddParameters("@Amount", journalVoucher.Amount.Trim());
                db.AddParameters("@Bank", journalVoucher.Bank.Trim());
                db.AddParameters("@BankBranch", journalVoucher.BankBranch.Trim());
                db.AddParameters("@ChequeNumber", journalVoucher.ChequeNumber.Trim());
                db.AddParameters("@ChequeDate", journalVoucher.ChequeDate.Trim());
                db.AddParameters("@PayToFromCompany", journalVoucher.PayToFromCompany.Trim());
                db.AddParameters("@Narration", journalVoucher.Narration.Trim());
                db.AddParameters("@ModifiedBy", LumexSessionManager.Get("ActiveUserId").ToString());
                db.AddParameters("@ModifiedFrom", LumexLibraryManager.GetTerminal());

                db.ExecuteNonQuery("UPDATE_JOURNAL_VOUCHER_ENTRY", true);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                journalVoucher = null;
            }
        }
        protected void GetAllVoucherList()
        {
            JournalVoucherBLL journalVoucher = new JournalVoucherBLL();

            try
            {
                string fromDate = LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim());
                string toDate = LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim());

                DataTable dt = journalVoucher.GetJournalVoucherListByDateRangeAndAll(drpdwnSalesCenterOrWarehouse.SelectedValue, fromDate, toDate, "All");

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

                if (voucherListGridView.Rows.Count > 0)
                {
                    voucherListGridView.UseAccessibleHeader = true;
                    voucherListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Journal Voucher 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
            {
                journalVoucher = null;
                MyAlertBox("MyOverlayStop();");
            }
        }
        protected void saveChangesButton_Click(object sender, EventArgs e)
        {
            JournalVoucherBLL journalVoucher = new JournalVoucherBLL();

            try
            {
                if (drAmtLabel.Text == crAmtLabel.Text && voucherStatusLabel.Text == "Update Pending")
                {
                    journalVoucher.UpdateJournalVoucherUpdateStatusByJournal(numberLabel.Text.Trim());

                    string message = "Journal Voucher Changes <span class='actionTopic'>Saved</span> Successfully.";
                    MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/AccUI/JournalVoucher/JournalVoucherList.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
            {
                journalVoucher = null;
            }
        }
        protected void updateButton_Click(object sender, EventArgs e)
        {
            JournalVoucherBLL journalVoucher = new JournalVoucherBLL();

            try
            {
                if (accountHeadDropDownList.SelectedValue == "")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "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
                {
                    journalVoucher.JournalNumber = journalNumberForUpdateHiddenField.Value.Trim();
                    journalVoucher.TransactionNumber = transactionNumberForUpdateHiddenField.Value.Trim();
                    journalVoucher.Description = descriptionForUpdateHiddenField.Value.Trim();
                    journalVoucher.ManualVoucherNumber = voucherNumberTextBox.Text.Trim();
                    journalVoucher.AccountId = accountHeadDropDownList.SelectedValue.Trim();
                    journalVoucher.DebitCredit = debitCreditDropDownList.SelectedValue.Trim();
                    journalVoucher.Amount = amountTextBox.Text.Trim();
                    journalVoucher.Bank = bankDropDownList.SelectedValue.Trim();
                    journalVoucher.BankBranch = bankBranchTextBox.Text.Trim();
                    journalVoucher.ChequeNumber = chequeNumberTextBox.Text.Trim();
                    journalVoucher.ChequeDate = LumexLibraryManager.ParseAppDate(chequeDateTextBox.Text.Trim());
                    journalVoucher.PayToFromCompany = payToFromCompanyDropDownList.SelectedValue.Trim();
                    journalVoucher.Narration = narrationTextBox.Text.Trim();

                    journalVoucher.UpdateJournalVoucherEntryByJournalAndTransactionNumber();

                    GetJournalVoucherEntryListByJournalNumber(numberLabel.Text.Trim());
                    string message = "Journal Voucher Entry <span class='actionTopic'>Updated</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
            {
                journalVoucher = null;
            }
        }
        public static string GetJournalEntryViewByJournalAndTransactionNumber(string SN, string journalNumber)
        {
            try
            {
                JournalVoucherBLL journalVoucher = new JournalVoucherBLL();

                DataTable dt = journalVoucher.GetJournalVoucherEntryByJournalAndTransactionNumber(journalNumber, SN);

                string json = JsonConvert.SerializeObject(dt);
                json = json.Substring(1, json.Length - 2);

                return json;
            }
            catch (Exception)
            {
                throw;
            }
        }
        protected void approveButton_Click(object sender, EventArgs e)
        {
            JournalVoucherBLL journalVoucher = new JournalVoucherBLL();
            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)
                    {
                        journalVoucher.ApproveJournalVoucherByJournal(voucherListGridView.Rows[i].Cells[0].Text.Trim());
                        count++;
                    }
                }

                if (count > 0)
                {
                    GetApprovalList();
                    string message = count.ToString() + " Journal Voucher(s) <span class='actionTopic'>Approved</span> Successfully.";
                    MyAlertBox("SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", \"\");");
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "No Voucher(s) are selected to Approve.";
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                journalVoucher = null;
                MyAlertBox("MyOverlayStop();");
            }
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            JournalVoucherBLL journalVoucher = new JournalVoucherBLL();
            payToFromCompanyDropDownList.Enabled = false;
            //payToFromTypeDropDownList.Enabled = false;
            //payToFromCompanyDropDownList.CausesValidation = false;


            try
            {
                DataTable dtJournalList = (DataTable)LumexSessionManager.Get("dtJournalList");

                if (decimal.Parse(drAmtLabel.Text.Trim()) != decimal.Parse(crAmtLabel.Text.Trim()))
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Total Debit & Credit Amount must be Same.";
                }
                else if (journalEntryListGridView.Rows.Count != dtJournalList.Rows.Count)
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Total Journal Entry Mismatch.";
                }
                else
                {
                    DataTable dt = journalVoucher.SaveJournalVoucher(drpdwnSalesCenterOrWarehouse.SelectedValue, dtJournalList);

                    if (dt.Rows.Count > 0)
                    {
                        LumexSessionManager.Remove("dtJournalList");
                        string message = "Journal Voucher <span class='actionTopic'>Created</span> Successfully with Journal Number: <span class='actionTopic'>" + dt.Rows[0][0].ToString() + "</span>.";
                        MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/AccUI/JournalVoucher/JournalVoucherList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                    }
                    else
                    {
                        string message = "<span class='actionTopic'>Failed</span> to Create Journal Voucher.";
                        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
            {
                journalVoucher = null;
            }
        }
        protected void approveButton_Click(object sender, EventArgs e)
        {
            JournalVoucherBLL journalVoucher = new JournalVoucherBLL();

            try
            {
                if (drAmtLabel.Text.Trim() == crAmtLabel.Text.Trim())
                {
                    journalVoucher.ApproveJournalVoucherByJournal(numberLabel.Text.Trim());

                    string message = "Journal Voucher <span class='actionTopic'>Approved</span> Successfully.";
                    MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/AccUI/JournalVoucher/JournalVoucherApprovalList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Total Debit & Credit Amount must be Same.";
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                if (ex.InnerException != null) { message += " --> " + ex.InnerException.Message; }
                MyAlertBox("ErrorAlert(\"" + ex.GetType() + "\", \"" + message + "\", \"\");");
            }
            finally
            {
                journalVoucher = null;
            }
        }