/// <summary> /// Grid CellEndEdit for product details fill to curresponding row in grid /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvPurchaseReturn_CellEndEdit(object sender, DataGridViewCellEventArgs e) { try { string strBarcode2 = string.Empty; decimal decBatchId2 = 0; BatchSP spBatch = new BatchSP(); ProductSP spProduct = new ProductSP(); PurchaseDetailsSP SPPurchaseDetails = new PurchaseDetailsSP(); PurchaseReturnDetailsSP SPPurchaseReturnDetails = new PurchaseReturnDetailsSP(); if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtproductName") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value.ToString().Trim() != string.Empty) { ProductInfo infoProduct = spProduct.ProductViewByName(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value.ToString()); if (infoProduct.ProductCode != null && infoProduct.ProductCode != string.Empty) { FillProductDetails(infoProduct.ProductCode.ToString(), e.RowIndex); } else { StringEmptyDetailsInGrid(); } } else { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductName"].Value = string.Empty; } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtproductCode") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value.ToString().Trim() != string.Empty) { ProductInfo infoProduct = spProduct.ProductViewByCode(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value.ToString()); if (infoProduct.ProductName != null && infoProduct.ProductCode != string.Empty) { FillProductDetails(infoProduct.ProductCode.ToString(), e.RowIndex); } else { StringEmptyDetailsInGrid(); } } else { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value = string.Empty; } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtbarcode") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value.ToString().Trim() != string.Empty) { string strBarcode = dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value.ToString(); decBatchId = spProduct.BatchIdByPartNoOrBarcode(strBarcode, strBarcode); if (decBatchId > 0) { DataTable dtblBatchName = new DataTable(); dtblBatchName = spProduct.ProductCodeAndBarcodeByBatchId(decBatchId); dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtproductCode"].Value = dtblBatchName.Rows[0]["productCode"].ToString(); if (dtblBatchName.Rows[0]["barcode"].ToString() != null && dtblBatchName.Rows[0]["barcode"].ToString() != string.Empty) { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value = dtblBatchName.Rows[0]["barcode"].ToString(); } decimal batchId = spBatch.BatchViewByBarcode(strBarcode); dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value = batchId; FillProductDetails(dtblBatchName.Rows[0]["productCode"].ToString(), e.RowIndex); } else { StringEmptyDetailsInGrid(); } } else { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtbarcode"].Value = string.Empty; } } if (e.ColumnIndex == dgvPurchaseReturn.Columns["dgvcmbUnit"].Index) { if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbUnit") { if ((dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value != null) && (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbUnit"].Value.ToString() != string.Empty)) { UnitConversionCalc(e.RowIndex); AmountCalculation("dgvtxtqty", e.RowIndex); } } } if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtqty" && isAmountcalc) { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) != 0) { if (cmbInvoiceNo.SelectedValue == null || cmbInvoiceNo.SelectedValue.ToString() == string.Empty) { AmountCalculation("dgvtxtqty", e.RowIndex); } else { DataTable dtbl = SPPurchaseDetails.PurchaseDetailsViewByPurchaseMasterIdWithRemaining(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()), decPurchaseReturnMasterId, decPurchaseReturnVoucherTypeId); if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtPurchaseDetailsId"].Value != null) { if (Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtPurchaseDetailsId"].Value.ToString()) > 0) { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null) { if (Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) > Convert.ToDecimal(dtbl.Rows[e.RowIndex]["qty"].ToString())) { dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value = Math.Round(Convert.ToDecimal(dtbl.Rows[e.RowIndex]["qty"].ToString()), PublicVariables._inNoOfDecimalPlaces); } } } } AmountCalculation("dgvtxtqty", e.RowIndex); } } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtrate" && isAmountcalc) { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString() != string.Empty && Convert.ToDecimal(dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtqty"].Value.ToString()) != 0) { AmountCalculation("dgvtxtrate", e.RowIndex); } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvtxtdiscount") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtdiscount"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtdiscount"].Value.ToString().Trim() != string.Empty && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvtxtDiscount"].Value.ToString().Trim() != "0") { AmountCalculation("dgvtxtrate", e.RowIndex); } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbTax" && isAmountcalc) { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbTax"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbTax"].Value.ToString() != string.Empty) { AmountCalculation("dgvtxtrate", e.RowIndex); } } else if (dgvPurchaseReturn.Columns[e.ColumnIndex].Name == "dgvcmbBatch") { if (dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value != null && dgvPurchaseReturn.Rows[e.RowIndex].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { decBatchId2 = Convert.ToDecimal(dgvPurchaseReturn.CurrentRow.Cells["dgvcmbBatch"].Value); strBarcode2 = spBatch.ProductBatchBarcodeViewByBatchId(decBatchId2); dgvPurchaseReturn.CurrentRow.Cells["dgvtxtbarcode"].Value = strBarcode2; } } CheckInvalidEntries(e); } catch (Exception ex) { MessageBox.Show("PR:80" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Product Details fill in the grid here /// </summary> /// <param name="strProduct"></param> /// <param name="inRowIndex"></param> /// <param name="strFillMode"></param> public void ProductDetailsFill(string strProduct, int inRowIndex, string strFillMode) { PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); SalesDetailsSP spSalesDetails = new SalesDetailsSP(); DataTable dtbl = new DataTable(); try { gridCombofill(); if (strFillMode == "ProductCode") { dtbl = spSalesDetails.SalesInvoiceDetailsViewByProductCodeForSI(DecSalesInvoiceVoucherTypeId, strProduct); } else if (strFillMode == "ProductName") { dtbl = spSalesDetails.SalesInvoiceDetailsViewByProductNameForSI(DecSalesInvoiceVoucherTypeId, strProduct); } else if (strFillMode == "Barcode") { dtbl = spSalesDetails.SalesInvoiceDetailsViewByBarcodeForSI(DecSalesInvoiceVoucherTypeId, strProduct); } if (dtbl.Rows.Count != 0) { IsSetGridValueChange = false; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value = dtbl.Rows[0]["salseDetailsId"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSISalesOrderDetailsId"].Value = dtbl.Rows[0]["salesOrderDetailsId"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value = dtbl.Rows[0]["deliveryNoteDetailsId"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value = dtbl.Rows[0]["salesQuotationDetailsId"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceProductId"].Value = dtbl.Rows[0]["productId"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceBrand"].Value = dtbl.Rows[0]["brandName"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = dtbl.Rows[0]["purchaseRate"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceSalesRate"].Value = dtbl.Rows[0]["salesRate"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceMrp"].Value = dtbl.Rows[0]["Mrp"]; decimal decProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceBarcode"].Value = dtbl.Rows[0]["barcode"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceProductCode"].Value = dtbl.Rows[0]["productCode"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value = dtbl.Rows[0]["productName"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(dtbl.Rows[0]["unitId"].ToString()); dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = dtbl.Rows[0]["unitConversionId"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(dtbl.Rows[0]["batchId"].ToString()); decimal decBatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inRowIndex].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); getProductRate(inRowIndex, decProductId, decBatchId); dgvSalesInvoice.Rows[inRowIndex].Cells["dgvcmbSalesInvoiceGodown"].Value = Convert.ToDecimal(dtbl.Rows[0]["godownId"].ToString()); RackComboFill(Convert.ToDecimal(dgvSalesInvoice.Rows[inRowIndex].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()), inRowIndex, dgvSalesInvoice.Rows[inRowIndex].Cells["dgvcmbSalesInvoiceRack"].ColumnIndex); dgvSalesInvoice.Rows[inRowIndex].Cells["dgvcmbSalesInvoiceRack"].Value = Convert.ToDecimal(dtbl.Rows[0]["rackId"].ToString()); dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceDiscountPercentage"].Value = dtbl.Rows[0]["discountPercent"].ToString(); dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value = dtbl.Rows[0]["discount"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceNetAmount"].Value = dtbl.Rows[0]["netvalue"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvcmbSalesInvoiceTaxName"].Value = dtbl.Rows[0]["taxId"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceTaxAmount"].Value = dtbl.Rows[0]["taxAmount"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceAmount"].Value = dtbl.Rows[0]["amount"]; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceConversionRate"].Value = dtbl.Rows[0]["conversionRate"]; GrossValueCalculation(inRowIndex); DiscountCalculation(inRowIndex, 22); DiscountCalculation(inRowIndex, 23); taxAndGridTotalAmountCalculation(inRowIndex); decCurrentRate = Convert.ToDecimal(dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); decCurrentConversionRate = Convert.ToDecimal(dtbl.Rows[0]["conversionRate"].ToString()); UnitConversionCalc(inRowIndex); SiGridTotalAmountCalculation(); IsSetGridValueChange = true; } //else //{ //if (strProductCode != string.Empty) //{ // ProductDetailsFill(strProduct, inRowIndex, "ProductCode"); //} else { if (dgvSalesInvoice.CurrentRow.Index < dgvSalesInvoice.RowCount - 1) { dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSISalesOrderDetailsId"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceProductId"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceBarcode"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceProductCode"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceProductName"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceBrand"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceQty"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceSalesRate"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceMrp"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceNetAmount"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceBrand"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceTaxAmount"].Value = string.Empty; dgvSalesInvoice.Rows[inRowIndex].Cells["dgvtxtSalesInvoiceAmount"].Value = string.Empty; SerialNoforSalesInvoice(); } } //} } catch (Exception ex) { MessageBox.Show("SI: 60" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Remove incomplete Rows from grid /// </summary> public bool RemoveIncompleteRowsFromGrid() { bool isOk = true; PurchaseDetailsSP SPPurchaseDetails = new PurchaseDetailsSP(); SettingsSP spSettings = new SettingsSP(); try { string strMessage = "Rows"; int inC = 0, inForFirst = 0; int inRowcount = dgvPurchaseReturn.RowCount; int inLastRow = 1; if (inRowcount <= 2) { if (dgvPurchaseReturn.Rows[0].Cells["dgvtxtproductName"].Value == null || dgvPurchaseReturn.Rows[0].Cells["dgvtxtproductName"].Value.ToString() == string.Empty || dgvPurchaseReturn.Rows[0].Cells["dgvtxtproductCode"].Value == null || dgvPurchaseReturn.Rows[0].Cells["dgvtxtproductCode"].Value.ToString() == string.Empty || dgvPurchaseReturn.Rows[0].Cells["dgvtxtrate"].Value == null || dgvPurchaseReturn.Rows[0].Cells["dgvtxtrate"].Value.ToString().Trim() == string.Empty || dgvPurchaseReturn.Rows[0].Cells["dgvtxtqty"].Value == null || dgvPurchaseReturn.Rows[0].Cells["dgvtxtqty"].Value.ToString().Trim() == string.Empty || Convert.ToDecimal(dgvPurchaseReturn.Rows[0].Cells["dgvtxtqty"].Value.ToString()) == 0 || (spSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && Convert.ToDecimal(dgvPurchaseReturn.Rows[0].Cells["dgvtxtrate"].Value) == 0)) { Messages.InformationMessage("Can't save purchase return without atleast one product with complete details"); dgvPurchaseReturn.ClearSelection(); dgvPurchaseReturn.Focus(); isOk = false; } } else { foreach (DataGridViewRow dgvrowCur in dgvPurchaseReturn.Rows) { if (inLastRow < inRowcount && dgvrowCur.HeaderCell.Value != null) { if (dgvrowCur.HeaderCell.Value.ToString() == "X" || dgvrowCur.Cells["dgvtxtproductName"].Value == null) { isOk = false; if (inC == 0) { strMessage = strMessage + Convert.ToString(dgvrowCur.Index + 1); inForFirst = dgvrowCur.Index; inC++; } else { strMessage = strMessage + ", " + Convert.ToString(dgvrowCur.Index + 1); } } } inLastRow++; } inLastRow = 1; if (!isOk) { strMessage = strMessage + " contains invalid entries. Do you want to continue?"; if (MessageBox.Show(strMessage, "OpenMiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { isOk = true; for (int inK = 0; inK < dgvPurchaseReturn.Rows.Count; inK++) { if (dgvPurchaseReturn.Rows[inK].HeaderCell.Value != null && dgvPurchaseReturn.Rows[inK].HeaderCell.Value.ToString() == "X" && !dgvPurchaseReturn.Rows[inK].IsNewRow) { dgvPurchaseReturn.Rows.RemoveAt(inK); inK--; SerialNo(); } } } else { isOk = false; dgvPurchaseReturn.Rows[inForFirst].Cells["dgvtxtproductName"].Selected = true; dgvPurchaseReturn.CurrentCell = dgvPurchaseReturn.Rows[inForFirst].Cells["dgvtxtproductName"]; dgvPurchaseReturn.Focus(); } } } } catch (Exception ex) { MessageBox.Show("PR:47" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isOk; }
/// <summary> /// Function to fill Voucher Type combobox /// </summary> public void VoucherTypeCombofill() { PurchaseDetailsSP SPPurchaseDetails = new PurchaseDetailsSP(); try { DataTable dtbl = new DataTable(); dtbl = SPPurchaseDetails.VoucherTypeComboFillForPurchaseInvoice(); cmbVoucherType.DataSource = dtbl; cmbVoucherType.ValueMember = "voucherTypeId"; cmbVoucherType.DisplayMember = "voucherTypeName"; cmbVoucherType.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show("PR:04" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill purchase details /// </summary> public void PurchaseDetailsFill() { DataTable dtbl = new DataTable(); PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP(); try { GridComboFill(); dtbl = spPurchaseDetails.PurchaseDetailsViewByPurchaseMasterId(decPurchaseMasterId); int i = 0; foreach (DataRow dr in dtbl.Rows) { dgvProductDetails.Rows.Add(); dgvProductDetails.Rows[i].Cells["dgvtxtPurchaseDetailsId"].Value = dr["purchaseDetailsId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = dr["purchaseOrderDetailsId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtMaterialReceiptDetailsId"].Value = dr["materialReceiptDetailsId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtProductId"].Value = dr["productId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtBarcode"].Value = dr["barcode"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtProductCode"].Value = dr["productCode"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtProductName"].Value = dr["productName"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtQuantity"].Value = dr["qty"].ToString(); UnitComboFill(Convert.ToDecimal(dr["productId"].ToString()), i, dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].ColumnIndex); dgvProductDetails.Rows[i].Cells["dgvtxtUnitConversionId"].Value = dr["unitConversionId"].ToString(); dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dr["unitId"].ToString()); dgvProductDetails.Rows[i].Cells["dgvcmbGodown"].Value = 1m; dgvProductDetails.Rows[i].Cells["dgvcmbRack"].Value = 1m; BatchComboFill(Convert.ToDecimal(dr["productId"].ToString()), i, dgvProductDetails.Rows[i].Cells["dgvcmbBatch"].ColumnIndex); dgvProductDetails.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(dr["batchId"].ToString()); dgvProductDetails.Rows[i].Cells["dgvtxtRate"].Value = dr["rate"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtGrossValue"].Value = dr["grossValue"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtDiscountPercent"].Value = dr["discountPercent"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtDiscount"].Value = dr["discount"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtNetValue"].Value = dr["netvalue"].ToString(); dgvProductDetails.Rows[i].Cells["dgvcmbTax"].Value = Convert.ToDecimal(dr["taxId"].ToString()); dgvProductDetails.Rows[i].Cells["dgvtxtTaxAmount"].Value = dr["taxAmount"].ToString(); dgvProductDetails.Rows[i].Cells["dgvtxtAmount"].Value = dr["Amount"].ToString(); int inRef = spPurchaseMaster.PurchaseMasterReferenceCheck(decPurchaseMasterId, Convert.ToDecimal(dr["purchaseDetailsId"].ToString())); if (Convert.ToDecimal(dr["purchaseOrderDetailsId"].ToString()) != 0 || Convert.ToDecimal(dr["materialReceiptDetailsId"].ToString()) != 0 || inRef == 1) { dgvProductDetails.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true; } i++; } if (cmbPurchaseMode.SelectedIndex > 1) { dgvProductDetails.AllowUserToAddRows = false; } SerialNo(); } catch (Exception ex) { MessageBox.Show("PI56:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Product details fill in grid corresponding to invoice number /// </summary> public void InvoiceDetailsFill() { PurchaseDetailsSP SPPurchaseDetails = new PurchaseDetailsSP(); try { if (!isEditFill) { inMaxCount = 0; string strTaxRate1 = string.Empty; string strproductId = string.Empty; decimal decTaxAmount = 0; decimal decAmount = 0; decimal decNetAmount = 0; decimal decTaxRate = 0; decimal decDiscountAmount = 0; decimal decGrossAmount = 0; int inRowIndex = 0; UnitConvertionSP SPUnitConversion = new UnitConvertionSP(); PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP(); DataTable dtblDetails = SPPurchaseDetails.PurchaseDetailsViewByPurchaseMasterIdWithRemaining(Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()), decPurchaseReturnMasterId, decPurchaseReturnVoucherTypeId); dgvPurchaseReturn.Rows.Clear(); foreach (DataRow drowDetails in dtblDetails.Rows) { dgvPurchaseReturn.Rows.Add(); DGVUnitComboFill(); DGVBatchComboFill(); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtPurchaseDetailsId"].Value = drowDetails.ItemArray[0].ToString(); strproductId = drowDetails.ItemArray[2].ToString(); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtproductId"].Value = Convert.ToString(drowDetails.ItemArray[2]); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtproductName"].Value = Convert.ToString(drowDetails.ItemArray[5]); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtproductCode"].Value = Convert.ToString(drowDetails.ItemArray[6]); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtVoucherTypeId"].Value = Convert.ToString(drowDetails.ItemArray[21]); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtVoucherNo"].Value = Convert.ToString(drowDetails.ItemArray[23]); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtInvoiceNo"].Value = Convert.ToString(drowDetails.ItemArray[22]); decQty = Math.Round(Convert.ToDecimal(Convert.ToString(drowDetails.ItemArray[10])), PublicVariables._inNoOfDecimalPlaces); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtqty"].Value = decQty; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtrate"].Value = Convert.ToString(drowDetails.ItemArray[11]); decRate = Math.Round(Convert.ToDecimal(Convert.ToString(drowDetails.ItemArray[11])), PublicVariables._inNoOfDecimalPlaces); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtbarcode"].Value = Convert.ToString(drowDetails.ItemArray[8]); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = SPUnitConversion.UnitConversionRateByUnitConversionId(Convert.ToDecimal(drowDetails.ItemArray[9].ToString())); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drowDetails.ItemArray[9].ToString()); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvcmbGodown"].Value = (Convert.ToString(drowDetails.ItemArray[17]) != null) ? Convert.ToDecimal(drowDetails.ItemArray[17].ToString()) : 0; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvcmbRack"].Value = (drowDetails.ItemArray[18].ToString() != null) ? Convert.ToDecimal(drowDetails.ItemArray[18].ToString()) : 0; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvcmbBatch"].Value = (drowDetails.ItemArray[19].ToString() != null) ? Convert.ToDecimal(drowDetails.ItemArray[19].ToString()) : 0; decGrossAmount = decQty * decRate; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails.ItemArray[12].ToString()); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drowDetails.ItemArray[9]); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtgrossValue"].Value = Math.Round(decGrossAmount, PublicVariables._inNoOfDecimalPlaces); if (Convert.ToString(drowDetails.ItemArray[7]) != string.Empty) { dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtdiscount"].Value = Convert.ToString(drowDetails.ItemArray[7]); decDiscountAmount = Math.Round(Convert.ToDecimal(Convert.ToString(drowDetails.ItemArray[7])), PublicVariables._inNoOfDecimalPlaces); } else { decDiscountAmount = 0; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtdiscount"].Value = 0; } decNetAmount = decGrossAmount - decDiscountAmount; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtNetAmount"].Value = (decNetAmount != 0) ? Math.Round(decNetAmount, PublicVariables._inNoOfDecimalPlaces) : 0; if (strTaxComboFill != string.Empty) { if (drowDetails.ItemArray[13].ToString() != string.Empty && Convert.ToDecimal(drowDetails.ItemArray[13].ToString()) != 0) { dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvcmbTax"].Value = Convert.ToDecimal(drowDetails.ItemArray[13].ToString()); strTaxRate1 = SPPurchaseReturnMaster.TaxRateFromPurchaseDetails(Convert.ToDecimal(Convert.ToString(drowDetails.ItemArray[13]))); } else { dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvcmbTax"].Value = "NA"; strTaxRate1 = string.Empty; } if (strTaxRate1 != string.Empty) { decTaxRate = Convert.ToDecimal(strTaxRate1); decTaxAmount = ((decNetAmount * decTaxRate) / 100); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxttaxAmount"].Value = Math.Round(decTaxAmount, PublicVariables._inNoOfDecimalPlaces); } else { dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxttaxAmount"].Value = 0; } } else { dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxttaxAmount"].Value = 0; } decAmount = decNetAmount + decTaxAmount; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtAmount"].Value = Math.Round(decAmount, PublicVariables._inNoOfDecimalPlaces); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtproductCode"].ReadOnly = true; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtproductName"].ReadOnly = true; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtbarcode"].ReadOnly = true; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvcmbBatch"].ReadOnly = true; dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 2].Cells["dgvtxtInRowIndex"].Value = Convert.ToString(drowDetails["extra1"]); dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 1].ReadOnly = true; int intIndex = 0; int.TryParse(Convert.ToString(drowDetails["extra1"]), out intIndex); if (inMaxCount < intIndex) inMaxCount = intIndex; inRowIndex++; } for (int i = inRowIndex; i < dgvPurchaseReturn.Rows.Count; ++i) dgvPurchaseReturn["dgvtxtInRowIndex", i].Value = Convert.ToString(GetNextinRowIndex()); CalculateTotalAmount(); } } catch (Exception ex) { MessageBox.Show("PR:42" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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; PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); DataTable dtbl = new DataTable(); try { if (strFillMode == "ProductCode") { dtbl = spPurchaseDetails.PurchaseDetailsViewByProductCodeForPI(decPurchaseInvoiceVoucherTypeId, strProduct); } else if (strFillMode == "ProductName") { dtbl = spPurchaseDetails.PurchaseDetailsViewByProductNameForPI(decPurchaseInvoiceVoucherTypeId, strProduct); } else if (strFillMode == "Barcode") { dtbl = spPurchaseDetails.PurchaseDetailsViewByBarcodeForPI(decPurchaseInvoiceVoucherTypeId, strProduct); } if (dtbl.Rows.Count >= 1) { decProductId = Convert.ToDecimal(dtbl.Rows[0]["productId"]); decGodownId = Convert.ToDecimal(dtbl.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 = dtbl.Rows[0]["purchaseDetailsId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtPurchaseOrderDetailsId"].Value = dtbl.Rows[0]["purchaseOrderDetailsId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtMaterialReceiptDetailsId"].Value = dtbl.Rows[0]["materialReceiptDetailsId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductId"].Value = dtbl.Rows[0]["productId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtBarcode"].Value = dtbl.Rows[0]["barcode"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductCode"].Value = dtbl.Rows[0]["productCode"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtProductName"].Value = dtbl.Rows[0]["productName"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtUnitConversionId"].Value = dtbl.Rows[0]["unitConversionId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbUnit"].Value = dtbl.Rows[0]["unitId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbGodown"].Value = dtbl.Rows[0]["godownId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbRack"].Value = dtbl.Rows[0]["rackId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbBatch"].Value = dtbl.Rows[0]["batchId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtRate"].Value = dtbl.Rows[0]["rate"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtGrossValue"].Value = dtbl.Rows[0]["grossValue"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscountPercent"].Value = dtbl.Rows[0]["discountPercent"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtDiscount"].Value = dtbl.Rows[0]["discount"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtNetValue"].Value = dtbl.Rows[0]["netvalue"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvcmbTax"].Value = dtbl.Rows[0]["taxId"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtTaxAmount"].Value = dtbl.Rows[0]["taxAmount"]; dgvProductDetails.Rows[inRowIndex].Cells["dgvtxtAmount"].Value = dtbl.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); } }
public void Delete() { PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP(); PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); PurchaseBillTaxSP spPurchaseBillTax = new PurchaseBillTaxSP(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); StockPostingSP spStockPosting = new StockPostingSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo(); MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo(); /*---------------------------------Deleting previous stock posting, Ledger posting, partybalanceposting---------------------------------------*/ infoPurchaseMaster = spPurchaseMaster.PurchaseMasterView(decPurchaseMasterId); if (infoPurchaseMaster.MaterialReceiptMasterId != 0) { infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId); spStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote (infoPurchaseMaster.VoucherTypeId, infoPurchaseMaster.VoucherNo, infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId); } spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (0, "NA", infoPurchaseMaster.VoucherNo, infoPurchaseMaster.VoucherTypeId); //------------------------------------------------- decimal decPurchaseDetailsId = 0; decimal decPurchaseOrderMasterId = 0; decimal decMaterialReceiptMasterId = 0; decimal decAdditionalCostId = 0; decimal decPurchaseBillTaxId = 0; int inRef = 0; bool isRef = false; try { foreach (DataGridViewRow dgvrow in dgvProductDetails.Rows) { if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() != "0") { decPurchaseDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString()); inRef = spPurchaseMaster.PurchaseMasterReferenceCheck(decPurchaseMasterId, decPurchaseDetailsId); if (inRef > 0 && !isRef) { isRef = true; } } } } if (!isRef) { isRef = spAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, decPurchaseInvoiceVoucherTypeId); if (!isRef) { spPurchaseMaster.PurchaseMasterDelete(decPurchaseMasterId); spPurchaseDetails.PurchaseDetailsDeleteByPurchaseMasterId(decPurchaseMasterId); foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows) { if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value != null) { if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != "0") { decAdditionalCostId = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString()); spAdditionalCost.AdditionalCostDelete(decAdditionalCostId); } } } if (dgvTax.Visible) { foreach (DataGridViewRow dgvrow in dgvTax.Rows) { if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != "0") { decPurchaseBillTaxId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString()); spPurchaseBillTax.PurchaseBillTaxDelete(decPurchaseBillTaxId); } } } } if (cmbPurchaseMode.Text == "Against PurchaseOrder") { decPurchaseOrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoPurchaseOrderMaster = spPurchaseOrderMaster.PurchaseOrderMasterView(decPurchaseOrderMasterId); } else if (cmbPurchaseMode.Text == "Against MaterialReceipt") { decMaterialReceiptMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(decMaterialReceiptMasterId); } spLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseInvoiceVoucherTypeId); if (infoPurchaseOrderMaster.PurchaseOrderMasterId != 0) { spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (decPurchaseInvoiceVoucherTypeId, strVoucherNo, infoPurchaseOrderMaster.VoucherNo, infoPurchaseOrderMaster.VoucherTypeId); } else if (infoMaterialReceiptMaster.MaterialReceiptMasterId != 0) { spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (decPurchaseInvoiceVoucherTypeId, strVoucherNo, infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId); } spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (0, "NA", strVoucherNo, decPurchaseInvoiceVoucherTypeId); spAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseInvoiceVoucherTypeId); Messages.DeletedMessage(); Clear(); this.Close(); } else { Messages.InformationMessage("Cannot delete purchase invoice because there is a payment voucher against this invoice"); } } else { Messages.InformationMessage("Cannot delete purchase invoice because reference exists"); } } catch (Exception ex) { MessageBox.Show("PI41:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// deleting the rows from tbl_PurchaseDetails removed by user from the grid while updating after reference check /// </summary> public void RemoveDelete() { PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP(); PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); decimal decPurchaseDetailsId = 0; decimal decAdditionalCostId = 0; int inRef = 0; try { foreach (var item in arrlstRemove) { decPurchaseDetailsId = Convert.ToDecimal(item); inRef = spPurchaseMaster.PurchaseMasterReferenceCheck(decPurchaseMasterId, decPurchaseDetailsId); if (inRef == 0) { spPurchaseDetails.PurchaseDetailsDelete(decPurchaseDetailsId); } } foreach (var item1 in arrlstRemoveAdditionalCost) { decAdditionalCostId = Convert.ToDecimal(item1); spAdditionalCost.AdditionalCostDelete(decAdditionalCostId); } } catch (Exception ex) { MessageBox.Show("PI40:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to edit purchase invoice /// </summary> public void Edit() { PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo(); PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP(); PurchaseDetailsInfo infoPurchaseDetails = new PurchaseDetailsInfo(); PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo(); PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP(); StockPostingInfo infoStockPosting = new StockPostingInfo(); StockPostingSP spStockPosting = new StockPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); PurchaseBillTaxInfo infoPurchaseBillTax = new PurchaseBillTaxInfo(); PurchaseBillTaxSP spPurchaseBillTax = new PurchaseBillTaxSP(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); UnitConvertionSP spUnitConvertion = new UnitConvertionSP(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); /*---------------------------------Deleting previous stock posting, Ledger posting, partybalanceposting---------------------------------------*/ infoPurchaseMaster = spPurchaseMaster.PurchaseMasterView(decPurchaseMasterId); if (infoPurchaseMaster.MaterialReceiptMasterId != 0) { infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId); spStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote (infoPurchaseMaster.VoucherTypeId, infoPurchaseMaster.VoucherNo, infoMaterialReceiptMaster.VoucherNo, infoMaterialReceiptMaster.VoucherTypeId); } spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType (0, "NA", infoPurchaseMaster.VoucherNo, infoPurchaseMaster.VoucherTypeId); try { RemoveDelete(); /*-----------------------------------------Purchase Master Edit----------------------------------------------------*/ infoPurchaseMaster.AdditionalCost = Convert.ToDecimal(lblAdditionalCostAmount.Text); infoPurchaseMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text); infoPurchaseMaster.CreditPeriod = txtCreditPeriod.Text; infoPurchaseMaster.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPurchaseMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoPurchaseMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text); infoPurchaseMaster.InvoiceNo = txtVoucherNo.Text; if (isAutomatic) { infoPurchaseMaster.SuffixPrefixId = decPurchaseInvoiceSuffixPrefixId; infoPurchaseMaster.VoucherNo = strVoucherNo; } else { infoPurchaseMaster.SuffixPrefixId = 0; infoPurchaseMaster.VoucherNo = strVoucherNo; } infoPurchaseMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPurchaseMaster.LrNo = txtLRNo.Text; if (cmbPurchaseMode.Text == "Against MaterialReceipt") { infoPurchaseMaster.MaterialReceiptMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); } else { infoPurchaseMaster.MaterialReceiptMasterId = 0; } infoPurchaseMaster.Narration = txtNarration.Text; infoPurchaseMaster.PurchaseAccount = Convert.ToDecimal(cmbPurchaseAccount.SelectedValue.ToString()); if (cmbPurchaseMode.Text == "Against PurchaseOrder") { infoPurchaseMaster.PurchaseOrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); } else { infoPurchaseMaster.PurchaseOrderMasterId = 0; } infoPurchaseMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoPurchaseMaster.TotalTax = Convert.ToDecimal(lblTaxAmount.Text); infoPurchaseMaster.TransportationCompany = txtTransportationCompany.Text; infoPurchaseMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseMaster.VendorInvoiceDate = Convert.ToDateTime(txtInvoiceDate.Text); infoPurchaseMaster.VendorInvoiceNo = txtVendorInvoiceNo.Text; infoPurchaseMaster.VoucherTypeId = decPurchaseInvoiceVoucherTypeId; infoPurchaseMaster.Extra1 = string.Empty; infoPurchaseMaster.Extra2 = string.Empty; infoPurchaseMaster.ExtraDate = Convert.ToDateTime(DateTime.Now); infoPurchaseMaster.PurchaseMasterId = decPurchaseMasterId; spPurchaseMaster.PurchaseMasterEdit(infoPurchaseMaster); infoPurchaseOrderMaster = spPurchaseOrderMaster.PurchaseOrderMasterView(infoPurchaseMaster.PurchaseOrderMasterId); infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId); spLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseInvoiceVoucherTypeId); spAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseInvoiceVoucherTypeId); foreach (DataGridViewRow dgvrow in dgvProductDetails.Rows) { if (dgvrow.Cells["dgvtxtProductId"].Value != null) { if (dgvrow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { /*-----------------------------------------Purchase Details Add----------------------------------------------------*/ infoPurchaseDetails.Amount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAmount"].Value.ToString()); infoPurchaseDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString()); infoPurchaseDetails.Discount = Convert.ToDecimal(dgvrow.Cells["dgvtxtDiscount"].Value.ToString()); infoPurchaseDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString()); infoPurchaseDetails.GrossAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtGrossValue"].Value.ToString()); infoPurchaseDetails.NetAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtNetValue"].Value.ToString()); infoPurchaseDetails.OrderDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString()); infoPurchaseDetails.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString()); infoPurchaseDetails.PurchaseMasterId = decPurchaseMasterId; infoPurchaseDetails.Qty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString()); infoPurchaseDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString()); infoPurchaseDetails.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString()); infoPurchaseDetails.ReceiptDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtMaterialReceiptDetailsId"].Value.ToString()); infoPurchaseDetails.SlNo = Convert.ToInt32(dgvrow.Cells["dgvtxtSlNo"].Value.ToString()); infoPurchaseDetails.TaxAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtTaxAmount"].Value.ToString()); infoPurchaseDetails.TaxId = Convert.ToDecimal(dgvrow.Cells["dgvcmbTax"].Value.ToString()); infoPurchaseDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value.ToString()); infoPurchaseDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); infoPurchaseDetails.Extra1 = string.Empty; infoPurchaseDetails.Extra2 = string.Empty; infoPurchaseDetails.ExtraDate = Convert.ToDateTime(DateTime.Today); if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() == "0" || dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString() == string.Empty) { spPurchaseDetails.PurchaseDetailsAdd(infoPurchaseDetails); } else { infoPurchaseDetails.PurchaseDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value.ToString()); spPurchaseDetails.PurchaseDetailsEdit(infoPurchaseDetails); } } else { spPurchaseDetails.PurchaseDetailsAdd(infoPurchaseDetails); } infoStockPosting.BatchId = infoPurchaseDetails.BatchId; infoStockPosting.Date = infoPurchaseMaster.Date; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.GodownId = infoPurchaseDetails.GodownId; infoStockPosting.InwardQty = infoPurchaseDetails.Qty; /// spUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.ProductId = infoPurchaseDetails.ProductId; infoStockPosting.RackId = infoPurchaseDetails.RackId; infoStockPosting.Rate = infoPurchaseDetails.Rate; infoStockPosting.UnitId = infoPurchaseDetails.UnitId; if (infoPurchaseDetails.OrderDetailsId != 0) { infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; } else if (infoPurchaseDetails.ReceiptDetailsId != 0) { infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; } else if (infoPurchaseDetails.OrderDetailsId == 0 && infoPurchaseDetails.ReceiptDetailsId == 0) { infoStockPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; } infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; infoStockPosting.ExtraDate = Convert.ToDateTime(DateTime.Today); spStockPosting.StockPostingAdd(infoStockPosting); if (infoPurchaseDetails.ReceiptDetailsId != 0) { infoStockPosting.InvoiceNo = infoMaterialReceiptMaster.InvoiceNo; infoStockPosting.VoucherNo = infoMaterialReceiptMaster.VoucherNo; infoStockPosting.VoucherTypeId = infoMaterialReceiptMaster.VoucherTypeId; infoStockPosting.AgainstInvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.AgainstVoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.AgainstVoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = infoPurchaseDetails.Qty; /// spUnitConvertion.UnitConversionRateByUnitConversionId(infoPurchaseDetails.UnitConversionId); spStockPosting.StockPostingAdd(infoStockPosting); } } } } /*-----------------------------------------Ledger Posting----------------------------------------------------*/ infoLedgerPosting.Credit = Convert.ToDecimal(txtGrandTotal.Text) * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Debit = 0; infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = infoPurchaseMaster.LedgerId; infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); decimal DecBillDiscount = Convert.ToDecimal(txtBillDiscount.Text.Trim().ToString()); if (DecBillDiscount > 0) { infoLedgerPosting.Credit = DecBillDiscount * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Debit = 0; infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = 9;//ledger id of discount received ledger infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } infoLedgerPosting.Credit = 0; infoLedgerPosting.Debit = TotalNetAmount();// * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = infoPurchaseMaster.PurchaseAccount; infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); foreach (DataGridViewRow dgvrow in dgvAdditionalCost.Rows) { if (dgvrow.Cells["dgvcmbLedger"].Value != null) { if (dgvrow.Cells["dgvcmbLedger"].Value.ToString() != string.Empty) { if (dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value != null) { if (dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value.ToString() != string.Empty) { /*-----------------------------------------Additional Cost Add----------------------------------------------------*/ infoAdditionalCost.Credit = 0; infoAdditionalCost.Debit = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostAmount"].Value.ToString()); infoAdditionalCost.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvcmbLedger"].Value.ToString()); infoAdditionalCost.VoucherNo = infoPurchaseMaster.VoucherNo; infoAdditionalCost.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; infoAdditionalCost.ExtraDate = DateTime.Now; if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value != null) { if (dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty) { infoAdditionalCost.AdditionalCostId = Convert.ToDecimal(dgvrow.Cells["dgvtxtAdditionalCostId"].Value.ToString()); spAdditionalCost.AdditionalCostEdit(infoAdditionalCost); } else { spAdditionalCost.AdditionalCostAdd(infoAdditionalCost); } } else { spAdditionalCost.AdditionalCostAdd(infoAdditionalCost); } /*-----------------------------------------Additional Cost Ledger Posting----------------------------------------------------*/ infoLedgerPosting.Credit = 0; infoLedgerPosting.Debit = infoAdditionalCost.Debit * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = infoAdditionalCost.LedgerId; infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } } } } if (dgvTax.Visible) { foreach (DataGridViewRow dgvrow in dgvTax.Rows) { if (dgvrow.Cells["dgvtxtTaxId"].Value != null) { if (dgvrow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty) { /*-----------------------------------------PurchaseBillTax Add----------------------------------------------------*/ infoPurchaseBillTax.PurchaseMasterId = decPurchaseMasterId; infoPurchaseBillTax.TaxAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtTotalTax"].Value.ToString()); infoPurchaseBillTax.TaxId = Convert.ToDecimal(dgvrow.Cells["dgvtxtTaxId"].Value.ToString()); infoPurchaseBillTax.Extra1 = string.Empty; infoPurchaseBillTax.Extra2 = string.Empty; infoPurchaseBillTax.ExtraDate = DateTime.Now; if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != string.Empty && dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString() != "0") { infoPurchaseBillTax.PurchaseBillTaxId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseBillTaxId"].Value.ToString()); spPurchaseBillTax.PurchaseBillTaxEdit(infoPurchaseBillTax); } else { spPurchaseBillTax.PurchaseBillTaxAdd(infoPurchaseBillTax); } } else { spPurchaseBillTax.PurchaseBillTaxAdd(infoPurchaseBillTax); } /*-----------------------------------------Tax Ledger Posting----------------------------------------------------*/ infoLedgerPosting.Credit = 0; infoLedgerPosting.Debit = infoPurchaseBillTax.TaxAmount * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.Date = Convert.ToDateTime(PublicVariables._dtCurrentDate); infoLedgerPosting.DetailsId = 0; infoLedgerPosting.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtLedgerId"].Value.ToString()); infoLedgerPosting.VoucherNo = infoPurchaseMaster.VoucherNo; infoLedgerPosting.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } } } /*-----------------------------------------PartyBalance Posting----------------------------------------------------*/ infoAccountLedger = spAccountLedger.AccountLedgerView(infoPurchaseMaster.LedgerId); if (infoAccountLedger.BillByBill == true) { infoPartyBalance.Credit = Convert.ToDecimal(txtGrandTotal.Text); infoPartyBalance.Debit = 0; if (txtCreditPeriod.Text != string.Empty) { infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text); } infoPartyBalance.Date = Convert.ToDateTime(txtVoucherDate.Text); infoPartyBalance.ExchangeRateId = infoPurchaseMaster.ExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.LedgerId = infoPurchaseMaster.LedgerId; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoPartyBalance.VoucherNo = infoPurchaseMaster.VoucherNo; infoPartyBalance.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoPartyBalance.AgainstInvoiceNo = "NA"; infoPartyBalance.AgainstVoucherNo = "NA"; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; infoPartyBalance.ExtraDate = DateTime.Now; spPartyBalance.PartyBalanceAdd(infoPartyBalance); } Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseMasterId); } else { Print(decPurchaseMasterId); } } Clear(); this.Close(); } catch (Exception ex) { MessageBox.Show("PI39:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Funtion to check remaining quantity with refernce to purchaseinvoice and rejectionout /// </summary> /// <returns></returns> public int QuantityCheckWithReference() { decimal decQtyRejectionOutAndPurchaseInvoice = 0; decimal decQtyMaterialReceipt = 0; decimal inRef = 0; int inF1 = 1; decimal decMaterialReceiptDetailsId = 0; MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); PurchaseDetailsSP spPurchaseDetails = new PurchaseDetailsSP(); RejectionOutDetailsSP spRejectionOut = new RejectionOutDetailsSP(); try { foreach (DataGridViewRow dgvrow in dgvProduct.Rows) { if (dgvrow.Cells["dgvtxtmaterialReceiptDetailsId"].Value != null) { if (dgvrow.Cells["dgvtxtmaterialReceiptDetailsId"].Value.ToString() != "0" || dgvrow.Cells["dgvtxtmaterialReceiptDetailsId"].Value.ToString() != string.Empty) { decMaterialReceiptDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtmaterialReceiptDetailsId"].Value.ToString()); inRef = spMaterialReceiptMaster.MaterialReceiptDetailsReferenceCheck(decMaterialReceiptDetailsId); if (inRef == 1) { if (inF1 == 1) { if (dgvrow.Cells["dgvtxtQty"].Value != null) { if (dgvrow.Cells["dgvtxtQty"].Value.ToString() != "0" || dgvrow.Cells["dgvtxtQty"].Value.ToString() != string.Empty) { decQtyMaterialReceipt = Convert.ToDecimal(dgvrow.Cells["dgvtxtQty"].Value.ToString()); decQtyRejectionOutAndPurchaseInvoice = Math.Round(spMaterialReceiptMaster.MaterialReceiptQuantityDetailsAgainstPurcahseInvoiceAndRejectionOut(decMaterialReceiptDetailsId), PublicVariables._inNoOfDecimalPlaces); if (decQtyMaterialReceipt >= decQtyRejectionOutAndPurchaseInvoice) { inF1 = 1; } else { inF1 = 0; Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtyRejectionOutAndPurchaseInvoice); } } else { inF1 = 0; Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtyRejectionOutAndPurchaseInvoice); } } else { inF1 = 0; Messages.InformationMessage("Quantity in row " + (dgvrow.Index + 1) + " should be greater than " + decQtyRejectionOutAndPurchaseInvoice); } } } else { inF1 = 1; } } } } } catch (Exception ex) { MessageBox.Show("MR11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return inF1; }