Esempio n. 1
0
 /// <summary>
 /// To fill the grid according to the pending Sales order Invoice number
 /// </summary>
 public void FillOrderDetails()
 {
     decimal decOrderNo = 0;
     try
     {
         DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo();
         DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP();
         decOrderNo = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString());
         inMaxCount = 0;
         string strSalesManId;
         decimal DefaultRate = 0;
         dgvProduct.Rows.Clear();
         DataTable dtblMaster = new SalesOrderMasterSP().SalesOrderMasterViewBySalesOrderMasterId(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()));
         cmbPricingLevel.SelectedValue = dtblMaster.Rows[0]["pricingLevelId"].ToString();
         if (dtblMaster.Rows[0]["employeeId"].ToString() != string.Empty)
         {
             strSalesManId = dtblMaster.Rows[0]["employeeId"].ToString();
             cmbSalesMan.SelectedValue = strSalesManId;
             SalesManComboFill();
             cmbSalesMan.SelectedValue = dtblMaster.Rows[0]["employeeId"].ToString();
         }
         CurrencyComboFill();
         cmbCurrency.SelectedValue = dtblMaster.Rows[0]["exchangeRateId"].ToString();
         DataTable dtblDetails = new SalesOrderDetailsSP().SalesOrderDetailsViewBySalesOrderMasterIdWithRemaining(decOrderNo, 0);
         int inRowIndex = 0;
         isValueChange = false;
         isDoAfterGridFill = false;
         infoDeliveryNoteMaster = spDeliveryNoteMaster.DeliveryNoteMasterViewAllByMasterId(decDelivryNoteIdToEdit);
         foreach (DataRow drowDetails in dtblDetails.Rows)
         {
             dgvProduct.Rows.Add();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = drowDetails["barcode"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = drowDetails["productCode"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductId"].Value = drowDetails["productId"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].Value = drowDetails["productName"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtQty"].Value = drowDetails["qty"].ToString();
             string ProductId = drowDetails.ItemArray[2].ToString();
             UnitComboFill1(Convert.ToDecimal(ProductId), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex);
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
             BatchComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex);
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString());
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value = drowDetails["rate"].ToString();
             DefaultRate = Convert.ToDecimal(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value.ToString());
             GridGodownComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].ColumnIndex);
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(drowDetails["godownId"].ToString());
             RackComboFill1(Convert.ToDecimal(drowDetails["godownId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].ColumnIndex);
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].Value = Convert.ToDecimal(drowDetails["rackId"].ToString());
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = drowDetails["salesOrderDetailsId"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherTypeId"].Value = drowDetails["voucherTypeId"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherNo"].Value = drowDetails["voucherNo"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtInvoiceNo"].Value = drowDetails["invoiceNo"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = drowDetails["unitConversionId"].ToString();
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = drowDetails["conversionRate"].ToString();
             if (cmbOrderNo.Visible == true)
             {
                 dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true;
             }
             dgvProduct.Rows[dgvProduct.Rows.Count - 2].HeaderCell.Value = "";
             AmountCalculation("dgvtxtQty", inRowIndex);
             int inIndex = 0;
             int.TryParse(drowDetails["extra1"].ToString(), out inIndex);
             if (inMaxCount < inIndex)
                 inMaxCount = inIndex;
             inRowIndex++;
             isValueChange = true;
         }
         for (int i = inRowIndex; i < dgvProduct.Rows.Count; ++i)
             dgvProduct["inRowIndex", i].Value = GetNextinRowIndex().ToString();
         SerialNo();
         TotalAmountCalculation();
         isDoAfterGridFill = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN27 :" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Grid fill function Againest SalseOrderDetails
 /// </summary>
 public void gridFillAgainestSalseOrderDetails()
 {
     SalesOrderMasterSP SPSalesOrderMaster = new SalesOrderMasterSP();
     SalesOrderDetailsSP spSalesOrderDetails = new SalesOrderDetailsSP();
     ProductInfo infoproduct = new ProductInfo();
     SalesMasterSP spSalesMaster = new SalesMasterSP();
     BrandInfo InfoBrand = new BrandInfo();
     TaxInfo infoTax = new TaxInfo();
     TaxSP SPTax = new TaxSP();
     try
     {
         if (cmbSalesModeOrderNo.SelectedIndex > 0)
         {
             inMaxCount = 0;
             isValueChange = false;
             for (int i = 0; i < dgvSalesInvoice.RowCount - 1; i++)
             {
                 if (dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value != null && dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() != string.Empty)
                 {
                     lstArrOfRemove.Add(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString());
                 }
             }
             dgvSalesInvoice.Rows.Clear();
             isValueChange = true;
             DataTable dtblMaster = SPSalesOrderMaster.SalesInvoiceGridfillAgainestSalesOrder(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()));
             cmbPricingLevel.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["pricingLevelId"].ToString());
             cmbCurrency.SelectedValue = Convert.ToDecimal(dtblMaster.Rows[0]["exchangeRateId"].ToString());
             if (dtblMaster.Rows[0]["employeeId"].ToString() != string.Empty)
             {
                 strSalesManId = dtblMaster.Rows[0]["employeeId"].ToString();
                 cmbSalesMan.SelectedValue = strSalesManId;
                 if (cmbSalesMan.SelectedValue == null)
                 {
                     salesManComboFill();
                     cmbSalesMan.SelectedValue = dtblMaster.Rows[0]["employeeId"].ToString();
                 }
             }
             cmbPricingLevel.Enabled = false;
             btnNewPricingLevel.Enabled = false;
             cmbCurrency.Enabled = false;
             DataTable dtblDetails = spSalesOrderDetails.SalesInvoiceGridfillAgainestSalesOrderUsingSalesDetails(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()), Convert.ToDecimal(decSalesInvoiceIdToEdit), DecSalesInvoiceVoucherTypeId);
             int inRowIndex = 0;
             foreach (DataRow drowDetails in dtblDetails.Rows)
             {
                 dgvSalesInvoice.Rows.Add();
                 isValueChange = false;
                 IsSetGridValueChange = false;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSISalesOrderDetailsId"].Value = drowDetails["salesOrderDetailsId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductCode"].Value = drowDetails["productCode"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBarcode"].Value = drowDetails["barcode"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = drowDetails["voucherNo"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = drowDetails["invoiceNo"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = drowDetails["voucherTypeId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value = "0";
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInRowIndex"].Value = drowDetails["salesOrderDetailsId"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value = drowDetails.ItemArray[2].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = drowDetails["unitConversionId"].ToString();
                 infoproduct = spSalesMaster.ProductViewByProductIdforSalesInvoice(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductName"].Value = infoproduct.ProductName;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceMrp"].Value = infoproduct.Mrp;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = infoproduct.PurchaseRate;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceSalesRate"].Value = infoproduct.SalesRate;
                 InfoBrand = new BrandSP().BrandView(infoproduct.BrandId);
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceBrand"].Value = InfoBrand.BrandName;
                 infoTax = SPTax.TaxViewByProductId(Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value).ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvcmbSalesInvoiceTaxName"].Value = infoTax.TaxId;
                 isValueChange = false;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true;
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceQty"].Value = drowDetails["Qty"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceRate"].Value = drowDetails["rate"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceAmount"].Value = drowDetails["amount"].ToString();
                 dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceConversionRate"].Value = drowDetails["conversionRate"].ToString();
                 isFromAgainest = true;
                 gridColumnMakeEnables();
                 int intIndex = 0;
                 intIndex = Convert.ToInt32(drowDetails["salesOrderDetailsId"].ToString());
                 if (inMaxCount < intIndex)
                     inMaxCount = intIndex;
                 inRowIndex++;
                 isValueChange = true;
                 isFromAgainest = false;
                 GrossValueCalculation(dgvSalesInvoice.Rows.Count - 2);
                 discountCalculation(dgvSalesInvoice.Rows.Count - 2);
                 taxAndGridTotalAmountCalculation(dgvSalesInvoice.Rows.Count - 2);
             }
             IsSetGridValueChange = true;
             for (int i = inRowIndex; i < dgvSalesInvoice.Rows.Count; ++i)
                 dgvSalesInvoice["dgvtxtSalesInvoiceInRowIndex", i].Value = GetNextinRowIndex().ToString();
             SerialNoforSalesInvoice();
             strVoucherNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString();
             strInvoiceNoTostockPost = dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString();
             decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value);
         }
         else
         {
             SiGridTotalAmountCalculation();
             ClearGridAgainest();
         }
         SiGridTotalAmountCalculation();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 51" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Function to use to fill details to updation when comes register or report
 /// </summary>
 public void FillRegisterOrReport()
 {
     try
     {
         SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
         SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo();
         SalesOrderDetailsSP spSalesOrderDetails = new SalesOrderDetailsSP();
         SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP();
         isValueChange = false;
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtOrderNo.ReadOnly = true;
         infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(decSalesOrderMasterId);
         txtOrderNo.Text = infoSalesOrderMaster.InvoiceNo;
         strVoucherNo = infoSalesOrderMaster.VoucherNo.ToString();
         decSalesSuffixPrefixId = Convert.ToDecimal(infoSalesOrderMaster.SuffixPrefixId);
         decSalesVoucherId = Convert.ToDecimal(infoSalesOrderMaster.VoucherTypeId);
         isAutomatic = new VoucherTypeSP().CheckMethodOfVoucherNumbering(decSalesVoucherId);
         decSalesOrderTypeId = decSalesVoucherId;
         txtDate.Text = infoSalesOrderMaster.Date.ToString("dd-MMM-yyyy");
         cmbCashOrParty.SelectedValue = infoSalesOrderMaster.LedgerId;
         decSalesOrderVoucherTypeId = infoSalesOrderMaster.VoucherTypeId;
         VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
         VoucherTypeSP spVoucherType = new VoucherTypeSP();
         infoVoucherType = spVoucherType.VoucherTypeView(decSalesOrderVoucherTypeId);
         string strVoucherTypeName = infoVoucherType.VoucherTypeName;
         this.Text = strVoucherTypeName;
         if (infoSalesOrderMaster.QuotationMasterId == 0)
         {
             cmbType.SelectedItem = "NA";
         }
         else if (infoSalesOrderMaster.QuotationMasterId != 0)
         {
             infoSalesQuotationMaster = new SalesQuotationMasterSP().SalesQuotationMasterView(infoSalesOrderMaster.QuotationMasterId);
             cmbType.SelectedValue = infoSalesQuotationMaster.VoucherTypeId;
             AgainstQuotationComboFill();
             cmbQuotationNo.SelectedValue = infoSalesOrderMaster.QuotationMasterId;
         }
         txtDueDate.Text = infoSalesOrderMaster.DueDate.ToString("dd-MMM-yyyy");
         TimeSpan objTs = Convert.ToDateTime(txtDueDate.Text).Subtract(Convert.ToDateTime(txtDate.Text));
         txtDueDays.Text = objTs.Days.ToString();
         txtNarration.Text = infoSalesOrderMaster.Narration;
         cmbCurrency.SelectedValue = infoSalesOrderMaster.ExchangeRateId;
         cmbPricingLevel.SelectedValue = infoSalesOrderMaster.PricinglevelId;
         SalesManComboFill();
         cmbSalesMan.SelectedValue = infoSalesOrderMaster.EmployeeId;
         txtTotalAmount.Text = infoSalesOrderMaster.TotalAmount.ToString();
         DataTable dtbl = new DataTable();
         dtbl = spSalesOrderDetails.SalesOrderDetailsViewByMasterId(decSalesOrderMasterId);
         if (CheckCancelStatus(decSalesOrderMasterId))
         {
             isCheck = true;
             cbxCancelled.Checked = true;
             cbxCancelled.Enabled = false;
             btnSave.Enabled = false;
             isCheck = false;
         }
         else
         {
             isCheck = true;
             cbxCancelled.Enabled = true;
             cbxCancelled.Checked = false;
             isCheck = false;
         }
         if (isAutomatic)
         {
             txtOrderNo.ReadOnly = true;
             txtDate.Focus();
         }
         else
         {
             txtOrderNo.ReadOnly = false;
             txtOrderNo.Focus();
         }
         for (int i = 0; i < dtbl.Rows.Count; i++)
         {
             isAmountcalc = false;
             isValueChange = false;
             dgvSalesOrder.Rows.Add();
             dgvSalesOrder.Rows[i].HeaderCell.Value = string.Empty;
             dgvSalesOrder.Rows[i].Cells["dgvtxtSalesOrderDetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["salesOrderDetailsId"].ToString());
             dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value = dtbl.Rows[i]["productId"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtProductCode"].Value = dtbl.Rows[i]["productCode"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtProductName"].Value = dtbl.Rows[i]["productName"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtQty"].Value = dtbl.Rows[i]["qty"].ToString();
             UnitComboFill(Convert.ToDecimal(dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value.ToString()), i, dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
             dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitId"].ToString());
             dgvSalesOrder.Rows[i].Cells["dgvtxtRate"].Value = dtbl.Rows[i]["rate"].ToString();
             BatchComboFill(Convert.ToDecimal(dgvSalesOrder.Rows[i].Cells["dgvtxtProductId"].Value.ToString()), i, dgvSalesOrder.Rows[i].Cells["dgvcmbBatch"].ColumnIndex);
             dgvSalesOrder.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(dtbl.Rows[i]["batchId"].ToString());
             dgvSalesOrder.Rows[i].Cells["dgvtxtBarcode"].Value = dtbl.Rows[i]["barcode"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtAmount"].Value = dtbl.Rows[i]["amount"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtUnitConversionId"].Value = dtbl.Rows[i]["unitConversionId"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtConversionRate"].Value = dtbl.Rows[i]["conversionRate"].ToString();
             dgvSalesOrder.Rows[i].Cells["dgvtxtSalesQuotationDetailsId"].Value = dtbl.Rows[i]["quotationDetailsId"].ToString();
             if (Convert.ToDecimal(dtbl.Rows[i]["quotationDetailsId"].ToString()) != 0)
             {
                 dgvSalesOrder.Rows[i].Cells["dgvtxtProductCode"].ReadOnly = true;
                 dgvSalesOrder.Rows[i].Cells["dgvtxtProductName"].ReadOnly = true;
                 dgvSalesOrder.Rows[i].Cells["dgvtxtBarcode"].ReadOnly = true;
             }
             if (cmbQuotationNo.Visible == true)
             {
                 dgvSalesOrder.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true;
             }
         }
         isAmountcalc = true;
         isEditFill = false;
         isValueChange = true;
         isDoAfterGridFill = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SO30:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 4
0
 /// <summary>
 ///to change the corresponding values in grid when cells changed 
 /// </summary>
 private void dgvProduct_CellLeave(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         SalesQuotationDetailsSP spQuotationDetails = new SalesQuotationDetailsSP();
         DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP();
         if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty")
         {
             decimal decCurrentQty = 0;
             decimal decOldQty = 0;
             if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString() != string.Empty)
             {
                 if (decDelivryNoteIdToEdit != 0)
                 {
                     if (cmbOrderNo.SelectedIndex != 0)
                     {
                         if (cmbDeliveryMode.Text == "Against Order")
                         {
                             DataTable dtblDetails = new SalesOrderDetailsSP().SalesOrderDetailsViewBySalesOrderMasterIdWithRemaining(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDelivryNoteIdToEdit);
                             decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[0].Cells["dgvtxtQty"].Value.ToString());
                             decOldQty = Convert.ToDecimal(dtblDetails.Rows[0]["qty"].ToString());
                         }
                         else if (cmbDeliveryMode.Text == "Against Quotation")
                         {
                             DataTable dtblQuotationDetails = spQuotationDetails.SalesQuotationDetailsViewByquotationMasterIdWithRemainingByNotInCurrDN(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDelivryNoteIdToEdit);
                             if (dtblQuotationDetails.Rows.Count >= 1)
                             {
                                 decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[0].Cells["dgvtxtQty"].Value.ToString());
                                 decOldQty = Convert.ToDecimal(dtblQuotationDetails.Rows[0]["qty"].ToString());
                             }
                         }
                         if (spDeliveryNoteMaster.DeliveryNoteMasterReferenceCheckRejectionIn(decDelivryNoteIdToEdit))
                         {
                             DataTable dtblRejectionInQty = new DataTable();
                             dtblRejectionInQty = spDeliveryNoteMaster.DeliveryNoteMasterReferenceCheckRejectionInQty(decDelivryNoteIdToEdit);
                             decimal decRejectionInQty = decimal.Parse(dtblRejectionInQty.Rows[e.RowIndex]["qty"].ToString());
                             if (decimal.Parse(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()) > decimal.Parse(dtblRejectionInQty.Rows[e.RowIndex]["qty"].ToString()))
                             {
                                 decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString());
                             }
                             else
                             {
                                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = Convert.ToDecimal(decRejectionInQty);
                             }
                         }
                         if (spDeliveryNoteMaster.DeliveryNoteCheckReferenceInSalesInvoice(decDelivryNoteIdToEdit))
                         {
                             DataTable dtblSalesInvoiceQty = new DataTable();
                             dtblSalesInvoiceQty = spDeliveryNoteMaster.DeliveryNoteMasterReferenceCheckSalesInvoiceQty(decDelivryNoteIdToEdit);
                             decimal decSalesInvoiceQty = decimal.Parse(dtblSalesInvoiceQty.Rows[e.RowIndex]["qty"].ToString());
                             if (decimal.Parse(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()) > decimal.Parse(dtblSalesInvoiceQty.Rows[e.RowIndex]["qty"].ToString()))
                             {
                                 decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString());
                             }
                             else
                             {
                                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = Convert.ToDecimal(decSalesInvoiceQty);
                             }
                         }
                     }
                     else
                     {
                         Messages.InformationMessage("Select OrderNo");
                         cmbOrderNo.Focus();
                     }
                 }
                 if (decDelivryNoteIdToEdit == 0)
                 {
                     if (Convert.ToInt32(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value) != 0)
                     {
                         if (cmbDeliveryMode.Text == "Against Quotation")
                         {
                             DataTable dtbl1 = spQuotationDetails.SalesQuotationDetailsViewByquotationMasterIdWithRemainingByNotInCurrDN(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDelivryNoteIdToEdit);
                             decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString());
                             decOldQty = Convert.ToDecimal(dtbl1.Rows[e.RowIndex]["qty"].ToString());
                         }
                         else if (cmbDeliveryMode.Text == "Against Order")
                         {
                             DataTable dtbl2 = new SalesOrderDetailsSP().SalesOrderDetailsViewBySalesOrderMasterIdWithRemaining(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDelivryNoteIdToEdit);
                             decCurrentQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString());
                             decOldQty = Convert.ToDecimal(dtbl2.Rows[e.RowIndex]["qty"].ToString());
                         }
                     }
                 }
             }
         }
         if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit")
         {
             if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString() != string.Empty)
             {
                 if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)
                 {
                     UnitConvertionSP SpUnitConvertion = new UnitConvertionSP();
                     DataTable dtblUnitByProduct = new DataTable();
                     dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductId"].Value.ToString());
                     foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows)
                     {
                         if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                         {
                             dgvProduct.Rows[e.RowIndex].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                             dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());
                             if (isDoAfterGridFill)
                             {
                                 decimal decNewConversionRate = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString());
                                 decimal decNewRate = (decCurrentRate * decCurrentConversionRate) / decNewConversionRate;
                                 dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decNewRate, 2);
                             }
                         }
                     }
                 }
             }
         }
         if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty")
         {
             AmountCalculation("dgvtxtQty", e.RowIndex);
         }
         if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate")
         {
             AmountCalculation("dgvtxtRate", e.RowIndex);
         }
         else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtAmount")
         {
             TotalAmountCalculation();
         }
         CheckInvalidEntries(e);
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN70:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Function to delete 
 /// </summary>
 public void Delete()
 {
     try
     {
         SalesOrderDetailsSP spSalesOrderDetails = new SalesOrderDetailsSP();
         SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP();
         decimal decResult1 = 0;
         for (int inI = 0; inI < dgvSalesOrder.Rows.Count - 1; inI++)
         {
             if (Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value) != 0)
             {
                 decResult1 = spSalesOrderDetails.SalesOrderDetailsDeletee(Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value));
             }
         }
         decimal decResult2 = spSalesOrderMaster.SalesOrderMasterDelete(decSalesOrderMasterId);
         if (decResult1 > 0 && decResult2 > 0)
         {
             Messages.DeletedMessage();
             if (frmSalesOrderRegisterObj != null)
             {
                 this.Close();
                 frmSalesOrderRegisterObj.Enabled = true;
             }
             if (frmSalesOrderReportObj != null)
             {
                 this.Close();
                 frmSalesOrderReportObj.Enabled = true;
             }
             if (objVoucherSearch != null)
             {
                 this.Close();
                 objVoucherSearch.Enabled = true;
             }
             if (frmDayBookObj != null)
             {
                 this.Close();
             }
         }
         else
         {
             Messages.ReferenceExistsMessage();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SO53:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Edit Function When update datas in Register or Report
 /// </summary>
 public void EditFunction()
 {
     try
     {
         decimal decSalesOrderSuffixPrefixId = 0;
         SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP();
         SalesOrderDetailsSP spSalesOrderDetails = new SalesOrderDetailsSP();
         SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo();
         SalesOrderDetailsInfo infoSalesOrderDetails = new SalesOrderDetailsInfo();
         infoSalesOrderMaster.VoucherTypeId = decSalesVoucherId;
         for (int inI = 0; inI < dgvSalesOrder.Rows.Count - 1; inI++)
         {
             if (Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value) != null && Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value) != 0)
             {
                 //for (int i = 0; i < dgvSalesOrder.Rows.Count - 1; i++)
                 //{
                 isEditDetails = Convert.ToString(spSalesOrderDetails.SalesOrderRefererenceCheckForEditDetails(Convert.ToDecimal(dgvSalesOrder.Rows[inI].Cells["dgvtxtSalesOrderDetailsId"].Value)));
                 //}
             }
         }
         isEditMaster = Convert.ToString(spSalesOrderMaster.SalesOrderRefererenceCheckForEditMaster(decSalesOrderMasterId));
         if (isEditMaster == "False" && isEditDetails == "False")
         {
             infoSalesOrderMaster.SalesOrderMasterId = decSalesOrderMasterId;
             infoSalesOrderMaster.Cancelled = cbxCancelled.Checked;
             infoSalesOrderMaster.Date = Convert.ToDateTime(txtDate.Text);
             infoSalesOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text);
             infoSalesOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString());
             infoSalesOrderMaster.SuffixPrefixId = Convert.ToDecimal(decSalesOrderSuffixPrefixId);
             infoSalesOrderMaster.VoucherNo = strVoucherNo;
             infoSalesOrderMaster.InvoiceNo = txtOrderNo.Text;
             infoSalesOrderMaster.UserId = PublicVariables._decCurrentUserId;
             infoSalesOrderMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString());
             infoSalesOrderMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString());
             if (cmbQuotationNo.SelectedIndex == -1)
             {
                 infoSalesOrderMaster.QuotationMasterId = 0;
             }
             else
             {
                 infoSalesOrderMaster.QuotationMasterId = Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString());
             }
             infoSalesOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId;
             infoSalesOrderMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString());
             infoSalesOrderMaster.Narration = txtNarration.Text.Trim();
             infoSalesOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text);
             infoSalesOrderMaster.Extra1 = string.Empty;
             infoSalesOrderMaster.Extra2 = string.Empty;
             RemoveSalesOrderDetails();
             spSalesOrderMaster.SalesOrderMasterEdit(infoSalesOrderMaster);
             SalesOrderDetailsEditFill();
             Messages.UpdatedMessage();
             if (frmSalesOrderRegisterObj != null)
             {
                 if (cbxPrintAfterSave.Checked == true)
                 {
                     if (new SettingsSP().SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesOrderMasterId);
                     }
                     else
                     {
                         Print(decSalesOrderMasterId);
                     }
                 }
                 this.Close();
                 frmSalesOrderRegisterObj.GridFill();
             }
             if (frmSalesOrderReportObj != null)
             {
                 if (cbxPrintAfterSave.Checked == true)
                 {
                     if (new SettingsSP().SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesOrderMasterId);
                     }
                     else
                     {
                         Print(decSalesOrderMasterId);
                     }
                 }
                 this.Close();
                 frmSalesOrderReportObj.GridFill();
             }
             if (frmDayBookObj != null)
             {
                 if (cbxPrintAfterSave.Checked == true)
                 {
                     if (new SettingsSP().SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesOrderMasterId);
                     }
                     else
                     {
                         Print(decSalesOrderMasterId);
                     }
                 }
                 this.Close();
             }
             if (objVoucherSearch != null)
             {
                 if (cbxPrintAfterSave.Checked == true)
                 {
                     if (new SettingsSP().SettingsStatusCheck("Printer") == "Dot Matrix")
                     {
                         PrintForDotMatrix(decSalesOrderMasterId);
                     }
                     else
                     {
                         Print(decSalesOrderMasterId);
                     }
                 }
                 this.Close();
                 objVoucherSearch.GridFill();
             }
         }
         else
         {
             Messages.ReferenceExistsMessageForUpdate();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SO47:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 7
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. 8
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);
     }
 }
Esempio n. 9
0
 /// <summary>
 /// Remove Product and details in editing mode
 /// </summary>
 public void RemoveSalesOrderDetails()
 {
     try
     {
         SalesOrderDetailsSP spSalesOrderDetails = new SalesOrderDetailsSP();
         foreach (var strId in lstArrOfRemove)
         {
             decimal decDeleteId = Convert.ToDecimal(strId);
             spSalesOrderDetails.SalesOrderDetailsDeletee(decDeleteId);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SO41:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }