Beispiel #1
0
 /// <summary>
 /// Edit Function
 /// </summary>
 public void EditFunction()
 {
     try
     {
         removeSalesInvoiceDetails();
         SalesMasterSP spSalesMaster = new SalesMasterSP();
         SalesMasterInfo InfoSalesMaster = new SalesMasterInfo();
         InfoSalesMaster = spSalesMaster.SalesMasterView(decSalesInvoiceIdToEdit);
         if (InfoSalesMaster.DeliveryNoteMasterId != 0)
         {
             DeliveryNoteMasterInfo infoDeliveryNote = new DeliveryNoteMasterInfo();
             infoDeliveryNote = new DeliveryNoteMasterSP().DeliveryNoteMasterView(InfoSalesMaster.DeliveryNoteMasterId);
             new StockPostingSP().StockPostingDeleteForSalesInvoiceAgainstDeliveryNote
                 (InfoSalesMaster.VoucherTypeId, InfoSalesMaster.VoucherNo,
                 infoDeliveryNote.VoucherNo, infoDeliveryNote.VoucherTypeId);
         }
         new StockPostingSP().StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType
                 (0, "NA", InfoSalesMaster.VoucherNo, InfoSalesMaster.VoucherTypeId);
         InfoSalesMaster.SalesMasterId = decSalesInvoiceIdToEdit;
         InfoSalesMaster.AdditionalCost = Convert.ToDecimal(lblLedgerTotalAmount.Text);
         InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text.Trim());
         InfoSalesMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim().ToString());
         InfoSalesMaster.CustomerName = txtCustomer.Text.Trim();
         InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text.ToString());
         InfoSalesMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
         InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim());
         InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim();
         InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         InfoSalesMaster.VoucherTypeId = DecSalesInvoiceVoucherTypeId;
         InfoSalesMaster.VoucherNo = strVoucherNo;
         if (isAutomatic)
         {
             InfoSalesMaster.SuffixPrefixId = decSalseInvoiceSuffixPrefixId;
         }
         else
         {
             InfoSalesMaster.SuffixPrefixId = 0;
         }
         if (cmbSalesMode.Text == "Against SalesOrder")
         {
             InfoSalesMaster.OrderMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.OrderMasterId = 0;
         }
         if (cmbSalesMode.Text == "Against Delivery Note")
         {
             InfoSalesMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.DeliveryNoteMasterId = 0;
         }
         if (cmbSalesMode.Text == "Against Quotation")
         {
             InfoSalesMaster.QuotationMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString());
         }
         else
         {
             InfoSalesMaster.QuotationMasterId = 0;
         }
         InfoSalesMaster.Narration = txtNarration.Text.Trim();
         InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
         InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString());
         InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text.Trim());
         if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible)
         {
             InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text.Trim());
         }
         else
         {
             InfoSalesMaster.TaxAmount = 0;
         }
         InfoSalesMaster.UserId = PublicVariables._decCurrentUserId;
         InfoSalesMaster.LrNo = txtVehicleNo.Text;
         InfoSalesMaster.TransportationCompany = txtTransportCompany.Text.Trim();
         InfoSalesMaster.POS = false;
         InfoSalesMaster.CounterId = 0;
         InfoSalesMaster.ExtraDate = DateTime.Now;
         InfoSalesMaster.Extra1 = string.Empty;
         InfoSalesMaster.Extra2 = string.Empty;
         spSalesMaster.SalesMasterEdit(InfoSalesMaster);
         removeSalesInvoiceDetails();
         SalesInvoiceDetailsEditFill();
         if (cmbCashOrParty.Enabled)
         {
             LedgerPostingSP spLedgerPosting = new LedgerPostingSP();
             spLedgerPosting.LedgerPostDelete(strVoucherNo, DecSalesInvoiceVoucherTypeId);
             ledgerPostingAdd();
         }
         else
         {
             ledgerPostingEdit();
         }
         Messages.UpdatedMessage();
         if (cbxPrintAfterSave.Checked)
         {
             SettingsSP spSettings = new SettingsSP();
             if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
             {
                 PrintForDotMatrix(decSalesInvoiceIdToEdit);
             }
             else
             {
                 Print(decSalesInvoiceIdToEdit);
             }
         }
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 78" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Call Corresponding Voucher to View details for updation in edit mode
 /// </summary>
 public void GotoSalesInvoice()
 {
     try
     {
         SalesMasterSP SpMaster = new SalesMasterSP();
         SalesMasterInfo InfoMaster = new SalesMasterInfo();
         InfoMaster = SpMaster.SalesMasterView(Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString()));
         if (InfoMaster.POS == true)
         {
             frmPOS objfrm = new frmPOS();
             
             objfrm.WindowState = FormWindowState.Normal;
             objfrm.MdiParent = formMDI.MDIObj;
             objfrm.Show();
             objfrm.CallFromVoucherSearch(this, Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString()));
         }
         else
         {
             frmSalesInvoice objfrmSalesInvoice = new frmSalesInvoice();
             frmSalesInvoice open = Application.OpenForms["frmSalesInvoice"] as frmSalesInvoice;
             if (open == null)
             {
                 objfrmSalesInvoice.WindowState = FormWindowState.Normal;
                 objfrmSalesInvoice.MdiParent = formMDI.MDIObj;
                 objfrmSalesInvoice.Show();
                 objfrmSalesInvoice.CallFromVoucherSearch(this, Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString()));
             }
             else
             {
                 open.MdiParent = formMDI.MDIObj;
                 if (open.WindowState == FormWindowState.Minimized)
                 {
                     open.WindowState = FormWindowState.Normal;
                 }
                 else
                 {
                     open.Activate();
                 }
                 open.CallFromVoucherSearch(this, Convert.ToDecimal(dgvVoucherSearch.CurrentRow.Cells["Id"].Value.ToString()));
                 open.BringToFront();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("VS24:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }