Exemplo n.º 1
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo();
         AccountLedgerSP spAccountLedger = new AccountLedgerSP();
         infoAccountLedger.AccountGroupId = 26;
         infoAccountLedger.LedgerName = txtCustomerName.Text.Trim();
         if (txtOpeningBalance.Text.Trim() != string.Empty)
         {
             infoAccountLedger.OpeningBalance = Convert.ToDecimal(txtOpeningBalance.Text.Trim());
             decOpeningBlnc = infoAccountLedger.OpeningBalance;
         }
         else
         {
             infoAccountLedger.OpeningBalance = 0;
         }
         infoAccountLedger.CrOrDr = cmbDrorCr.Text;
         infoAccountLedger.BankAccountNumber = txtAccountNo.Text.Trim();
         infoAccountLedger.BranchName = txtBranchName.Text.Trim();
         infoAccountLedger.BranchCode = txtBranchCode.Text.Trim();
         infoAccountLedger.Mobile = txtMobile.Text.Trim();
         infoAccountLedger.Address = txtAddress.Text.Trim();
         if (cmbBillbyBill.Text == "Yes")
         {
             infoAccountLedger.BillByBill = true;
         }
         else
         {
             infoAccountLedger.BillByBill = false;
         }
         if (txtCreditLimit.Text.Trim() != string.Empty)
         {
             infoAccountLedger.CreditLimit = Convert.ToDecimal(txtCreditLimit.Text.ToString());
         }
         else
         {
             infoAccountLedger.CreditLimit = 0;
         }
         if (txtCreditPeriod.Text.Trim() != string.Empty)
         {
             infoAccountLedger.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.ToString());
         }
         else
         {
             infoAccountLedger.CreditPeriod = 0;
         }
         infoAccountLedger.Cst = txtCST.Text.Trim();
         if (Convert.ToDecimal(cmbArea.SelectedValue.ToString()) != 0)
         {
             infoAccountLedger.AreaId = Convert.ToDecimal(cmbArea.SelectedValue.ToString());
         }
         else
         {
             infoAccountLedger.AreaId = 1m;
         }
         if (Convert.ToDecimal(cmbRoute.SelectedValue.ToString()) != 0)
         {
             infoAccountLedger.RouteId = Convert.ToDecimal(cmbRoute.SelectedValue.ToString());
         }
         else
         {
             infoAccountLedger.RouteId = 1m;
         }
         infoAccountLedger.MailingName = txtMailingName.Text.Trim();
         infoAccountLedger.Phone = txtphone.Text.Trim();
         infoAccountLedger.Email = txtEmail.Text.Trim();
         infoAccountLedger.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
         infoAccountLedger.Tin = txtTin.Text.Trim();
         infoAccountLedger.Pan = txtPan.Text.Trim();
         infoAccountLedger.Narration = txtNarration.Text.Trim();
         infoAccountLedger.IsDefault = false;
         infoAccountLedger.Extra1 = string.Empty;
         infoAccountLedger.Extra2 = string.Empty;
         if (spAccountLedger.AccountLedgerCheckExistenceForCustomer(txtCustomerName.Text.Trim(), 0) == false)
         {
             decledgerid = spAccountLedger.AccountLedgerAddForCustomer(infoAccountLedger);
             if (decOpeningBlnc > 0)
             {
                 ledgerPosting();
                 if (cmbBillbyBill.Text == "Yes")
                 {
                     partyBalance();
                 }
             }
             Messages.SavedMessage();
             Clear();
         }
         else
         {
             Messages.InformationMessage("Ledger name already exist");
             txtCustomerName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Cus6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }