/// <summary> /// Function to fill the product details /// </summary> /// <param name="strProduct"></param> /// <param name="inRowIndex"></param> /// <param name="strFillMode"></param> public void ProductDetailsFill(string strProduct, int inRowIndex, string strFillMode) { decimal decProductId = 0; decimal decGodownId = 0; PurchaseInvoiceBll BllPurchaseInvoice = new PurchaseInvoiceBll(); List<DataTable> ListObj = new List<DataTable>(); try { if (strFillMode == "ProductCode") { ListObj = BllPurchaseInvoice.PurchaseDetailsViewByProductCodeForPI(decPurchaseInvoiceVoucherTypeId, strProduct); } else if (strFillMode == "ProductName") { ListObj = BllPurchaseInvoice.PurchaseDetailsViewByProductNameForPI(decPurchaseInvoiceVoucherTypeId, strProduct); } else if (strFillMode == "Barcode") { ListObj = BllPurchaseInvoice.PurchaseDetailsViewByBarcodeForPI(decPurchaseInvoiceVoucherTypeId, strProduct); } if (ListObj[0].Rows.Count >= 1) { decProductId = Convert.ToDecimal(ListObj[0].Rows[0]["productId"]); decGodownId = Convert.ToDecimal(ListObj[0].Rows[0]["godownId"]); UnitComboFill(decProductId, inRowIndex, dgvProductDetails.Columns["dgvcmbUnit"].Index); GodownComboFill(); RackComboFill(decGodownId, inRowIndex, dgvProductDetails.Columns["dgvcmbRack"].Index); BatchComboFill(decProductId, inRowIndex, dgvProductDetails.Columns["dgvcmbBatch"].Index); dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtPurchaseDetailsId"].Value = ListObj[0].Rows[0]["purchaseDetailsId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtPurchaseOrderDetailsId"].Value = ListObj[0].Rows[0]["purchaseOrderDetailsId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtMaterialReceiptDetailsId"].Value = ListObj[0].Rows[0]["materialReceiptDetailsId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value = ListObj[0].Rows[0]["productId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtBarcode"].Value = ListObj[0].Rows[0]["barcode"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[0]["productCode"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[0]["productName"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtUnitConversionId"].Value = ListObj[0].Rows[0]["unitConversionId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbUnit"].Value = ListObj[0].Rows[0]["unitId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbGodown"].Value = ListObj[0].Rows[0]["godownId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbRack"].Value = ListObj[0].Rows[0]["rackId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbBatch"].Value = ListObj[0].Rows[0]["batchId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value = ListObj[0].Rows[0]["rate"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtGrossValue"].Value = ListObj[0].Rows[0]["grossValue"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = ListObj[0].Rows[0]["discountPercent"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = ListObj[0].Rows[0]["discount"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtNetValue"].Value = ListObj[0].Rows[0]["netvalue"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value = ListObj[0].Rows[0]["taxId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtTaxAmount"].Value = ListObj[0].Rows[0]["taxAmount"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[0]["amount"]; dgvProductDetails.Rows[inRowIndex].HeaderCell.Value = "X"; dgvProductDetails.Rows[inRowIndex].HeaderCell.Style.ForeColor = Color.Red; } else { if (strProductCode != string.Empty) { ProductDetailsFill(strProductCode, inRowIndex, "ProductCode"); } else { dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtPurchaseDetailsId"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtPurchaseOrderDetailsId"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtMaterialReceiptDetailsId"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtBarcode"].Value = string.Empty; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value = string.Empty; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductName"].Value = string.Empty; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtQuantity"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtUnitConversionId"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbUnit"].Value = Convert.ToDecimal("0"); dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbGodown"].Value = Convert.ToDecimal("0"); dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbRack"].Value = Convert.ToDecimal("0"); dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbBatch"].Value = Convert.ToDecimal("0"); dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtGrossValue"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtNetValue"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value = Convert.ToDecimal("0"); dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtTaxAmount"].Value = 0; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtAmount"].Value = 0; dgvProductDetails.Rows[inRowIndex].HeaderCell.Value = "X"; dgvProductDetails.Rows[inRowIndex].HeaderCell.Style.ForeColor = Color.Red; } } } catch (Exception ex) { MessageBox.Show("PI49:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }