Ejemplo n.º 1
0
 /// <summary>
 /// Save Function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         DateValidation Objdatevalidation = new DateValidation();
         OtherDateValidationFunction ObjotherdateValidation = new OtherDateValidationFunction();
         Objdatevalidation.DateValidationFunction(txtVoucherDate);
         AccountLedgerSP SpAccountLedger = new AccountLedgerSP();
         SettingsSP spSettings = new SettingsSP();
         txtVoucherDate.Text = txtVoucherDate.Text.Trim();
         cmbvouchertype.Text = cmbvouchertype.Text.Trim();
         txtAmount.Text = txtAmount.Text.Trim();
         txtBank.Text = txtBank.Text.Trim();
         txtcheckdate.Text = txtcheckdate.Text.Trim();
         txtcheckNo.Text = txtcheckNo.Text.Trim();
         txtNarration.Text = txtNarration.Text.Trim();
         DataTable dtblMaster = new DataTable();
         PDCClearanceMasterSP sppdcClearance = new PDCClearanceMasterSP();
         PDCClearanceMasterInfo infoPdcclearance = new PDCClearanceMasterInfo();
         infoPdcclearance.SuffixPrefixId = decSufixprefixPdcpayableID;
         infoPdcclearance.FinancialYearId = Convert.ToDecimal(PublicVariables._decCurrentFinancialYearId.ToString());
         infoPdcclearance.VoucherNo = strVoucherNo;
         infoPdcclearance.InvoiceNo = txtvoucherNo.Text;
         if (txtVoucherDate.Text != string.Empty)
             infoPdcclearance.Date = Convert.ToDateTime(txtVoucherDate.Text);
         else
             infoPdcclearance.Date = DateTime.Now;
         infoPdcclearance.LedgerId = decimal.Parse(strledgerId.ToString());
         infoPdcclearance.AgainstId = decmasterId;
         infoPdcclearance.UserId = PublicVariables._decCurrentUserId;
         infoPdcclearance.VoucherTypeId = decPDCclearanceVoucherTypeId;
         infoPdcclearance.Status = cmbStatus.Text.ToString();
         infoPdcclearance.Type = cmbvouchertype.Text.ToString();
         infoPdcclearance.ExtraDate = DateTime.Now;
         infoPdcclearance.Narration = txtNarration.Text;
         infoPdcclearance.Extra1 = string.Empty;
         infoPdcclearance.Extra2 = string.Empty;
         if (!isInEditMode)
         {
             decimal decIdentity = sppdcClearance.PDCClearanceMasterAdd(infoPdcclearance);
             LedgerPostingAdd();
             if (cmbStatus.Text.ToString() == "Bounced")
             {
                 if (SpAccountLedger.AccountGroupIdCheck(txtAccountLedger.Text.ToString()))
                 {
                     PartyBalanceAddOrEdit();
                 }
             }
             Messages.SavedMessage();
             if (cbxPrint.Checked)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decIdentity);
                 }
                 else
                 {
                     Print(decIdentity);
                 }
             }
             ClearFunction();
         }
         else
         {
             decimal decIdentity = decPDCClearanceEditId;
             infoPdcclearance.PDCClearanceMasterId = decPDCClearanceEditId;
             sppdcClearance.PDCClearanceMasterEdit(infoPdcclearance);
             SpAccountLedger.LedgerPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decPDCclearanceVoucherTypeId);
             LedgerPostingAdd();
             SpAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPDCclearanceVoucherTypeId);
             if (cmbStatus.Text.ToString() == "Bounced")
             {
                 if (SpAccountLedger.AccountGroupIdCheck(txtAccountLedger.Text.ToString()))
                 {
                     PartyBalanceAddOrEdit();
                 }
             }
             Messages.UpdatedMessage();
             if (cbxPrint.Checked)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decIdentity);
                 }
                 else
                 {
                     Print(decIdentity);
                 }
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }