Exemplo n.º 1
0
 /// <summary>
 /// Save function
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         SettingsSP spSettings = new SettingsSP();
         DateValidation Objdatevalidation = new DateValidation();
         OtherDateValidationFunction ObjotherdateValidation = new OtherDateValidationFunction();
         AccountLedgerSP spAccountLedger = new AccountLedgerSP();
         PartyBalanceSP spPartyBalance = new PartyBalanceSP();
         Objdatevalidation.DateValidationFunction(txtVoucherDate);
         ObjotherdateValidation.DateValidationFunction(txtChequeDate, false);
         DataTable dtblMaster = new DataTable();
         PDCPayableMasterInfo InfoPayable = new PDCPayableMasterInfo();
         PDCPayableMasterSP SpPayable = new PDCPayableMasterSP();
         InfoPayable.VoucherNo = strVoucherNo;
         InfoPayable.InvoiceNo = txtvoucherNo.Text.Trim();
         InfoPayable.Date = DateTime.Parse(txtVoucherDate.Text);
         InfoPayable.LedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString());
         InfoPayable.Amount = decimal.Parse(txtAmount.Text);
         InfoPayable.Narration = txtNarration.Text;
         InfoPayable.ChequeNo = txtcheckNo.Text;
         if (txtChequeDate.Text != string.Empty)
             InfoPayable.ChequeDate = Convert.ToDateTime(txtChequeDate.Text);
         else
             InfoPayable.ChequeDate = DateTime.Now;
         InfoPayable.UserId = PublicVariables._decCurrentUserId;
         InfoPayable.VoucherTypeId = decPDCpayableVoucherTypeId;
         if (cmbBank.SelectedValue != null && cmbBank.SelectedValue.ToString() != string.Empty)
         {
             InfoPayable.BankId = Convert.ToDecimal(cmbBank.SelectedValue.ToString());
         }
         else
             InfoPayable.ExtraDate = DateTime.Now;
         InfoPayable.Extra1 = string.Empty;
         InfoPayable.Extra2 = string.Empty;
         if (!isInEditMode)
         {
             decimal decIdentity = SpPayable.PDCPayableMasterAdd(InfoPayable);
             LedgerPosting();
             PartyBalanceAddOrEdit();
             Messages.SavedMessage();
             if (cbxPrint.Checked)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decIdentity);
                 }
                 else
                 {
                     Print(decIdentity);
                 }
             }
             ClearFunction();
         }
         else
         {
             decimal decIdentity = decPDCpayableEditId;
             InfoPayable.PdcPayableMasterId = decPDCpayableEditId;
             SpPayable.PDCPayableMasterEdit(InfoPayable);
             LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
             spLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decPDCpayableVoucherTypeId, 12);
             spPartyBalance.PartyBalanceDeleteByVoucherTypeAndVoucherNo(decPDCpayableVoucherTypeId, strVoucherNo);
             PartyBalanceAddOrEdit();
             LedgerPostingEdit(decPDCpayableEditId);
             Messages.UpdatedMessage();
             if (cbxPrint.Checked)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decIdentity);
                 }
                 else
                 {
                     Print(decIdentity);
                 }
             }
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PP7:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }