Esempio n. 1
0
 /// <summary>
 /// Function to use the SaveItems to table
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         decimal decSalesOrderSuffixPrefixId = 0;
         SalesOrderDetailsInfo infoSalesOrderDetails = new SalesOrderDetailsInfo();
         SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo();
         SalesOrderDetailsSP spSalesOrderDetails = new SalesOrderDetailsSP();
         SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP();
         infoSalesOrderMaster.Cancelled = false;
         infoSalesOrderMaster.Date = Convert.ToDateTime(txtDate.Text);
         infoSalesOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text);
         infoSalesOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
         if (isAutomatic)
         {
             infoSalesOrderMaster.SuffixPrefixId = decSalesOrderSuffixPrefixId;
             infoSalesOrderMaster.VoucherNo = strVoucherNo;
         }
         else
         {
             infoSalesOrderMaster.SuffixPrefixId = 0;
             infoSalesOrderMaster.VoucherNo = spSalesOrderMaster.VoucherNoMax(decSalesOrderTypeId);
         }
         infoSalesOrderMaster.VoucherTypeId = decSalesOrderTypeId;
         infoSalesOrderMaster.InvoiceNo = txtOrderNo.Text;
         infoSalesOrderMaster.UserId = PublicVariables._decCurrentUserId;
         if (cmbSalesMan.SelectedIndex == -1)
         {
             infoSalesOrderMaster.SalesOrderMasterId = 0;
         }
         else
         {
             infoSalesOrderMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
         }
         infoSalesOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
         if (cmbPricingLevel.SelectedIndex == -1)
         {
             infoSalesOrderMaster.PricinglevelId = 0;
         }
         else
         {
             infoSalesOrderMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
         }
         infoSalesOrderMaster.Narration = txtNarration.Text.Trim();
         if (cmbQuotationNo.SelectedIndex == -1)
         {
             infoSalesOrderMaster.QuotationMasterId = 0;
         }
         else
         {
             infoSalesOrderMaster.QuotationMasterId = Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString());
         }
         infoSalesOrderMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
         infoSalesOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
         infoSalesOrderMaster.Extra1 = string.Empty;
         infoSalesOrderMaster.Extra2 = string.Empty;
         decSalesOrderMasterIdentity = Convert.ToDecimal(spSalesOrderMaster.SalesOrderMasterAdd(infoSalesOrderMaster));
         int inRowcount = dgvSalesOrder.Rows.Count;
         for (int inI = 0; inI < inRowcount - 1; inI++)
         {
             infoSalesOrderDetails.SalesOrderMasterId = decSalesOrderMasterIdentity;
             if (dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != "")
             {
                 infoProduct = new ProductSP().ProductViewByCode(dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                 infoSalesOrderDetails.ProductId = infoProduct.ProductId;
             }
             if (dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != "")
             {
                 infoSalesOrderDetails.Qty = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString());
             }
             if (dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != "")
             {
                 infoSalesOrderDetails.UnitId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                 infoSalesOrderDetails.UnitConversionId = decConversionId;
             }
             if (dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString() != "")
             {
                 infoSalesOrderDetails.UnitConversionId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
             }
             if (dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty)
             {
                 infoSalesOrderDetails.BatchId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value.ToString());
             }
             if (dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value == null || dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString() == "")
             {
                 infoSalesOrderDetails.QuotationDetailsId = Convert.ToDecimal(0);
             }
             else
             {
                 infoSalesOrderDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value);
             }
             infoSalesOrderDetails.Rate = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
             infoSalesOrderDetails.Amount = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
             infoSalesOrderDetails.SlNo = Convert.ToInt32(dgvSalesOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
             infoSalesOrderDetails.UnitConversionId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
             infoSalesOrderDetails.Extra1 = string.Empty;
             infoSalesOrderDetails.Extra2 = string.Empty;
             spSalesOrderDetails.SalesOrderDetailsAdd(infoSalesOrderDetails);
         }
         Messages.SavedMessage();
         if (cbxPrintAfterSave.Checked == true)
         {
             if (new SettingsSP().SettingsStatusCheck("Printer") == "Dot Matrix")
             {
                 PrintForDotMatrix(decSalesOrderMasterIdentity);
             }
             else
             {
                 Print(decSalesOrderMasterIdentity);
             }
         }
         Clear();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SO46:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Function to Editthe sales order details 
 /// </summary>
 public void SalesOrderDetailsEditFill()
 {
     try
     {
         SalesOrderDetailsInfo infoSalesOrderDetails = new SalesOrderDetailsInfo();
         SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo();
         SalesOrderDetailsSP spSalesOrderDetails = new SalesOrderDetailsSP();
         SalesOrderMasterSP spSalesOrdermaster = new SalesOrderMasterSP();
         for (int inI = 0; inI < dgvSalesOrder.Rows.Count - 1; inI++)
         {
             if (Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value) == 0 || dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value == null)
             {
                 infoSalesOrderDetails.SalesOrderMasterId = decSalesOrderMasterId;
                 infoSalesOrderDetails.SalesOrderDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value);
                 infoProduct = new ProductSP().ProductViewByCode(dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                 infoSalesOrderDetails.ProductId = infoProduct.ProductId;
                 infoSalesOrderDetails.Qty = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value);
                 infoSalesOrderDetails.UnitId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                 infoSalesOrderDetails.UnitConversionId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
                 infoSalesOrderDetails.BatchId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value.ToString());
                 infoSalesOrderDetails.Rate = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                 infoSalesOrderDetails.Amount = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                 infoSalesOrderDetails.SlNo = Convert.ToInt32(dgvSalesOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
                 if (dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString() != string.Empty)
                 {
                     infoSalesOrderDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString());
                 }
                 else
                 {
                     infoSalesOrderMaster.QuotationMasterId = 0;
                 }
                 infoSalesOrderDetails.Extra1 = string.Empty;
                 infoSalesOrderDetails.Extra2 = string.Empty;
                 spSalesOrderDetails.SalesOrderDetailsAdd(infoSalesOrderDetails);
             }
             else
             {
                 infoSalesOrderDetails.SalesOrderMasterId = decSalesOrderMasterId;
                 infoSalesOrderDetails.SalesOrderDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value);
                 infoProduct = new ProductSP().ProductViewByCode(dgvSalesOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString());
                 infoSalesOrderDetails.ProductId = infoProduct.ProductId;
                 infoSalesOrderDetails.Qty = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtQty"].Value);
                 infoSalesOrderDetails.UnitId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString());
                 infoSalesOrderDetails.UnitConversionId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString());
                 infoSalesOrderDetails.BatchId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvcmbBatch"].Value.ToString());
                 infoSalesOrderDetails.Rate = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString());
                 infoSalesOrderDetails.Amount = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString());
                 infoSalesOrderDetails.SlNo = Convert.ToInt32(dgvSalesOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString());
                 if (dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value != null && dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString() != string.Empty)
                 {
                     infoSalesOrderDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesQuotationDetailsId"].Value.ToString());
                 }
                 else
                 {
                     infoSalesOrderMaster.QuotationMasterId = 0;
                 }
                 infoSalesOrderDetails.Extra1 = string.Empty;
                 infoSalesOrderDetails.Extra2 = string.Empty;
                 spSalesOrderDetails.SalesOrderDetailsEdit(infoSalesOrderDetails);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SO43:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }