/// <summary> /// Function to fill the fields for edit or delete /// </summary> public void FillRegisterOrReport() { MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); MaterialReceiptDetailsInfo infoMaterialReceiptDetails = new MaterialReceiptDetailsInfo(); VoucherTypeBll BllVoucherType = new VoucherTypeBll(); MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll(); MaterialReceiptBll bllMaterialReceiptDetails = new MaterialReceiptBll(); PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); try { PurchaseOrderMasterInfo infoPurchaseOrder = new PurchaseOrderMasterInfo(); decimal decTotal = 0; decimal decStatus = bllMaterialReceiptMaster.MaterialReceiptMasterReferenceCheck(decMaterialReceiptMasterId); if (decStatus == 0) { cmbCashOrParty.Enabled = false; cmbOrderNo.Enabled = false; cmbcurrency.Enabled = false; txtDate.Enabled = false; cmbVoucherType.Enabled = false; } btnSave.Text = "Update"; btnDelete.Enabled = true; txtReceiptNo.ReadOnly = true; infoMaterialReceiptMaster = bllMaterialReceiptMaster.MaterialReceiptMasterView(decMaterialReceiptMasterId); txtReceiptNo.Text = infoMaterialReceiptMaster.InvoiceNo; strVoucherNo = infoMaterialReceiptMaster.VoucherNo.ToString(); decMaterialReceiptSuffixPrefixId = Convert.ToDecimal(infoMaterialReceiptMaster.SuffixPrefixId); decMaterialReceiptVoucherTypeId = Convert.ToDecimal(infoMaterialReceiptMaster.VoucherTypeId); isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decMaterialReceiptVoucherTypeId); decMaterialReceiptTypeId = decMaterialReceiptVoucherTypeId; txtDate.Text = infoMaterialReceiptMaster.Date.ToString("dd-MMM-yyyy"); cmbCashOrParty.SelectedValue = infoMaterialReceiptMaster.LedgerId; if (infoMaterialReceiptMaster.OrderMasterId != 0) { infoPurchaseOrder = BllPurchaseOrder.PurchaseOrderMasterView(Convert.ToDecimal(infoMaterialReceiptMaster.OrderMasterId.ToString())); decPurchaseOrderVoucherTypeId = infoPurchaseOrder.VoucherTypeId; cmbVoucherType.SelectedValue = decPurchaseOrderVoucherTypeId; cmbOrderNo.SelectedValue = infoMaterialReceiptMaster.OrderMasterId.ToString(); decOrderNoWhileEditMode = infoMaterialReceiptMaster.OrderMasterId; } else { cmbVoucherType.SelectedValue = 0; } txtTransportation.Text = infoMaterialReceiptMaster.TransportationCompany; txtNarration.Text = infoMaterialReceiptMaster.Narration; txtLRNo.Text = infoMaterialReceiptMaster.LrNo; CurrencyComboFill(); cmbcurrency.SelectedValue = infoMaterialReceiptMaster.exchangeRateId; decTotal = Convert.ToDecimal(infoMaterialReceiptMaster.TotalAmount.ToString()); decTotal = Math.Round(decTotal, PublicVariables._inNoOfDecimalPlaces); txtTotal.Text = Convert.ToString(decTotal); List<DataTable> ListObj = new List<DataTable>(); ListObj = bllMaterialReceiptDetails.MaterialReceiptDetailsViewByMasterId(decMaterialReceiptMasterId); dgvProduct.Rows.Clear(); for (int i = 0; i < ListObj[0].Rows.Count; i++) { isAmountcalc = false; isValueChange = false; dgvProduct.Rows.Add(); dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["materialReceiptDetailsId"].ToString()); decMaterialReceiptDetailId = Convert.ToDecimal(ListObj[0].Rows[i]["materialReceiptDetailsId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtSlNo"].Value = ListObj[0].Rows[i]["slno"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[i]["productName"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = ListObj[0].Rows[i]["qty"].ToString(); dgvProduct.Rows[i].Cells["productId"].Value = ListObj[0].Rows[i]["productId"].ToString(); decimal decProductId = Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString()); UnitComboFill(decProductId, i, dgvProduct.Rows[i].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitId"].ToString()); DGVGodownComboFill(); dgvProduct.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["godownId"].ToString()); decGodownId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvcmbGodown"].Value); RackComboFill(decGodownId, i, dgvProduct.Rows[i].Cells["dgvCmbRack"].ColumnIndex); if (Convert.ToDecimal(ListObj[0].Rows[i]["orderDetailsId"].ToString()) == 0) { dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = 0; } else { dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["orderDetailsId"].ToString()); } dgvProduct.Rows[i].Cells["dgvCmbRack"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["rackId"].ToString()); BatchComboFill(decProductId, i, Convert.ToInt32(dgvProduct.Rows[i].Cells["dgvcmbBatch"].ColumnIndex)); dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitConversionId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = ListObj[0].Rows[i]["barcode"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = ListObj[0].Rows[i]["rate"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[i]["amount"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtvouchertypeId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["voucherTypeId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtvoucherNo"].Value = ListObj[0].Rows[i]["voucherNo"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtinvoiceNo"].Value = ListObj[0].Rows[i]["invoiceNo"].ToString(); decAgainstVoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtvouchertypeId"].Value.ToString()); strAgainstVoucherNo = dgvProduct.Rows[i].Cells["dgvtxtvoucherNo"].Value.ToString(); UnitConvertionBll bllUnitConvertion = new UnitConvertionBll(); List<DataTable> listObjUnitByProduct = new List<DataTable>(); listObjUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(decProductId.ToString()); foreach (DataRow drUnitByProduct in listObjUnitByProduct[0].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()); } } decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtRate"].Value.ToString()); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value.ToString()); decimal decReference = bllMaterialReceiptMaster.MaterialReceiptDetailsReferenceCheck(decMaterialReceiptDetailId); if (decReference == 1 || Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString())!=0) { dgvProduct.Rows[i].Cells["dgvtxtProductCode"].ReadOnly = true; dgvProduct.Rows[i].Cells["dgvtxtProductName"].ReadOnly = true; dgvProduct.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true; dgvProduct.Rows[i].Cells["dgvtxtBarcode"].ReadOnly = true; dgvProduct.Rows[i].Cells["dgvCmbRack"].ReadOnly = true; dgvProduct.Rows[i].Cells["dgvcmbGodown"].ReadOnly = true; dgvProduct.Rows[i].Cells["dgvtxtRate"].ReadOnly = true; dgvProduct.Rows[i].Cells["dgvcmbBatch"].ReadOnly = true; } if (cmbVoucherType.Text != "NA") { dgvProduct.Rows[i].Cells["dgvcmbUnit"].ReadOnly = true; } } isAmountcalc = true; isValueChange = true; isDoAfterGridFill = true; } catch (Exception ex) { MessageBox.Show("MR16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to delete material receipt /// </summary> public void Delete() { MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll(); //StockPostingSP spstockposting = new StockPostingSP(); StockPostingBll BllStockPosting = new StockPostingBll(); try { decimal decResult1 = 0; decimal decReference = bllMaterialReceiptMaster.MaterialReceiptMasterReferenceCheck(decMaterialReceiptMasterId); if (decReference == 1) { decResult1 = bllMaterialReceiptMaster.MaterialReceiptDelete(decMaterialReceiptMasterId); if (decResult1 > 0) { if (Convert.ToDecimal(dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtvouchertypeId"].Value) == 0) { decimal decResult3 = BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(0, "NA", strVoucherNo, decMaterialReceiptVoucherTypeId); } else { decimal decResult3 = BllStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(decMaterialReceiptVoucherTypeId, strVoucherNo, strAgainstVoucherNo, decAgainstVoucherTypeId); } Messages.DeletedMessage(); if (frmMaterialReceiptRegisterObj != null) { this.Close(); frmMaterialReceiptRegisterObj.GridFill(); } if (frmMaterialReceiptReportObj != null) { this.Close(); frmMaterialReceiptReportObj.GridFill(); } if (objVoucherSearch != null) { this.Close(); objVoucherSearch.GridFill(); } if (frmDayBookObj != null) { this.Close(); frmDayBookObj.dayBookGridFill(); } } } else { Messages.ReferenceExistsMessage(); } } catch (Exception ex) { MessageBox.Show("MR50:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }