コード例 #1
0
        /// <summary>
        /// Save data to the database
        /// </summary>
        public void SaveFunction()
        {
            try
            {
                int inRowcount = dgvMultipleAccountLedger.RowCount;//edited by Runali
                int inRowcountDec = (dgvMultipleAccountLedger.RowCount) - 1;
                decimal decOpeningBalance = 0;
                decimal decLedgerId = 0;
                bool isSave = false;
                AccountLedgerInfo infoAccountledger = new AccountLedgerInfo();
                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo();
                FinancialYearBll BllFinancialYear = new FinancialYearBll();
                FinancialYearInfo infoFinancialYear = new FinancialYearInfo();

                for (int i = 0; i < inRowcount - 1; i++)
                {
                    infoAccountledger.AccountGroupId = Convert.ToDecimal(cmbAccountGroup.SelectedValue.ToString());

                    infoAccountledger.LedgerName = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtLedgerName"].Value.ToString();
                    if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null)
                    {
                        infoAccountledger.OpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString());
                    }
                    else
                    {
                        infoAccountledger.OpeningBalance = 0;
                    }
                    infoAccountledger.CrOrDr = dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString();

                    if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value != null)
                    {
                        infoAccountledger.Narration = dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtNarration"].Value.ToString();
                    }
                    else
                    {
                        infoAccountledger.Narration = string.Empty;
                    }
                    infoAccountledger.MailingName = string.Empty;
                    infoAccountledger.Address = string.Empty;
                    infoAccountledger.State = string.Empty;
                    infoAccountledger.Phone = string.Empty;
                    infoAccountledger.Mobile = string.Empty;
                    infoAccountledger.Email = string.Empty;
                    infoAccountledger.CreditPeriod = 0;
                    infoAccountledger.CreditLimit = 0;
                    infoAccountledger.PricinglevelId = 0;
                    infoAccountledger.BillByBill = false;
                    infoAccountledger.Tin = string.Empty;
                    infoAccountledger.Cst = string.Empty;
                    infoAccountledger.Pan = string.Empty;
                    infoAccountledger.RouteId = 0;
                    infoAccountledger.BankAccountNumber = string.Empty;
                    infoAccountledger.BranchName = string.Empty;
                    infoAccountledger.BranchCode = string.Empty;
                    infoAccountledger.Extra1 = string.Empty;
                    infoAccountledger.Extra2 = string.Empty;
                    infoAccountledger.AreaId = 0;
                    infoAccountledger.IsDefault = false;
                    infoAccountledger.ExtraDate = PublicVariables._dtCurrentDate;
                    decLedgerId = bllAccountLedger.AccountLedgerAddWithIdentity(infoAccountledger);

                    if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value != null && dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != "0")
                    {
                        if (dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString() != string.Empty)
                        {
                            string strfinancialId;
                            decOpeningBalance = Convert.ToDecimal(dgvMultipleAccountLedger.Rows[i].Cells["dgvtxtOpeningBalance"].Value.ToString());
                            infoFinancialYear = BllFinancialYear.FinancialYearViewForAccountLedger(1);
                            strfinancialId = infoFinancialYear.FromDate.ToString("dd-MMM-yyyy");
                            infoLedgerPosting.VoucherTypeId = 1;
                            infoLedgerPosting.Date = Convert.ToDateTime(strfinancialId.ToString());
                            infoLedgerPosting.LedgerId = decLedgerId;
                            infoLedgerPosting.VoucherNo = decLedgerId.ToString();
                            if (dgvMultipleAccountLedger.Rows[i].Cells["dgvcmbDebitOrCredit"].Value.ToString() == "Dr")
                            {
                                infoLedgerPosting.Debit = decOpeningBalance;
                            }
                            else
                            {
                                infoLedgerPosting.Credit = decOpeningBalance;
                            }
                            infoLedgerPosting.DetailsId = 0;
                            infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId;
                            infoLedgerPosting.InvoiceNo = decLedgerId.ToString();

                            infoLedgerPosting.ChequeNo = string.Empty;
                            infoLedgerPosting.ChequeDate = DateTime.Now;

                            infoLedgerPosting.Extra1 = string.Empty;
                            infoLedgerPosting.Extra2 = string.Empty;
                            BllLedgerPosting.LedgerPostingAdd(infoLedgerPosting);

                        }

                    }
                    isSave = true;
                }
                if (isSave)
                {
                    Messages.SavedMessage();
                    cmbAccountGroup.Focus();
                    cmbAccountGroup.SelectedIndex = -1;
                    dgvMultipleAccountLedger.Rows.Clear();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("MAL6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #2
0
        /// <summary>
        /// Creating one ledger for the purticular tax
        /// </summary>
        public void CreateLedger()
        {
            try
            {
                AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                infoAccountLedger.AccountGroupId = 20;
                infoAccountLedger.LedgerName = txtTaxName.Text;
                infoAccountLedger.OpeningBalance = 0;
                infoAccountLedger.IsDefault = false;
                infoAccountLedger.CrOrDr = "Cr";
                infoAccountLedger.Narration = string.Empty;
                infoAccountLedger.MailingName = txtTaxName.Text;
                infoAccountLedger.Address = string.Empty;
                infoAccountLedger.Phone = string.Empty;
                infoAccountLedger.Mobile = string.Empty;
                infoAccountLedger.Email = string.Empty;
                infoAccountLedger.CreditPeriod = 0;
                infoAccountLedger.CreditLimit = 0;
                infoAccountLedger.PricinglevelId = 0;
                infoAccountLedger.BillByBill = false;
                infoAccountLedger.Tin = string.Empty;
                infoAccountLedger.Cst = string.Empty;
                infoAccountLedger.Pan = string.Empty;
                infoAccountLedger.RouteId = 1;
                infoAccountLedger.BankAccountNumber = string.Empty;
                infoAccountLedger.BranchName = string.Empty;
                infoAccountLedger.BranchCode = string.Empty;
                infoAccountLedger.ExtraDate = DateTime.Now;
                infoAccountLedger.Extra1 = string.Empty;
                infoAccountLedger.Extra2 = string.Empty;
                infoAccountLedger.AreaId = 1;
                bllAccountLedger.AccountLedgerAddWithIdentity(infoAccountLedger);

            }
            catch (Exception ex)
            {
                MessageBox.Show("TAX:12" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
コード例 #3
0
 /// <summary>
 /// Function to save account ledger
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         infoAccountLedger.LedgerName = txtLedgerName.Text.Trim();
         infoAccountLedger.AccountGroupId = Convert.ToDecimal(cmbGroup.SelectedValue.ToString());
         decOpeningBalance = Convert.ToDecimal(((txtOpeningBalance.Text == "") ? "0" : txtOpeningBalance.Text.Trim()));
         infoAccountLedger.OpeningBalance = decOpeningBalance;
         infoAccountLedger.CrOrDr = cmbOpeningBalanceCrOrDr.Text.Trim();
         infoAccountLedger.Narration = txtNarration.Text.Trim();
         infoAccountLedger.IsDefault = false;
         if (isBankAccount)
         {
             infoAccountLedger.BankAccountNumber = txtAcNo.Text.Trim();
             infoAccountLedger.BranchName = txtBranchName.Text.Trim();
             infoAccountLedger.BranchCode = txtBranchCode.Text.Trim();
         }
         else
         {
             if (isSundryDebtorOrCreditor)
             {
                 infoAccountLedger.BankAccountNumber = txtAccountNo.Text;
                 infoAccountLedger.BranchName = string.Empty;
                 infoAccountLedger.BranchCode = string.Empty;
             }
             else
             {
                 infoAccountLedger.BankAccountNumber = string.Empty;
                 infoAccountLedger.BranchName = string.Empty;
                 infoAccountLedger.BranchCode = string.Empty;
             }
         }
         if (isSundryDebtorOrCreditor)
         {
             infoAccountLedger.MailingName = txtMailingName.Text.Trim();
             infoAccountLedger.BankAccountNumber = txtAccountNo.Text.Trim();
             infoAccountLedger.Address = txtAddress.Text.Trim();
             infoAccountLedger.Phone = txtPhone.Text.Trim();
             infoAccountLedger.Mobile = txtMobile.Text.Trim();
             infoAccountLedger.Email = txtEmail.Text.Trim();
             infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim());
             infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.Trim());
             if (cmbPricingLevel.SelectedIndex <= 0)
             {
                 infoAccountLedger.PricinglevelId = 1;
             }
             else
             {
                 infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
             }
             if (cmbBillByBill.Text == "Yes")
             {
                 infoAccountLedger.BillByBill = true;
             }
             else
             {
                 infoAccountLedger.BillByBill = false;
             }
             infoAccountLedger.Tin = txtTin.Text.Trim();
             infoAccountLedger.Cst = txtCst.Text.Trim();
             infoAccountLedger.Pan = txtPan.Text.Trim();
             if (cmbArea.SelectedIndex <= 0)
             {
                 infoAccountLedger.AreaId = 1;
             }
             else
             {
                 infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString());
             }
             if (cmbRoute.SelectedIndex < 0)
             {
                 infoAccountLedger.RouteId = 1;
             }
             else
             {
                 infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString());
             }
             infoAccountLedger.Extra1 = string.Empty;
             infoAccountLedger.Extra2 = string.Empty;
             infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate;
         }
         else
         {
             infoAccountLedger.MailingName = string.Empty;
             infoAccountLedger.BankAccountNumber = string.Empty;
             infoAccountLedger.Address = string.Empty;
             infoAccountLedger.State = string.Empty;
             infoAccountLedger.Phone = string.Empty;
             infoAccountLedger.Mobile = string.Empty;
             infoAccountLedger.Email = string.Empty;
             infoAccountLedger.CreditPeriod = 0;
             infoAccountLedger.CreditLimit = 0;
             infoAccountLedger.PricinglevelId = 0;
             infoAccountLedger.BillByBill = false;
             infoAccountLedger.Tin = string.Empty;
             infoAccountLedger.Cst = string.Empty;
             infoAccountLedger.Pan = string.Empty;
             infoAccountLedger.RouteId = 1;
             infoAccountLedger.AreaId = 1;
             infoAccountLedger.Extra1 = string.Empty;
             infoAccountLedger.Extra2 = string.Empty;
             infoAccountLedger.ExtraDate = PublicVariables._dtCurrentDate;
         }
         if (bllAccountLedger.AccountLedgerCheckExistence(txtLedgerName.Text.Trim().ToString(), 0) == false)
         {
             decLedgerId = bllAccountLedger.AccountLedgerAddWithIdentity(infoAccountLedger);
             if (decOpeningBalance > 0)
             {
                 LedgerPostingAdd();
                 if (cmbBillByBill.Text == "Yes" && isSundryDebtorOrCreditor)
                 {
                     PartyBalanceAdd();
                 }
             }
             Messages.SavedMessage();
             Clear();
             decIdForOtherForms = decLedgerId;
             if (frmRejectionInObj != null)
             {
                 this.Close();
             }
             if (frmMaterialReceptObj != null)
             {
                 this.Close();
             }
             if (frmPurchaseInvoiceObj != null)
             {
                 this.Close();
             }
             if (frmContraVoucherObj != null)
             {
                 this.Close();
             }
             if (frmPaymentVoucherObj != null)
             {
                 this.Close();
             }
             if (frmReceiptVoucherObj != null)
             {
                 this.Close();
             }
             if (frmDailysalaryvoucherobj != null)
             {
                 this.Close();
             }
             /*------------------For ReceiptVoucher--------------------*/
             if (frmReceiptVoucherObj != null)
             {
                 this.Close();
             }
             if (frmPurchaseOrderObj != null)
             {
                 this.Close();
             }
             /*----------For journal voucher------------*/
             if (frmJournalVoucherObj != null)
             {
                 this.Close();
             }
             /*----------For Debitnote voucher-----------*/
             if (frmDebitNoteObj != null)
             {
                 this.Close();
             }
             /*----------For Creditnote voucher-----------*/
             if (frmCreditNoteObj != null)
             {
                 this.Close();
             }
             if (frmSalesReturnObj != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
             if (frmSalesInvoiceObj != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
             if (frmSalesQuotationObj != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
             if (frmSalesOrderObj != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
             /*----------   For Pdcpayable voucher-----------*/
             if (frmPdcpayableObj != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
             if (frmPdcpayableObj2 != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
             /*---------- Coded For PdcReceivable voucher-----------*/
             if (frmpdcreceivableObj != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
             if (frmpdcreceivableObj2 != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
             /*.................end.......................*/
             if (frmPOSObj != null)
             {
                 if (decIdForOtherForms != 0)
                 {
                     this.Close();
                 }
             }
         }
         else
         {
             Messages.InformationMessage("Ledger name already exist");
             txtLedgerName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AL1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }