/// <summary> /// Function to insert values to MaterialReceiptMaster Table /// </summary> /// <param name="materialreceiptmasterinfo"></param> /// <returns></returns> public decimal MaterialReceiptMasterAdd(MaterialReceiptMasterInfo materialreceiptmasterinfo) { decimal decIdentity = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("MaterialReceiptMasterAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.SuffixPrefixId; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = materialreceiptmasterinfo.Date; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.LedgerId; sprmparam = sccmd.Parameters.Add("@orderMasterId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.OrderMasterId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.Narration; sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.exchangeRateId; sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.TotalAmount; sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.UserId; sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.LrNo; sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.TransportationCompany; sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.FinancialYearId; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = materialreceiptmasterinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.Extra2; decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return(decIdentity); }
/// <summary> /// Function to insert values to MaterialReceiptMaster Table /// </summary> /// <param name="materialreceiptmasterinfo"></param> /// <returns></returns> public decimal MaterialReceiptMasterAdd(MaterialReceiptMasterInfo materialreceiptmasterinfo) { decimal decIdentity = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("MaterialReceiptMasterAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@suffixPrefixId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.SuffixPrefixId; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = materialreceiptmasterinfo.Date; sprmparam = sccmd.Parameters.Add("@ledgerId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.LedgerId; sprmparam = sccmd.Parameters.Add("@orderMasterId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.OrderMasterId; sprmparam = sccmd.Parameters.Add("@narration", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.Narration; sprmparam = sccmd.Parameters.Add("@exchangeRateId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.exchangeRateId; sprmparam = sccmd.Parameters.Add("@totalAmount", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.TotalAmount; sprmparam = sccmd.Parameters.Add("@userId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.UserId; sprmparam = sccmd.Parameters.Add("@lrNo", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.LrNo; sprmparam = sccmd.Parameters.Add("@transportationCompany", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.TransportationCompany; sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = materialreceiptmasterinfo.FinancialYearId; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = materialreceiptmasterinfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = materialreceiptmasterinfo.Extra2; decIdentity = Convert.ToDecimal(sccmd.ExecuteScalar()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return decIdentity; }
/// <summary> /// Function to get particular values from MaterialReceiptMaster Table based on the parameter /// </summary> /// <param name="materialReceiptMasterId"></param> /// <returns></returns> public MaterialReceiptMasterInfo MaterialReceiptMasterView(decimal materialReceiptMasterId) { MaterialReceiptMasterInfo materialreceiptmasterinfo = new MaterialReceiptMasterInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("MaterialReceiptMasterView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@materialReceiptMasterId", SqlDbType.Decimal); sprmparam.Value = materialReceiptMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { materialreceiptmasterinfo.MaterialReceiptMasterId = decimal.Parse(sdrreader[0].ToString()); materialreceiptmasterinfo.VoucherNo = sdrreader[1].ToString(); materialreceiptmasterinfo.InvoiceNo = sdrreader[2].ToString(); materialreceiptmasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[3].ToString()); materialreceiptmasterinfo.VoucherTypeId = decimal.Parse(sdrreader[4].ToString()); materialreceiptmasterinfo.Date = DateTime.Parse(sdrreader[5].ToString()); materialreceiptmasterinfo.LedgerId = decimal.Parse(sdrreader[6].ToString()); materialreceiptmasterinfo.OrderMasterId = decimal.Parse(sdrreader[7].ToString()); materialreceiptmasterinfo.Narration = sdrreader[8].ToString(); materialreceiptmasterinfo.exchangeRateId = Convert.ToDecimal(sdrreader[9].ToString()); materialreceiptmasterinfo.TotalAmount = decimal.Parse(sdrreader[10].ToString()); materialreceiptmasterinfo.UserId = decimal.Parse(sdrreader[11].ToString()); materialreceiptmasterinfo.LrNo = sdrreader[12].ToString(); materialreceiptmasterinfo.TransportationCompany = sdrreader[13].ToString(); materialreceiptmasterinfo.FinancialYearId = decimal.Parse(sdrreader[14].ToString()); materialreceiptmasterinfo.Extra1 = sdrreader[15].ToString(); materialreceiptmasterinfo.Extra2 = sdrreader[16].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(materialreceiptmasterinfo); }
/// <summary> /// It is a function for Add Stock Posting /// </summary> public void AddStockPosting() { try { StockPostingInfo infoStockPosting = new StockPostingInfo(); StockPostingSP spStockPosting = new StockPostingSP(); MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(Convert.ToDecimal(cmbMaterialReceiptNo.SelectedValue)); infoStockPosting.Date = DateTime.Parse(txtDate.Text); infoStockPosting.VoucherTypeId = infoMaterialReceiptMaster.VoucherTypeId; infoStockPosting.VoucherNo = infoMaterialReceiptMaster.VoucherNo; infoStockPosting.InvoiceNo = infoMaterialReceiptMaster.InvoiceNo; if (isAutomatic) { infoStockPosting.AgainstVoucherNo = strVoucherNo; infoStockPosting.AgainstInvoiceNo = txtRejectionOutNo.Text; } else { infoStockPosting.AgainstVoucherNo = txtRejectionOutNo.Text; infoStockPosting.AgainstInvoiceNo = txtRejectionOutNo.Text; } if (decRejectionOutVoucherTypeId != 0) { infoStockPosting.AgainstVoucherTypeId = decRejectionOutVoucherTypeId; } if (strVoucherNo != string.Empty) { infoStockPosting.AgainstVoucherNo = strVoucherNo; } if (txtRejectionOutNo.Text != string.Empty) { infoStockPosting.AgainstInvoiceNo = txtRejectionOutNo.Text; } infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = infoRejectionOutDetails.Qty; infoStockPosting.ProductId = infoRejectionOutDetails.ProductId; infoStockPosting.BatchId = infoRejectionOutDetails.BatchId; infoStockPosting.UnitId = infoRejectionOutDetails.UnitId; infoStockPosting.GodownId = infoRejectionOutDetails.GodownId; infoStockPosting.RackId = infoRejectionOutDetails.RackId; infoStockPosting.Rate = infoRejectionOutDetails.Rate; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; spStockPosting.StockPostingAdd(infoStockPosting); } catch (Exception ex) { MessageBox.Show("RO28:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Fill function for edit /// </summary> public void FillRejectionOutReportForEdit() { try { dgvProduct.Rows.Clear(); isDoCellValueChange = false; isFromRegister = true; btnSave.Text = "Update"; btnDelete.Enabled = true; txtRejectionOutNo.ReadOnly = true; infoRejectionOutMaster = spRejectionOutMaster.RejectionOutMasterView(decRejectionOutId); MaterialReceiptMasterSP SpMaterialReceiptMaster = new MaterialReceiptMasterSP(); MaterialReceiptMasterInfo InfoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); InfoMaterialReceiptMaster = SpMaterialReceiptMaster.MaterialReceiptMasterView(infoRejectionOutMaster.MaterialReceiptMasterId); strRejectionOutVoucherNo = spRejectionOutMaster.GetRejectionOutVoucherNo(infoRejectionOutMaster.RejectionOutMasterId); txtRejectionOutNo.Text = infoRejectionOutMaster.InvoiceNo; strVoucherNo = infoRejectionOutMaster.VoucherNo.ToString(); decRejectionOutSuffixPrefixId = Convert.ToDecimal(infoRejectionOutMaster.SuffixPrefixId); decRejectionOutVoucherTypeId = Convert.ToDecimal(infoRejectionOutMaster.VoucherTypeId); isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decRejectionOutVoucherTypeId); infoVoucherType = spVoucherType.VoucherTypeView(decRejectionOutVoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; if (!isAutomatic) { txtRejectionOutNo.ReadOnly = false; txtRejectionOutNo.Focus(); } else { txtRejectionOutNo.ReadOnly = true; txtDate.Focus(); } decRejectionOutTypeId = decRejectionOutVoucherTypeId; txtDate.Text = infoRejectionOutMaster.Date.ToString("dd-MMM-yyyy"); cmbCashOrParty.SelectedValue = infoRejectionOutMaster.LedgerId; cmbVoucherType.SelectedValue = InfoMaterialReceiptMaster.VoucherTypeId; cmbMaterialReceiptNo.SelectedValue = Convert.ToDecimal(infoRejectionOutMaster.MaterialReceiptMasterId.ToString()); txtTransportationCompany.Text = infoRejectionOutMaster.TransportationCompany; txtNarration.Text = infoRejectionOutMaster.Narration; cmbCurrency.SelectedValue = infoRejectionOutMaster.ExchangeRateId; txtTotalAmount.Text = infoRejectionOutMaster.TotalAmount.ToString(); txtLrNo.Text = infoRejectionOutMaster.LrNo.ToString(); DataTable dtblRejectionOut = spRejectionOutDetails.RejectionOutDetailsViewByRejectionOutMasterId(infoRejectionOutMaster.RejectionOutMasterId); for (int i = 0; i < dtblRejectionOut.Rows.Count; i++) { dgvProduct.Rows.Add(); GodownComboFill(); isAmountcalc = false; decRejectionOutDetailId = Convert.ToDecimal(dtblRejectionOut.Rows[i]["rejectionOutDetailsId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtSlNo"].Value = dtblRejectionOut.Rows[i]["slno"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtProductId"].Value = dtblRejectionOut.Rows[i]["productId"].ToString(); ProductDefaultValues(i, Convert.ToDecimal(dtblRejectionOut.Rows[i]["productId"].ToString())); BatchComboFill(Convert.ToDecimal(dtblRejectionOut.Rows[i]["productId"].ToString()), i, dgvProduct.Rows[i].Cells["dgvcmbBatch"].ColumnIndex); dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(dtblRejectionOut.Rows[i]["batchId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = dtblRejectionOut.Rows[i]["qty"].ToString(); UnitComboFill(Convert.ToDecimal(dtblRejectionOut.Rows[i]["productId"].ToString()), i, dgvProduct.Rows[i].Cells["dgvcmbUnit"].ColumnIndex); isDoCellValueChange = true; isDoAfterGridFill = true; isValueChange = true; isAmountcalc = true; dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtblRejectionOut.Rows[i]["unitId"].ToString()); isDoCellValueChange = false; isDoAfterGridFill = false; isValueChange = false; dgvProduct.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(dtblRejectionOut.Rows[i]["godownId"].ToString()); RackComboFill(Convert.ToDecimal(dtblRejectionOut.Rows[i]["godownId"].ToString()), dgvProduct, i); dgvProduct.Rows[i].Cells["dgvcmbRack"].Value = Convert.ToDecimal(dtblRejectionOut.Rows[i]["rackId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = dtblRejectionOut.Rows[i]["barcode"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtRejectionOutDetailsId"].Value = decRejectionOutDetailId; dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = dtblRejectionOut.Rows[i]["rate"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = dtblRejectionOut.Rows[i]["amount"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtunitConversionId"].Value = dtblRejectionOut.Rows[i]["UnitConversionId"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtconversionRate"].Value = dtblRejectionOut.Rows[i]["conversionRate"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtmaterialReceiptDetailsId"].Value = dtblRejectionOut.Rows[i]["materialReceiptDetailsId"].ToString(); } TotalAmount(); isAmountcalc = true; isDoAfterGridFill = true; isFromRegister = false; isDoCellValueChange = true; isValueChange = true; } catch (Exception ex) { MessageBox.Show("RO36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from MaterialReceiptMaster Table based on the parameter /// </summary> /// <param name="materialReceiptMasterId"></param> /// <returns></returns> public MaterialReceiptMasterInfo MaterialReceiptMasterView(decimal materialReceiptMasterId) { MaterialReceiptMasterInfo materialreceiptmasterinfo = new MaterialReceiptMasterInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("MaterialReceiptMasterView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@materialReceiptMasterId", SqlDbType.Decimal); sprmparam.Value = materialReceiptMasterId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { materialreceiptmasterinfo.MaterialReceiptMasterId = decimal.Parse(sdrreader[0].ToString()); materialreceiptmasterinfo.VoucherNo = sdrreader[1].ToString(); materialreceiptmasterinfo.InvoiceNo = sdrreader[2].ToString(); materialreceiptmasterinfo.SuffixPrefixId = decimal.Parse(sdrreader[3].ToString()); materialreceiptmasterinfo.VoucherTypeId = decimal.Parse(sdrreader[4].ToString()); materialreceiptmasterinfo.Date = DateTime.Parse(sdrreader[5].ToString()); materialreceiptmasterinfo.LedgerId = decimal.Parse(sdrreader[6].ToString()); materialreceiptmasterinfo.OrderMasterId = decimal.Parse(sdrreader[7].ToString()); materialreceiptmasterinfo.Narration = sdrreader[8].ToString(); materialreceiptmasterinfo.exchangeRateId = Convert.ToDecimal (sdrreader[9].ToString()); materialreceiptmasterinfo.TotalAmount = decimal.Parse(sdrreader[10].ToString()); materialreceiptmasterinfo.UserId = decimal.Parse(sdrreader[11].ToString()); materialreceiptmasterinfo.LrNo = sdrreader[12].ToString(); materialreceiptmasterinfo.TransportationCompany = sdrreader[13].ToString(); materialreceiptmasterinfo.FinancialYearId = decimal.Parse(sdrreader[14].ToString()); materialreceiptmasterinfo.Extra1 = sdrreader[15].ToString(); materialreceiptmasterinfo.Extra2 = sdrreader[16].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return materialreceiptmasterinfo; }
/// <summary> /// Function to fill the details while calling from register or report /// </summary> public void FillRegisterOrReport() { PurchaseMasterInfo infoPurchaseMaster = new PurchaseMasterInfo(); PurchaseMasterSP spPurchaseMaster = new PurchaseMasterSP(); PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo(); PurchaseOrderMasterSP spPurchaseOrderMaster = new PurchaseOrderMasterSP(); MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); VoucherTypeSP spVoucherType = new VoucherTypeSP(); VoucherTypeInfo infoVoucherType = new VoucherTypeInfo(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); bool isPartyBalanceRef = false; try { isEditFill = true; btnSave.Text = "Update"; btnDelete.Enabled = true; txtVoucherNo.ReadOnly = true; infoPurchaseMaster = spPurchaseMaster.PurchaseMasterView(decPurchaseMasterId); strVoucherNo = infoPurchaseMaster.VoucherNo; decPurchaseInvoiceVoucherTypeId = infoPurchaseMaster.VoucherTypeId; decPurchaseInvoiceSuffixPrefixId = infoPurchaseMaster.SuffixPrefixId; isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decPurchaseInvoiceVoucherTypeId); infoVoucherType = spVoucherType.VoucherTypeView(decPurchaseInvoiceVoucherTypeId); this.Text = infoVoucherType.VoucherTypeName; if (isAutomatic) { txtVoucherDate.Focus(); } else { txtVoucherNo.Focus(); } txtVoucherNo.Text = infoPurchaseMaster.InvoiceNo; txtVendorInvoiceNo.Text = infoPurchaseMaster.VendorInvoiceNo; dtpVoucherDate.Value = infoPurchaseMaster.Date; dtpInvoiceDate.Value = infoPurchaseMaster.VendorInvoiceDate; cmbCashOrParty.SelectedValue = infoPurchaseMaster.LedgerId; if (infoPurchaseMaster.PurchaseOrderMasterId == 0 && infoPurchaseMaster.MaterialReceiptMasterId == 0) { cmbPurchaseMode.SelectedItem = "NA"; } else if (infoPurchaseMaster.PurchaseOrderMasterId != 0 && infoPurchaseMaster.MaterialReceiptMasterId == 0) { cmbPurchaseMode.SelectedItem = "Against PurchaseOrder"; infoPurchaseOrderMaster = spPurchaseOrderMaster.PurchaseOrderMasterView(infoPurchaseMaster.PurchaseOrderMasterId); cmbVoucherType.SelectedValue = infoPurchaseOrderMaster.VoucherTypeId; OrderComboFill(); cmbOrderNo.SelectedValue = infoPurchaseMaster.PurchaseOrderMasterId; } else if (infoPurchaseMaster.PurchaseOrderMasterId == 0 && infoPurchaseMaster.MaterialReceiptMasterId != 0) { cmbPurchaseMode.SelectedItem = "Against MaterialReceipt"; infoMaterialReceiptMaster = spMaterialReceiptMaster.MaterialReceiptMasterView(infoPurchaseMaster.MaterialReceiptMasterId); cmbVoucherType.SelectedValue = infoMaterialReceiptMaster.VoucherTypeId; OrderComboFill(); cmbOrderNo.SelectedValue = infoPurchaseMaster.MaterialReceiptMasterId; } cmbPurchaseAccount.SelectedValue = infoPurchaseMaster.PurchaseAccount; txtCreditPeriod.Text = infoPurchaseMaster.CreditPeriod; cmbCurrency.SelectedValue = infoPurchaseMaster.ExchangeRateId; txtNarration.Text = infoPurchaseMaster.Narration; lblAdditionalCostAmount.Text = Math.Round(infoPurchaseMaster.AdditionalCost, PublicVariables._inNoOfDecimalPlaces).ToString(); lblTaxAmount.Text = Math.Round(infoPurchaseMaster.TotalTax, PublicVariables._inNoOfDecimalPlaces).ToString(); txtTotalAmount.Text = Math.Round(infoPurchaseMaster.TotalAmount, PublicVariables._inNoOfDecimalPlaces).ToString(); txtBillDiscount.Text = Math.Round(infoPurchaseMaster.BillDiscount, PublicVariables._inNoOfDecimalPlaces).ToString(); txtLRNo.Text = infoPurchaseMaster.LrNo; txtTransportationCompany.Text = infoPurchaseMaster.TransportationCompany; txtGrandTotal.Text = Math.Round(infoPurchaseMaster.GrandTotal, PublicVariables._inNoOfDecimalPlaces).ToString(); PurchaseDetailsFill(); TaxGridFill(); AdditionalCostGridFill(); isPartyBalanceRef = spAccountLedger.PartyBalanceAgainstReferenceCheck(strVoucherNo, decPurchaseInvoiceVoucherTypeId); if (isPartyBalanceRef) { cmbCashOrParty.Enabled = false; } else { cmbCashOrParty.Enabled = true; } isEditFill = false; } catch (Exception ex) { MessageBox.Show("PI55:" + 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> /// 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> /// Function to fill the fields for edit or delete /// </summary> public void FillRegisterOrReport() { MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); MaterialReceiptDetailsInfo infoMaterialReceiptDetails = new MaterialReceiptDetailsInfo(); VoucherTypeSP spVoucherType = new VoucherTypeSP(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); MaterialReceiptDetailsSP spMaterialReceiptDetails = new MaterialReceiptDetailsSP(); PurchaseOrderMasterSP SPPurchaseOrderMaster = new PurchaseOrderMasterSP(); try { PurchaseOrderMasterSP spPurchaseOrder = new PurchaseOrderMasterSP(); PurchaseOrderMasterInfo infoPurchaseOrder = new PurchaseOrderMasterInfo(); decimal decTotal = 0; decimal decStatus = spMaterialReceiptMaster.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 = spMaterialReceiptMaster.MaterialReceiptMasterView(decMaterialReceiptMasterId); txtReceiptNo.Text = infoMaterialReceiptMaster.InvoiceNo; strVoucherNo = infoMaterialReceiptMaster.VoucherNo.ToString(); decMaterialReceiptSuffixPrefixId = Convert.ToDecimal(infoMaterialReceiptMaster.SuffixPrefixId); decMaterialReceiptVoucherTypeId = Convert.ToDecimal(infoMaterialReceiptMaster.VoucherTypeId); isAutomatic = spVoucherType.CheckMethodOfVoucherNumbering(decMaterialReceiptVoucherTypeId); decMaterialReceiptTypeId = decMaterialReceiptVoucherTypeId; txtDate.Text = infoMaterialReceiptMaster.Date.ToString("dd-MMM-yyyy"); cmbCashOrParty.SelectedValue = infoMaterialReceiptMaster.LedgerId; if (infoMaterialReceiptMaster.OrderMasterId != 0) { infoPurchaseOrder = SPPurchaseOrderMaster.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); DataTable dtbl = new DataTable(); dtbl = spMaterialReceiptDetails.MaterialReceiptDetailsViewByMasterId(decMaterialReceiptMasterId); dgvProduct.Rows.Clear(); for (int i = 0; i < dtbl.Rows.Count; i++) { isAmountcalc = false; isValueChange = false; dgvProduct.Rows.Add(); dgvProduct.Rows[i].Cells["dgvtxtMaterialReceiptdetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["materialReceiptDetailsId"].ToString()); decMaterialReceiptDetailId = Convert.ToDecimal(dtbl.Rows[i]["materialReceiptDetailsId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtSlNo"].Value = dtbl.Rows[i]["slno"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtProductCode"].Value = dtbl.Rows[i]["productCode"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = dtbl.Rows[i]["productName"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = dtbl.Rows[i]["qty"].ToString(); dgvProduct.Rows[i].Cells["productId"].Value = dtbl.Rows[i]["productId"].ToString(); decimal decProductId = Convert.ToDecimal(dtbl.Rows[i]["productId"].ToString()); UnitComboFill(decProductId, i, dgvProduct.Rows[i].Cells["dgvcmbUnit"].ColumnIndex); dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitId"].ToString()); DGVGodownComboFill(); dgvProduct.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(dtbl.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(dtbl.Rows[i]["orderDetailsId"].ToString()) == 0) { dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = 0; } else { dgvProduct.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToDecimal(dtbl.Rows[i]["orderDetailsId"].ToString()); } dgvProduct.Rows[i].Cells["dgvCmbRack"].Value = Convert.ToDecimal(dtbl.Rows[i]["rackId"].ToString()); BatchComboFill(decProductId, i, Convert.ToInt32(dgvProduct.Rows[i].Cells["dgvcmbBatch"].ColumnIndex)); dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(dtbl.Rows[i]["batchId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(dtbl.Rows[i]["unitConversionId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = dtbl.Rows[i]["barcode"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = dtbl.Rows[i]["rate"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = dtbl.Rows[i]["amount"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtvouchertypeId"].Value = Convert.ToDecimal(dtbl.Rows[i]["voucherTypeId"].ToString()); dgvProduct.Rows[i].Cells["dgvtxtvoucherNo"].Value = dtbl.Rows[i]["voucherNo"].ToString(); dgvProduct.Rows[i].Cells["dgvtxtinvoiceNo"].Value = dtbl.Rows[i]["invoiceNo"].ToString(); decAgainstVoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtvouchertypeId"].Value.ToString()); strAgainstVoucherNo = dgvProduct.Rows[i].Cells["dgvtxtvoucherNo"].Value.ToString(); UnitConvertionSP SpUnitConvertion = new UnitConvertionSP(); DataTable dtblUnitByProduct = new DataTable(); dtblUnitByProduct = SpUnitConvertion.UnitConversionIdAndConRateViewallByProductId(decProductId.ToString()); 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()); } } decCurrentRate = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtRate"].Value.ToString()); decCurrentConversionRate = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value.ToString()); decimal decReference = spMaterialReceiptMaster.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 edit the voucher /// </summary> public void EditFunction() { MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); SettingsSP spSettings = new SettingsSP(); try { infoMaterialReceiptMaster.MaterialReceiptMasterId = decMaterialReceiptMasterId; infoMaterialReceiptMaster.Date = Convert.ToDateTime(txtDate.Text); infoMaterialReceiptMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoMaterialReceiptMaster.SuffixPrefixId = Convert.ToDecimal(decMaterialReceiptSuffixPrefixId); infoMaterialReceiptMaster.VoucherNo = strVoucherNo; infoMaterialReceiptMaster.VoucherTypeId = decMaterialReceiptVoucherTypeId; infoMaterialReceiptMaster.InvoiceNo = txtReceiptNo.Text; infoMaterialReceiptMaster.UserId = PublicVariables._decCurrentUserId; infoMaterialReceiptMaster.TransportationCompany = txtTransportation.Text.Trim(); infoMaterialReceiptMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoMaterialReceiptMaster.Narration = txtNarration.Text.Trim(); infoMaterialReceiptMaster.LrNo = txtLRNo.Text.Trim(); infoMaterialReceiptMaster.exchangeRateId = Convert.ToDecimal(cmbcurrency.SelectedValue.ToString()); infoMaterialReceiptMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text); infoMaterialReceiptMaster.Extra1 = string.Empty; infoMaterialReceiptMaster.Extra2 = string.Empty; infoMaterialReceiptMaster.ExtraDate = Convert.ToDateTime(DateTime.Now); if (cmbOrderNo.Text == string.Empty || cmbOrderNo.SelectedValue.ToString() == string.Empty) { infoMaterialReceiptMaster.OrderMasterId = 0; } else { infoMaterialReceiptMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); } spMaterialReceiptMaster.MaterialReceiptMasterEdit(infoMaterialReceiptMaster); removeMaterialReceiptDetails(); MaterialReceiptDetailsEditFill(); if (isEdit) { Messages.UpdatedMessage(); if (frmMaterialReceiptRegisterObj != null) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decMaterialReceiptMasterId); } else { Print(decMaterialReceiptMasterId, infoMaterialReceiptMaster.OrderMasterId); } frmMaterialReceiptRegisterObj.GridFill(); frmMaterialReceiptRegisterObj.Enabled = true; } if (frmMaterialReceiptReportObj != null) { if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decMaterialReceiptMasterId); } else { Print(decMaterialReceiptMasterId, infoMaterialReceiptMaster.OrderMasterId); } } frmMaterialReceiptReportObj.GridFill(); frmMaterialReceiptReportObj.Enabled = true; } if (frmDayBookObj != null) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decMaterialReceiptMasterId); } else { Print(decMaterialReceiptMasterId, infoMaterialReceiptMaster.OrderMasterId); } } this.Close(); isEdit = false; } } catch (Exception ex) { MessageBox.Show("MR36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save the voucher /// </summary> public void SaveFunction() { MaterialReceiptDetailsInfo infoMaterialReceiptDetails = new MaterialReceiptDetailsInfo(); ProductInfo infoProduct = new ProductInfo(); MaterialReceiptMasterInfo infoMaterialReceiptMaster = new MaterialReceiptMasterInfo(); StockPostingSP spstockposting = new StockPostingSP(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); MaterialReceiptDetailsSP spMaterialReceiptDetails = new MaterialReceiptDetailsSP(); ProductSP spproduct = new ProductSP(); try { infoMaterialReceiptMaster.Date = Convert.ToDateTime(txtDate.Text); infoMaterialReceiptMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); if (isAutomatic) { infoMaterialReceiptMaster.SuffixPrefixId = decMaterialReceiptSuffixPrefixId; infoMaterialReceiptMaster.VoucherNo = strVoucherNo; } else { infoMaterialReceiptMaster.SuffixPrefixId = 0; infoMaterialReceiptMaster.VoucherNo = txtReceiptNo.Text; } infoMaterialReceiptMaster.VoucherTypeId = decMaterialReceiptVoucherTypeId; infoMaterialReceiptMaster.InvoiceNo = txtReceiptNo.Text; infoMaterialReceiptMaster.UserId = PublicVariables._decCurrentUserId; infoMaterialReceiptMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoMaterialReceiptMaster.TransportationCompany = txtTransportation.Text.Trim(); infoMaterialReceiptMaster.LrNo = txtLRNo.Text.Trim(); infoMaterialReceiptMaster.Narration = txtNarration.Text.Trim(); if (cmbOrderNo.SelectedValue == null || cmbOrderNo.SelectedValue.ToString() == string.Empty) { infoMaterialReceiptMaster.OrderMasterId = 0; } else { infoMaterialReceiptMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); } infoMaterialReceiptMaster.exchangeRateId = Convert.ToDecimal(cmbcurrency.SelectedValue.ToString());//saving corresponding exchangeRateId as currencyId infoMaterialReceiptMaster.TotalAmount = Convert.ToDecimal(txtTotal.Text); infoMaterialReceiptMaster.Extra1 = string.Empty; infoMaterialReceiptMaster.Extra2 = string.Empty; infoMaterialReceiptMaster.ExtraDate = Convert.ToDateTime(DateTime.Now); decMaterialReceiptMasterIdentity = Convert.ToDecimal(spMaterialReceiptMaster.MaterialReceiptMasterAdd(infoMaterialReceiptMaster)); int inRowcount = dgvProduct.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { infoMaterialReceiptDetails.MaterialReceiptMasterId = decMaterialReceiptMasterIdentity; 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()); infoMaterialReceiptDetails.ProductId = infoProduct.ProductId; } if (dgvProduct.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value != null) { infoMaterialReceiptDetails.OrderDetailsId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtPurchaseOrderDetailsId"].Value.ToString()); } else infoMaterialReceiptDetails.OrderDetailsId = 0; if (dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); } else { infoMaterialReceiptDetails.GodownId = 1; } if (dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value != null && dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvCmbRack"].Value.ToString()); } else { infoMaterialReceiptDetails.RackId = 1; } if (dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.BatchId = Convert.ToDecimal(Convert.ToString(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value)); } else { infoMaterialReceiptDetails.BatchId = 1; } if (dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != string.Empty) { infoMaterialReceiptDetails.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) { infoMaterialReceiptDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoMaterialReceiptDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); } infoMaterialReceiptDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoMaterialReceiptDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoMaterialReceiptDetails.Slno = Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoMaterialReceiptDetails.Extra1 = string.Empty; infoMaterialReceiptDetails.Exta2 = string.Empty; infoMaterialReceiptDetails.ExtraDate = Convert.ToDateTime(DateTime.Now); spMaterialReceiptDetails.MaterialReceiptDetailsAdd(infoMaterialReceiptDetails); //-----------------Stockposting---------------------------// StockPostingInfo infoStockPosting = new StockPostingInfo(); infoStockPosting.Date = infoMaterialReceiptMaster.Date; infoStockPosting.ProductId = infoMaterialReceiptDetails.ProductId; infoStockPosting.BatchId = infoMaterialReceiptDetails.BatchId; infoStockPosting.UnitId = infoMaterialReceiptDetails.UnitId; infoStockPosting.GodownId = infoMaterialReceiptDetails.GodownId; infoStockPosting.RackId = infoMaterialReceiptDetails.RackId; if (cmbOrderNo.SelectedValue != null) { if (dgvProduct.Rows[inI].Cells["dgvtxtvoucherNo"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtvoucherNo"].Value.ToString() != string.Empty) { infoStockPosting.VoucherNo = Convert.ToString(dgvProduct.Rows[inI].Cells["dgvtxtvoucherNo"].Value.ToString()); infoStockPosting.AgainstVoucherNo = strVoucherNo; } else { infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.AgainstVoucherNo = "NA"; } if (dgvProduct.Rows[inI].Cells["dgvtxtinvoiceNo"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtinvoiceNo"].Value.ToString() != string.Empty) { infoStockPosting.InvoiceNo = Convert.ToString(dgvProduct.Rows[inI].Cells["dgvtxtinvoiceNo"].Value.ToString()); infoStockPosting.AgainstInvoiceNo = txtReceiptNo.Text; } else { infoStockPosting.InvoiceNo = txtReceiptNo.Text; infoStockPosting.AgainstInvoiceNo = "NA"; } if (dgvProduct.Rows[inI].Cells["dgvtxtvouchertypeId"].Value != null && dgvProduct.Rows[inI].Cells["dgvtxtvouchertypeId"].Value.ToString() != string.Empty) { infoStockPosting.VoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtvouchertypeId"].Value.ToString()); infoStockPosting.AgainstVoucherTypeId = decMaterialReceiptVoucherTypeId; } else { infoStockPosting.VoucherTypeId = decMaterialReceiptVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; } } else { infoStockPosting.InvoiceNo = txtReceiptNo.Text; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decMaterialReceiptVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; } infoStockPosting.InwardQty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()) / Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtConversionRate"].Value.ToString()); infoStockPosting.OutwardQty = 0; infoStockPosting.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; spstockposting.StockPostingAdd(infoStockPosting); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { SettingsSP spSettings = new SettingsSP(); if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decMaterialReceiptMasterIdentity); } else { Print(decMaterialReceiptMasterIdentity, infoMaterialReceiptMaster.OrderMasterId); } } Clear(); } catch (Exception ex) { MessageBox.Show("MR35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }