Esempio n. 1
0
 /// <summary>
 /// Function to save new added rows while editmode
 /// </summary>
 public void NewRowAddedToSalesQuotationDetails()
 {
     SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP();
     SalesQuotationDetailsInfo infoSalesQuotationDetails = new SalesQuotationDetailsInfo();
     ProductInfo infoproduct = new ProductInfo();
     ProductSP SpProduct = new ProductSP();
     try
     {
         for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++)
         {
             if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtquotationDetailsId"].Value) == 0)
             {
                 infoSalesQuotationDetails.QuotationMasterId = decSalesquotationMasterId;
                 infoproduct = SpProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                 infoSalesQuotationDetails.ProductId = infoproduct.ProductId;
                 infoSalesQuotationDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
                 infoSalesQuotationDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value);
                 decimal unitConversion = SpSalesQuotationDetails.UnitconversionIdViewByUnitIdAndProductId(infoSalesQuotationDetails.UnitId, infoSalesQuotationDetails.ProductId);
                 infoSalesQuotationDetails.UnitConversionId = unitConversion;
                 infoSalesQuotationDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                 infoSalesQuotationDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                 infoSalesQuotationDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
                 if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value) == 0)
                 {
                     infoSalesQuotationDetails.BatchId = 0;
                 }
                 else
                 {
                     infoSalesQuotationDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString());
                 }
                 infoSalesQuotationDetails.Extra1 = string.Empty;
                 infoSalesQuotationDetails.Extra2 = string.Empty;
                 SpSalesQuotationDetails.SalesQuotationDetailsAdd(infoSalesQuotationDetails);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:19" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Function to save the sales quatation
 /// </summary>
 public void SaveFunction()
 {
     SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP();
     SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP();
     SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
     SalesQuotationDetailsInfo infoSalesQuotationDetails = new SalesQuotationDetailsInfo();
     SettingsSP spSettings = new SettingsSP();
     ProductSP spProduct = new ProductSP();
     ProductInfo infoproduct = new ProductInfo();
     try
     {
         infoSalesQuotationMaster.Date = Convert.ToDateTime(txtSalesQuotationDate.Text);
         infoSalesQuotationMaster.PricinglevelId = Convert.ToDecimal(cmbPricinglevel.SelectedValue.ToString());
         infoSalesQuotationMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString());
         if (isAutomatic)
         {
             infoSalesQuotationMaster.SuffixPrefixId = decSalesQuotationPreffixSuffixId;
             infoSalesQuotationMaster.VoucherNo = strSalesQuotationNo;
         }
         else
         {
             infoSalesQuotationMaster.SuffixPrefixId = 0;
             infoSalesQuotationMaster.VoucherNo = SpSalesQuotationMaster.VoucherNoMax(decsalesQuotationTypeId);
         }
         infoSalesQuotationMaster.VoucherTypeId = decsalesQuotationTypeId;
         infoSalesQuotationMaster.InvoiceNo = txtQuotationNo.Text;
         infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString());
         infoSalesQuotationMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         infoSalesQuotationMaster.userId = PublicVariables._decCurrentUserId;
         infoSalesQuotationMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text);
         infoSalesQuotationMaster.Narration = txtNarration.Text.Trim();
         infoSalesQuotationMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoSalesQuotationMaster.Extra1 = string.Empty;
         infoSalesQuotationMaster.Extra2 = string.Empty;
         if (cbxApproved.Checked)
         {
             infoSalesQuotationMaster.Approved = true;
         }
         else
         {
             infoSalesQuotationMaster.Approved = false;
         }
         decSalesQuotationmasterIdentity = Convert.ToDecimal(SpSalesQuotationMaster.SalesQuotationMasterAdd(infoSalesQuotationMaster));
         int inRowcount = dgvProduct.Rows.Count;
         for (int inI = 0; inI < inRowcount - 1; inI++)
         {
             infoSalesQuotationDetails.QuotationMasterId = decSalesQuotationmasterIdentity;
             if (dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty)
             {
                 infoproduct = spProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                 infoSalesQuotationDetails.ProductId = infoproduct.ProductId;
             }
             if (dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
             }
             if (dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                 decimal unitConversion = SpSalesQuotationDetails.UnitconversionIdViewByUnitIdAndProductId(infoSalesQuotationDetails.UnitId, infoSalesQuotationDetails.ProductId);
                 infoSalesQuotationDetails.UnitConversionId = unitConversion;
             }
             if (dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
             {
                 infoSalesQuotationDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value);
             }
             else
             {
                 infoSalesQuotationDetails.BatchId = 0;
             }
             infoSalesQuotationDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
             infoSalesQuotationDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
             infoSalesQuotationDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
             infoSalesQuotationDetails.Extra1 = string.Empty;
             infoSalesQuotationDetails.Extra2 = string.Empty;
             SpSalesQuotationDetails.SalesQuotationDetailsAdd(infoSalesQuotationDetails);
         }
         Messages.SavedMessage();
         if (cbxPrintAfterSave.Checked)
         {
             if (dgvProduct.Rows.Count > 0)
             {
                 if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix")
                 {
                     PrintForDotMatrix(decSalesQuotationmasterIdentity);
                 }
                 else
                 {
                     Print(decSalesQuotationmasterIdentity);
                 }
             }
             else
             {
                 Messages.InformationMessage("No data found");
             }
         }
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:32" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }