/// <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); } }
/// <summary> /// Grid fill function Againest QuotationDetails /// </summary> public void gridFillAgainestQuotationDetails() { SalesQuotationMasterSP SPQuotationMaster = new SalesQuotationMasterSP(); SalesQuotationDetailsSP SPQuotationDetails = new SalesQuotationDetailsSP(); 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 = SPQuotationMaster.SalesInvoiceGridfillAgainestQuotation(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 = SPQuotationDetails.SalesInvoiceGridfillAgainestQuotationUsingQuotationDetails(Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()), decSalesInvoiceIdToEdit, DecSalesInvoiceVoucherTypeId); int inRowIndex = 0; foreach (DataRow drowDetails in dtblDetails.Rows) { dgvSalesInvoice.Rows.Add(); IsSetGridValueChange = false; isValueChange = false; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value = drowDetails["quotationDetailsId"].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["quotationDetailsId"].ToString(); dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceProductId"].Value = drowDetails.ItemArray[2].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; dgvSalesInvoice.Rows[dgvSalesInvoice.Rows.Count - 2].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = drowDetails["unitConversionId"].ToString(); 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["quotationDetailsId"].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: 52" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the grid to edit the details /// </summary> public void SalesQuotationDetailsEditFill() { SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP(); SalesQuotationDetailsInfo infoSalesQuotationDetails = new SalesQuotationDetailsInfo(); ProductSP SpProduct = new ProductSP(); ProductInfo infoproduct = new ProductInfo(); try { for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++) { infoSalesQuotationDetails.QuotationMasterId = decSalesquotationMasterId; infoSalesQuotationDetails.QuotationDetailsId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQuotationDetailsId"].Value); 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()); if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQuotationDetailsId"].Value) == 0) { infoSalesQuotationDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); } else { DGVUnitComboFill(); infoSalesQuotationDetails.UnitId = Convert.ToDecimal((dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString())); } decimal unitConversion = SpSalesQuotationDetails.UnitconversionIdViewByUnitIdAndProductId(infoSalesQuotationDetails.UnitId, infoSalesQuotationDetails.ProductId); infoSalesQuotationDetails.UnitConversionId = unitConversion; infoSalesQuotationDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value); infoSalesQuotationDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value); infoSalesQuotationDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value); infoSalesQuotationDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value); infoSalesQuotationDetails.Extra1 = string.Empty; infoSalesQuotationDetails.Extra2 = string.Empty; SpSalesQuotationDetails.SalesQuotationDetailsEdit(infoSalesQuotationDetails); } } catch (Exception ex) { MessageBox.Show("SQ:20" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// To fill the grid according to the pending Sales Quotation Invoice number /// </summary> public void FillQuotationDetails() { SerialNo(); try { SalesQuotationMasterSP spQuotationMaster = new SalesQuotationMasterSP(); SalesQuotationDetailsSP spQuotationDetails = new SalesQuotationDetailsSP(); DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo(); DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP(); decimal decOrderNo = 0; decimal DefaultRate = 0; string strSalesManId; inMaxCount = 0; decOrderNo = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); dgvProduct.Rows.Clear(); DataTable dtblMaster = spQuotationMaster.SalesQuotationMasterViewByQuotationMasterId(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString())); if (dtblMaster.Rows.Count > 0) { 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 dtblQuotationDetails = spQuotationDetails.SalesQuotationDetailsViewByquotationMasterIdWithRemainingByNotInCurrDN(Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()), decDeliveryNoteMasterId); int inRowIndex = 0; isValueChange = false; isDoAfterGridFill = false; foreach (DataRow drowDetails in dtblQuotationDetails.Rows) { dgvProduct.Rows.Add(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = drowDetails["barcode"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductId"].Value = drowDetails["productId"].ToString(); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = drowDetails["productCode"].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(); UnitComboFill1(Convert.ToDecimal(drowDetails["productId"].ToString()), 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()); 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["dgvtxtRate"].Value = drowDetails["Rate"].ToString(); DefaultRate = Convert.ToDecimal(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value.ToString()); dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = drowDetails["quotationDetailsId"].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 = Convert.ToDecimal(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("DN28 :" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void dgvProduct_CellLeave(object sender, DataGridViewCellEventArgs e) { try { if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtQty") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQuotationDetailsId"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQuotationDetailsId"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQuotationDetailsId"].Value.ToString()) != 0) { if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString() != string.Empty) { SalesQuotationDetailsSP spSalesQuationDetails = new SalesQuotationDetailsSP(); decimal decReferencedQty = Math.Round(spSalesQuationDetails.SalesQuatationReferenceCheck(Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQuotationDetailsId"].Value.ToString())),PublicVariables._inNoOfDecimalPlaces); decimal decQty = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value.ToString()); if (decQty < decReferencedQty) { Messages.InformationMessage("Quantity in row " + (e.RowIndex + 1) + " should be greater than " + decReferencedQty); IsCellValue = false; dgvProduct.Rows[e.RowIndex].Cells["dgvtxtQty"].Value = Math.Round(decReferencedQty,PublicVariables._inNoOfDecimalPlaces); IsCellValue = true; } } } AmountCalculation("dgvtxtQty", e.RowIndex); TotalAmountCalculation(); } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbUnit") { 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 = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[e.RowIndex].Cells["ProductId"].Value.ToString()); if (dtblUnitByProduct.Rows.Count > 0) { 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 (IsDoAfterFill) { 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, Convert.ToInt32(PublicVariables._inNoOfDecimalPlaces)); } } } AmountCalculation("dgvtxtQty", e.RowIndex); TotalAmountCalculation(); } } } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvcmbBatch") { if (dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { string strProductCode = string.Empty; ProductInfo infoproduct = new ProductInfo(); ProductSP SpProduct = new ProductSP(); decimal decBatchId = Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value); dgvProduct.Rows[e.RowIndex].Cells["dgvtxtBarcode"].Value = SpProduct.BarcodeViewByBatchId(decBatchId); strProductCode = dgvProduct.Rows[e.RowIndex].Cells["dgvtxtProductCode"].Value.ToString(); infoproduct = SpProduct.ProductViewByCode(strProductCode); DateTime dtcurrentDate = PublicVariables._dtCurrentDate; decimal decNodecplaces = PublicVariables._inNoOfDecimalPlaces; decimal decStandardRate = SpProduct.SalesInvoiceProductRateForSales(infoproduct.ProductId, dtcurrentDate, decBatchId, Convert.ToDecimal(cmbPricinglevel.SelectedValue), decNodecplaces); if (dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value) != 0) { dgvProduct.Rows[e.RowIndex].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[e.RowIndex].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces); } AmountCalculation("dgvtxtQty", e.RowIndex); TotalAmountCalculation(); } } } else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtExchangeRate" && isAmountcalc) { AmountCalculation("dgvtxtExchangeRate", e.RowIndex); TotalAmountCalculation(); } //---------------while changing Rate,corresponding change in amount---- else if (dgvProduct.Columns[e.ColumnIndex].Name == "dgvtxtRate" && isAmountcalc) { AmountCalculation("dgvtxtRate", e.RowIndex); TotalAmountCalculation(); } //----while changing amount ,corresponding chnage in total amount------- CheckInvalidEntriesInDataGridProduct(e); } catch (Exception ex) { MessageBox.Show("SQ:76" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to remove SalesQuatation details in edit mode /// </summary> public void RemoveSalesQuotationDetails() { SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP(); try { foreach (var strId in lstArrOfRemove) { decimal decDeleteId = Convert.ToDecimal(strId); SpSalesQuotationDetails.SalesQuotationDetailsDelete(decDeleteId); } } catch (Exception ex) { MessageBox.Show("SQ:18" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the details for edit or delete /// </summary> public void FillRegisterOrReport() { SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP(); TransactionsGeneralFill transactionGeneralFillObj = new TransactionsGeneralFill(); SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP(); ProductSP SpProduct = new ProductSP(); try { VoucherTypeSP spVoucherType = new VoucherTypeSP(); IsDoAfterFill = false; IsCellValue = false; btnSave.Text = "Update"; btnDelete.Enabled = true; infoSalesQuotationMaster = SpSalesQuotationMaster.SalesQuotationMasterView(decSalesquotationMasterId); txtQuotationNo.Text = infoSalesQuotationMaster.InvoiceNo; strVoucherNo = infoSalesQuotationMaster.VoucherNo.ToString(); decSalesQuotationPreffixSuffixId = Convert.ToDecimal(infoSalesQuotationMaster.SuffixPrefixId); decSalesQuotationVoucherId = Convert.ToDecimal(infoSalesQuotationMaster.VoucherTypeId); isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decSalesQuotationVoucherId); decsalesQuotationTypeId = decSalesQuotationVoucherId; txtSalesQuotationDate.Text = infoSalesQuotationMaster.Date.ToString("dd-MMM-yyyy"); cmbCashOrParty.SelectedValue = infoSalesQuotationMaster.LedgerId; ComboSalesManFill(); cmbSalesman.SelectedValue = infoSalesQuotationMaster.EmployeeId; txtNarration.Text = infoSalesQuotationMaster.Narration; cmbCurrency.SelectedValue = infoSalesQuotationMaster.ExchangeRateId; decimal decsalesregisterTotal = Convert.ToDecimal(infoSalesQuotationMaster.TotalAmount.ToString()); decsalesregisterTotal = Math.Round(decsalesregisterTotal, PublicVariables._inNoOfDecimalPlaces); txtTotal.Text = Convert.ToString(decsalesregisterTotal); cmbPricinglevel.SelectedValue = infoSalesQuotationMaster.PricinglevelId; DataTable dtbl = new DataTable(); dtbl = SpSalesQuotationDetails.SalesQuotationDetailsViewByMasterId(decSalesquotationMasterId); if (isAutomatic) { txtQuotationNo.ReadOnly = true; txtSalesQuotationDate.Focus(); } else { txtQuotationNo.ReadOnly = false; txtQuotationNo.Focus(); } string strApproved = Convert.ToString(infoSalesQuotationMaster.Approved); if (strApproved == "False") { cbxApproved.Checked = false; } else { cbxApproved.Checked = true; } decimal decCount = SpSalesQuotationMaster.CheckingStastusForSalesQuotation(decSalesquotationMasterId); if (decCount > 0) { cbxApproved.Enabled = false; } else { cbxApproved.Enabled = true; } for (int i = 0; i < dtbl.Rows.Count; i++) { isAmountcalc = false; dgvProduct.Rows.Add(); dgvProduct.Rows[i].HeaderCell.Value = string.Empty; dgvProduct.Rows[i].Cells["dgvtxtQuotationDetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["quotationDetailsId"].ToString()); dgvProduct.Rows[i].Cells["ProductId"].Value = dtbl.Rows[i]["productId"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = dtbl.Rows[i]["Barcode"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtProductCode"].Value = dtbl.Rows[i]["productCode"].ToString(); transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, dtbl.Rows[i]["productId"].ToString(), i); SpSalesQuotationMaster.SalesQuotationMasterBatchFill(dgvProduct, Convert.ToDecimal(dtbl.Rows[i]["productId"].ToString()), i); dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = dtbl.Rows[i]["productName"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = dtbl.Rows[i]["qty"].ToString(); IsCellValue = true; dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitId"].ToString()); IsCellValue = false; dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = dtbl.Rows[i]["rate"].ToString(); IsCellValue = true; dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = dtbl.Rows[i]["amount"].ToString(); IsCellValue = false; dgvProduct.Rows[i].Cells["dgvcmbbatch"].Value = Convert.ToDecimal(dtbl.Rows[i]["batchId"].ToString()); UnitConvertionSP SpUnitConvertion = new UnitConvertionSP(); DataTable dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[i].Cells["ProductId"].Value.ToString()); if (dtblUnitByProduct.Rows.Count > 0) { foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows) { if (dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); } } } decimal decStandardRate = SpProduct.SalesInvoiceProductRateForSales(Convert.ToDecimal(dtbl.Rows[i]["productId"].ToString()), PublicVariables._dtCurrentDate, Convert.ToDecimal(dtbl.Rows[i]["batchId"].ToString()), Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces); if (dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty) { if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value) != 0) { dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces); } } } isAmountcalc = true; IsCellValue = true; IsDoAfterFill = true; } catch (Exception ex) { MessageBox.Show("SQ:39" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete the salesquatation /// </summary> public void Delete() { SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP(); SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP(); try { decimal decResult2 = SpSalesQuotationMaster.SalesQuotationMasterDelete(decSalesquotationMasterId); decimal decResult1 = 0; if (decResult2 == 1) { for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++) { if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtquotationDetailsId"].Value) != 0) { decResult1 = SpSalesQuotationDetails.SalesQuotationDetailsDelete(Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtquotationDetailsId"].Value)); } } } if (decResult1 > 0 && decResult2 > 0) { Messages.DeletedMessage(); if (frmSalesQuotationRegisterObj != null) { this.Close(); frmSalesQuotationRegisterObj.Enabled = true; } if (frmSalesQuotationReportObj != null) { this.Close(); frmSalesQuotationReportObj.Enabled = true; } if (objVoucherSearch != null) { this.Close(); objVoucherSearch.Enabled = true; } if (frmDayBookObj != null) { this.Close(); frmDayBookObj.Enabled = true; } } else { Messages.ReferenceExistsMessage(); } } catch (Exception ex) { MessageBox.Show(" SQ:34" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit the SalesQuatation /// </summary> public void EditFunction() { SalesQuotationDetailsSP SpSalesQuotationDetails = new SalesQuotationDetailsSP(); SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); SalesQuotationMasterSP SpSalesQuotationMaster = new SalesQuotationMasterSP(); SettingsSP spSettings = new SettingsSP(); try { for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++) { if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtquotationDetailsId"].Value) != 0) { isEditDetails = Convert.ToString(SpSalesQuotationDetails.SalesQuotationRefererenceCheckForEditDetails(Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtquotationDetailsId"].Value))); } } isEditMaster = Convert.ToString(SpSalesQuotationMaster.SalesQuotationRefererenceCheckForEditMaster(decSalesquotationMasterId)); if (isEditMaster == "False" && isEditDetails == "False") { infoSalesQuotationMaster.QuotationMasterId = decSalesquotationMasterId; infoSalesQuotationMaster.Date = Convert.ToDateTime(txtSalesQuotationDate.Text); infoSalesQuotationMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoSalesQuotationMaster.SuffixPrefixId = Convert.ToDecimal(decSalesQuotationPreffixSuffixId); infoSalesQuotationMaster.VoucherNo = strVoucherNo; infoSalesQuotationMaster.VoucherTypeId = decSalesQuotationVoucherId; infoSalesQuotationMaster.InvoiceNo = txtQuotationNo.Text; infoSalesQuotationMaster.userId = PublicVariables._decCurrentUserId;//by default current userid used as current user id infoSalesQuotationMaster.EmployeeId = Convert.ToDecimal(cmbSalesman.SelectedValue.ToString()); infoSalesQuotationMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoSalesQuotationMaster.Narration = txtNarration.Text.Trim(); infoSalesQuotationMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text); infoSalesQuotationMaster.PricinglevelId = Convert.ToDecimal(cmbPricinglevel.SelectedValue.ToString()); infoSalesQuotationMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); if (cbxApproved.Checked) { infoSalesQuotationMaster.Approved = true; } else { infoSalesQuotationMaster.Approved = false; } infoSalesQuotationMaster.Extra1 = string.Empty; infoSalesQuotationMaster.Extra2 = string.Empty; SpSalesQuotationMaster.SalesQuotationMasterEdit(infoSalesQuotationMaster); RemoveSalesQuotationDetails(); NewRowAddedToSalesQuotationDetails(); SalesQuotationDetailsEditFill(); Messages.UpdatedMessage(); if (frmSalesQuotationRegisterObj != null) { if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesquotationMasterId); } else { Print(decSalesquotationMasterId); } } this.Close(); frmSalesQuotationRegisterObj.GridFill(); } if (frmSalesQuotationReportObj != null) { if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesquotationMasterId); } else { Print(decSalesquotationMasterId); } } this.Close(); frmSalesQuotationReportObj.GridFill(); } if (frmDayBookObj != null) { if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesquotationMasterId); } else { Print(decSalesquotationMasterId); } } this.Close(); } if (objfrmVoucherSearch != null) { if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesquotationMasterId); } else { Print(decSalesquotationMasterId); } } this.Close(); } if (objVoucherSearch != null) { if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesquotationMasterId); } else { Print(decSalesquotationMasterId); } } this.Close(); } } else { Messages.ReferenceExistsMessageForUpdate(); } } catch (Exception ex) { MessageBox.Show("SQ:33" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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); } }
/// <summary> /// Fill Details Corresponding Quotation No /// </summary> public void FillQuotationDetails() { SerialNo(); try { SalesOrderDetailsInfo infoSalesOrderDetails = new SalesOrderDetailsInfo(); TransactionsGeneralFill TransactionGeneralFillObj = new TransactionsGeneralFill(); decimal decOrderNo = 0; if (!isEditFill) { inMaxCount = 0; decOrderNo = Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString()); dgvSalesOrder.Rows.Clear(); DataTable dtblMaster = new SalesQuotationMasterSP().QuotationMasterViewByQuotationMasterId(Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString())); if (dtblMaster.Rows.Count > 0) { cmbPricingLevel.SelectedValue = dtblMaster.Rows[0]["pricingLevelId"].ToString(); if (dtblMaster.Rows[0]["employeeId"].ToString() != "") { strSalesMan = dtblMaster.Rows[0]["employeeId"].ToString(); cmbSalesMan.SelectedValue = strSalesMan; if (cmbSalesMan.SelectedValue == null) { SalesManComboFill(); cmbSalesMan.SelectedValue = dtblMaster.Rows[0]["employeeId"].ToString(); } } DGVCurrencyComboFill(); cmbCurrency.SelectedValue = dtblMaster.Rows[0]["exchangeRateId"].ToString(); DataTable dtblDetails = new SalesQuotationDetailsSP().SalesQuotationDetailsViewByquotationMasterIdWithRemainingBySO(Convert.ToDecimal(cmbQuotationNo.SelectedValue.ToString()), decSalesOrderMasterId); int inRowIndex = 0; foreach (DataRow drowDetails in dtblDetails.Rows) { dgvSalesOrder.Rows.Add(); isValueChange = false; isDoAfterGridFill = false; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtSalesOrderDetailsId"].Value = drowDetails.ItemArray[0].ToString(); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtSalesQuotationDetailsId"].Value = drowDetails.ItemArray[0].ToString(); String ProductId = drowDetails.ItemArray[2].ToString(); infoProduct = new ProductSP().ProductView(Convert.ToDecimal(ProductId)); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = drowDetails["barcode"].ToString(); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductId"].Value = drowDetails["productId"]; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = infoProduct.ProductCode; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductName"].Value = drowDetails["productName"].ToString(); AssignProductDefaultValues(dgvSalesOrder.Rows.Count - 2, drowDetails["productId"].ToString()); TransactionGeneralFillObj.UnitViewAllByProductId(dgvSalesOrder, infoProduct.ProductId.ToString(), dgvSalesOrder.Rows.Count - 2); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtQty"].Value = drowDetails["qty"].ToString(); UnitComboFill(Convert.ToDecimal(ProductId), dgvSalesOrder.Rows.Count - 2, dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString()); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtRate"].Value = drowDetails["rate"].ToString(); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtAmount"].Value = drowDetails["amount"].ToString(); BatchComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvSalesOrder.Rows.Count - 2, dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex); if (Convert.ToDecimal(drowDetails["batchId"].ToString()) != 0) { dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString()); } else { StockPostingSP spStockPosting = new StockPostingSP(); decimal decBatchId = spStockPosting.BatchViewByProductId(Convert.ToDecimal(ProductId)); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbBatch"].Value = decBatchId; } string strBarcode = new BatchSP().ProductBatchBarcodeViewByBatchId(Convert.ToDecimal(dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbBatch"].Value.ToString())); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = strBarcode.ToString(); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductCode"].ReadOnly = true; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductName"].ReadOnly = true; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true; dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["inRowIndex"].Value = drowDetails["extra1"].ToString(); UnitConvertionSP SpUnitConvertion = new UnitConvertionSP(); DataTable dtblUnitByProduct = new DataTable(); dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtProductId"].Value.ToString()); foreach (DataRow drUnitByProduct in dtblUnitByProduct.Rows) { if (dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString()) { dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString()); dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString()); } } decCurrentConversionRate = Convert.ToDecimal(dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value.ToString()); decCurrentRate = Convert.ToDecimal(dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvtxtRate"].Value.ToString()); if (cmbQuotationNo.Visible == true) { dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true; } dgvSalesOrder.Rows[dgvSalesOrder.Rows.Count - 2].HeaderCell.Value = ""; int intIndex = 0; int.TryParse(drowDetails["extra1"].ToString(), out intIndex); if (inMaxCount < intIndex) inMaxCount = intIndex; inRowIndex++; isValueChange = true; } for (int i = inRowIndex; i < dgvSalesOrder.Rows.Count; ++i) dgvSalesOrder["inRowIndex", i].Value = GetNextinRowIndex().ToString(); SerialNo(); TotalAmountCalculation(); isDoAfterGridFill = true; } } } catch (Exception ex) { MessageBox.Show("SO38: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }