/// <summary> /// Function to insert values to StockPosting Table /// </summary> /// <param name="stockpostinginfo"></param> /// <returns></returns> public decimal StockPostingAdd(StockPostingInfo stockpostinginfo) { decimal decProductId = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StockPostingAdd", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = stockpostinginfo.Date; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.ProductId; sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.BatchId; sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.UnitId; sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.GodownId; sprmparam = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.RackId; sprmparam = sccmd.Parameters.Add("@againstVoucherTypeId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.AgainstVoucherTypeId; sprmparam = sccmd.Parameters.Add("@againstInvoiceNo", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.AgainstInvoiceNo; sprmparam = sccmd.Parameters.Add("@againstVoucherNo", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.AgainstVoucherNo; sprmparam = sccmd.Parameters.Add("@inwardQty", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.InwardQty; sprmparam = sccmd.Parameters.Add("@outwardQty", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.OutwardQty; sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.Rate; sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.FinancialYearId; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.Extra2; decProductId = Convert.ToDecimal(sccmd.ExecuteScalar()); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } return decProductId; }
/// <summary> /// Function to get particular values from StockPosting Table based on the parameter /// </summary> /// <param name="stockPostingId"></param> /// <returns></returns> public StockPostingInfo StockPostingView(decimal stockPostingId) { StockPostingInfo stockpostinginfo = new StockPostingInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StockPostingView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@stockPostingId", SqlDbType.Decimal); sprmparam.Value = stockPostingId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { stockpostinginfo.StockPostingId = decimal.Parse(sdrreader[0].ToString()); stockpostinginfo.Date = DateTime.Parse(sdrreader[1].ToString()); stockpostinginfo.VoucherTypeId = decimal.Parse(sdrreader[2].ToString()); stockpostinginfo.VoucherNo = sdrreader[3].ToString(); stockpostinginfo.InvoiceNo = sdrreader[4].ToString(); stockpostinginfo.ProductId = decimal.Parse(sdrreader[5].ToString()); stockpostinginfo.BatchId = decimal.Parse(sdrreader[6].ToString()); stockpostinginfo.UnitId = decimal.Parse(sdrreader[7].ToString()); stockpostinginfo.GodownId = decimal.Parse(sdrreader[8].ToString()); stockpostinginfo.RackId = decimal.Parse(sdrreader[9].ToString()); stockpostinginfo.AgainstVoucherTypeId = decimal.Parse(sdrreader[10].ToString()); stockpostinginfo.AgainstInvoiceNo = sdrreader[11].ToString(); stockpostinginfo.AgainstVoucherNo = sdrreader[12].ToString(); stockpostinginfo.InwardQty = decimal.Parse(sdrreader[13].ToString()); stockpostinginfo.OutwardQty = decimal.Parse(sdrreader[14].ToString()); stockpostinginfo.Rate = decimal.Parse(sdrreader[15].ToString()); stockpostinginfo.FinancialYearId = decimal.Parse(sdrreader[16].ToString()); stockpostinginfo.ExtraDate = DateTime.Parse(sdrreader[17].ToString()); stockpostinginfo.Extra1 = sdrreader[18].ToString(); stockpostinginfo.Extra2 = sdrreader[19].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return(stockpostinginfo); }
/// <summary> /// Function for New Row Added To Delete From tbl_StockPosting /// </summary> /// <param name="inI"></param> public void StockPostingNewRows(int inI) { try { StockPostingSP spStockPosting = new StockPostingSP(); StockPostingInfo infoStockPosting = new StockPostingInfo(); int inRow = inI; infoStockPosting.AgainstInvoiceNo = string.Empty; infoStockPosting.AgainstVoucherNo = string.Empty; infoStockPosting.Date = PublicVariables._dtCurrentDate; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.InvoiceNo = Convert.ToString(decProductIdForEdit); infoStockPosting.VoucherNo = Convert.ToString(decProductIdForEdit); infoStockPosting.VoucherTypeId = 2; // infoStockPosting.UnitId = decUnitIdForUpdate; infoStockPosting.UnitId = Convert.ToDecimal(dgvProductCreation.Rows[inRow].Cells["dgvcmbUnit"].Value); infoStockPosting.GodownId = Convert.ToDecimal(dgvProductCreation.Rows[inRow].Cells["dgvcmbtgodown"].Value); infoStockPosting.InwardQty = Convert.ToDecimal(dgvProductCreation.Rows[inRow].Cells["dgvtxtqty"].Value); infoStockPosting.OutwardQty = 0; infoStockPosting.RackId = Convert.ToDecimal(dgvProductCreation.Rows[inRow].Cells["dgvcmbrack"].Value); infoStockPosting.Rate = Convert.ToDecimal(dgvProductCreation.Rows[inRow].Cells["dgvtxtrate"].Value); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; infoStockPosting.ExtraDate = DateTime.Now; infoStockPosting.ProductId = decProductIdForEdit; if (cmbAllowBatch.SelectedIndex == 0) { int inId = spStockPosting.ReturnBatchIdFromStockPosting(decProductIdForEdit); infoStockPosting.BatchId = inId; } else { // infoStockPosting.BatchId = decBatchId; infoStockPosting.BatchId = Convert.ToDecimal(dgvProductCreation.Rows[inRow].Cells["dgvtxtbatchId"].Value); } decimal decId = spStockPosting.StockPostingAdd(infoStockPosting); dgvProductCreation.Rows[inRow].Cells["dgvtxtstockpostId"].Value = decId; } catch (Exception ex) { MessageBox.Show("PC:72" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for call from productRegister /// </summary> public void CallFromProductRegister(decimal decId, frmProductRegister frmProRegister) { try { base.Show(); this.frmProductRegisterObj = frmProRegister; frmProductRegisterObj.Enabled = false; ProductSP spProduct = new ProductSP(); ProductInfo infoProduct = new ProductInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); BatchInfo infoBatch = new BatchInfo(); StockPostingSP spStockposting = new StockPostingSP(); BatchSP spBatch = new BatchSP(); DataTable dtbl = new DataTable(); UnitSP spUnit = new UnitSP(); decProductIdForEdit = decId; infoProduct = spProduct.ProductView(decId); strUnitNameForGrid = spUnit.UnitName(infoProduct.UnitId); btnSave.Text = "Update"; btnDelete.Enabled = true; //cmbUnit.Enabled = false; txtName.Text = infoProduct.ProductName; txtProductCode.Text = infoProduct.ProductCode; cmbGroup.SelectedValue = infoProduct.GroupId; cmbBrand.SelectedValue = infoProduct.BrandId; cmbUnit.SelectedValue = infoProduct.UnitId; if (spProduct.ProductReferenceCheck(decId)) { cmbUnit.Enabled = false; } decUnitIdForUpdate = infoProduct.UnitId; cmbSize.SelectedValue = infoProduct.SizeId; cmbModalNo.SelectedValue = infoProduct.ModelNoId; cmbTax.SelectedValue = infoProduct.TaxId; cmbTaxApplicableOn.SelectedItem = infoProduct.TaxapplicableOn; txtPurchaseRate.Text = infoProduct.PurchaseRate.ToString(); txtSalesRate.Text = infoProduct.SalesRate.ToString(); txtMrp.Text = infoProduct.Mrp.ToString(); txtMinimumStock.Text = infoProduct.MinimumStock.ToString(); txtMaximumStock.Text = infoProduct.MaximumStock.ToString(); txtReorderLevel.Text = infoProduct.ReorderLevel.ToString(); txtPartNo.Text = infoProduct.PartNo; cmbDefaultGodown.SelectedValue = infoProduct.GodownId; cmbDefaultRack.SelectedValue = infoProduct.RackId; if (infoProduct.IsBom) { cmbBom.SelectedIndex = 1; isBomFromRegister = true; } if (infoProduct.Ismultipleunit) { cmbMultipleUnit.SelectedIndex = 1; isMulUnitFromRgister = true; } if (infoProduct.Isopeningstock) { isOpeningStockForUpdate = true; OpeningStockGridFill(); } if (infoProduct.IsallowBatch) { OpeningStockGridWithBathFill(); } else { cmbAllowBatch.SelectedIndex = 0; txtPartNo.Text = spBatch.PartNoReturn(decProductIdForEdit); } if (infoProduct.Ismultipleunit) { cmbMultipleUnit.SelectedIndex = 1; } else { cmbMultipleUnit.SelectedIndex = 0; } if (infoProduct.IsBom) { cmbBom.SelectedIndex = 1; } else { cmbBom.SelectedIndex = 0; } if (infoProduct.Isopeningstock) { cmbOpeningStock.SelectedIndex = 1; } else { cmbOpeningStock.SelectedIndex = 0; } if (infoProduct.IsActive) { cbxActive.Checked = true; } else { cbxActive.Checked = false; } if (infoProduct.IsshowRemember) { cbxReminder.Checked = true; } else { cbxReminder.Checked = false; } txtNarration.Text = infoProduct.Narration; } catch (Exception ex) { MessageBox.Show("PC:63" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Edit stockposting table /// </summary> public void StockPostingTableEditFill() { try { StockPostingSP spStockPosting = new StockPostingSP(); StockPostingInfo infoStockPosting = new StockPostingInfo(); BatchSP spBatch = new BatchSP(); for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++) { infoStockPosting.StockPostingId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtstockpostId"].Value); infoStockPosting.AgainstInvoiceNo = string.Empty; infoStockPosting.AgainstVoucherNo = string.Empty; infoStockPosting.Date = PublicVariables._dtCurrentDate; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.InvoiceNo = Convert.ToString(decProductIdForEdit); infoStockPosting.VoucherNo = Convert.ToString(decProductIdForEdit); infoStockPosting.VoucherTypeId = 2; infoStockPosting.UnitId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbUnit"].Value); infoStockPosting.InwardQty = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtqty"].Value); infoStockPosting.OutwardQty = 0; infoStockPosting.ProductId = decProductIdForEdit; infoStockPosting.Rate = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtrate"].Value); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; infoStockPosting.ExtraDate = DateTime.Now; if (!dgvProductCreation.Columns["dgvcmbrack"].Visible) { infoStockPosting.RackId = 1; } else { infoStockPosting.RackId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Value); } if (!dgvProductCreation.Columns["dgvcmbtgodown"].Visible) { infoStockPosting.GodownId = 1; } else { infoStockPosting.GodownId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Value); } if (cmbAllowBatch.SelectedIndex == 0) { if (isBatchRemoved) { infoStockPosting.BatchId = spBatch.BatchIdForStockPosting(decProductIdForEdit); } else { int inId = spStockPosting.ReturnBatchIdFromStockPosting(decProductIdForEdit); infoStockPosting.BatchId = inId; } } else { infoStockPosting.BatchId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtbatchId"].Value); } isStpUpdated = spStockPosting.StockPostingEdit(infoStockPosting); } } catch (Exception ex) { MessageBox.Show("PC:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function for Save and Edit /// </summary> public void SaveOrEdit() { try { PurchaseMasterSP SPPurchaseMaster = new PurchaseMasterSP(); PurchaseReturnMasterSP SPPurchaseReturnMaster = new PurchaseReturnMasterSP(); PurchaseReturnDetailsSP SPPurchaseReturnDetails = new PurchaseReturnDetailsSP(); PurchaseReturnDetailsInfo infoPurchaseReturnDetails = new PurchaseReturnDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); StockPostingSP spStockPosting = new StockPostingSP(); UnitConvertionSP SPUnitConversion = new UnitConvertionSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); ExchangeRateSP spExchangeRate = new ExchangeRateSP(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); AccountLedgerInfo infoAccountLedger = new AccountLedgerInfo(); AccountLedgerSP spAccountLedger = new AccountLedgerSP(); PurchaseReturnBilltaxInfo infoPurchaseReturnBillTax = new PurchaseReturnBilltaxInfo(); PurchaseReturnBilltaxSP spPurchaseReturnBillTax = new PurchaseReturnBilltaxSP(); SettingsSP spSettings = new SettingsSP(); UnitSP spUnit = new UnitSP(); DataTable dtblPurchaseMasterViewById = new DataTable(); string strAgainstVoucherNo = string.Empty; string strAgainstInvoiceNo = string.Empty; decimal decPurchaseReturnMasterIds = 0; decimal decPurchaseMasterId = 0; decimal decDiscount = 0; decimal decExchangeRate = 0; decimal decDis = 0; if (isAutomatic) { if (strVoucherNo != string.Empty) { infoPurchaseReturnMaster.VoucherNo = strVoucherNo; } if (txtReturnNo.Text != string.Empty) { infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text; } } else { infoPurchaseReturnMaster.VoucherNo = strVoucherNo; infoPurchaseReturnMaster.InvoiceNo = txtReturnNo.Text; } if (decPurchaseReturnVoucherTypeId != 0) { infoPurchaseReturnMaster.VoucherTypeId = decPurchaseReturnVoucherTypeId; } infoPurchaseReturnMaster.SuffixPrefixId = (decPurchaseReturnSuffixPrefixId != 0) ? decPurchaseReturnSuffixPrefixId : 0; infoPurchaseReturnMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPurchaseReturnMaster.PurchaseAccount = Convert.ToDecimal(cmbPurchaseAccount.SelectedValue.ToString()); if (cmbInvoiceNo.SelectedValue != null && cmbInvoiceNo.Visible == true) { infoPurchaseReturnMaster.PurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString())); decPurchaseMasterId = Convert.ToDecimal((cmbInvoiceNo.SelectedValue.ToString())); } else { infoPurchaseReturnMaster.PurchaseMasterId = 0; } infoPurchaseReturnMaster.ExchangeRateId = (cmbCurrency.SelectedValue != null) ? Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()) : 0; infoPurchaseReturnMaster.Narration = txtNarration.Text.Trim(); infoPurchaseReturnMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseReturnMaster.LrNo = txtLrlNo.Text.Trim(); infoPurchaseReturnMaster.TransportationCompany = txtTransportationCompany.Text.Trim(); infoPurchaseReturnMaster.Date = Convert.ToDateTime(txtDate.Text); infoPurchaseReturnMaster.TotalAmount = (txtTotalAmount.Text != string.Empty) ? Convert.ToDecimal(txtTotalAmount.Text) : 0; infoPurchaseReturnMaster.TotalTax = (lblTaxAmount.Text != string.Empty) ? Convert.ToDecimal(lblTaxAmount.Text) : 0; infoPurchaseReturnMaster.Discount = (txtBillDiscount.Text != string.Empty) ? Convert.ToDecimal(txtBillDiscount.Text) : 0; infoPurchaseReturnMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseReturnMaster.Extra1 = string.Empty; infoPurchaseReturnMaster.Extra2 = string.Empty; infoPurchaseReturnMaster.ExtraDate = DateTime.Now; infoPurchaseReturnMaster.GrandTotal = (txtGrandTotal.Text != string.Empty) ? Convert.ToDecimal(txtGrandTotal.Text) : 0; if (btnSave.Text == "Save") { decPurchaseReturnMasterIds = SPPurchaseReturnMaster.PurchaseReturnMasterAddWithReturnIdentity(infoPurchaseReturnMaster); } else { infoPurchaseReturnMaster.PurchaseReturnMasterId = decPurchaseReturnMasterId; decExchangeRate = spExchangeRate.ExchangeRateViewByExchangeRateId(infoPurchaseReturnMaster.ExchangeRateId); SPPurchaseReturnMaster.PurchaseReturnMasterEdit(infoPurchaseReturnMaster); infoPurchaseMaster = SPPurchaseMaster.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); spLedgerPosting.LedgerPostDelete(strVoucherNo, decPurchaseReturnVoucherTypeId); spAccountLedger.PartyBalanceDeleteByVoucherTypeVoucherNoAndReferenceType(strVoucherNo, decPurchaseReturnVoucherTypeId); } infoLedgerPosting.Date = infoPurchaseReturnMaster.Date; infoLedgerPosting.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoLedgerPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoLedgerPosting.ChequeNo = string.Empty; infoLedgerPosting.ChequeDate = DateTime.Now; infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.PurchaseAccount; infoLedgerPosting.Debit = 0; if (btnSave.Text == "Save") { infoLedgerPosting.Credit = TotalNetAmountCalculation() * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.ExtraDate = DateTime.Now; } else { infoLedgerPosting.Credit = TotalNetAmountCalculation(); } spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.LedgerId = infoPurchaseReturnMaster.LedgerId; if (btnSave.Text == "Save") { infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text) * spExchangeRate.ExchangeRateViewByExchangeRateId(Convert.ToDecimal(cmbCurrency.SelectedValue.ToString())); infoLedgerPosting.ExtraDate = DateTime.Now; } else { infoLedgerPosting.Debit = Convert.ToDecimal(txtGrandTotal.Text); } infoLedgerPosting.Credit = 0; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); foreach (DataGridViewRow dgvrow in dgvPurchaseReturnTax.Rows) { if (dgvrow.Cells["dgvtxtTaxId"].Value != null && dgvrow.Cells["dgvtxtTaxId"].Value.ToString() != string.Empty) { infoLedgerPosting.LedgerId = Convert.ToDecimal(dgvrow.Cells["dgvtxtledgerId"].Value.ToString()); infoLedgerPosting.Credit = (dgvrow.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(dgvrow.Cells["dgvtxtAmounts"].Value.ToString()); infoLedgerPosting.Debit = 0; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } } if (txtBillDiscount.Text.Trim() != string.Empty) { decDis = Convert.ToDecimal(txtBillDiscount.Text); } if (decDis >= 0) { infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = decDis; infoLedgerPosting.LedgerId = 9; infoLedgerPosting.ExtraDate = DateTime.Now; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } if (btnSave.Text == "Update") { infoPurchaseReturnMaster = SPPurchaseReturnMaster.PurchaseReturnMasterView(decPurchaseReturnMasterId); if (infoPurchaseReturnMaster.PurchaseMasterId == 0) { spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(0, "NA", infoPurchaseReturnMaster.VoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } if (infoPurchaseReturnMaster.PurchaseMasterId != 0) { infoPurchaseMaster = SPPurchaseMaster.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); spStockPosting.StockPostingDeleteByagainstVoucherTypeIdAndagainstVoucherNoAndVoucherNoAndVoucherType(infoPurchaseMaster.VoucherTypeId, strInvoiceNo, strVoucherNo, infoPurchaseReturnMaster.VoucherTypeId); } } foreach (DataGridViewRow dgvrow in dgvPurchaseReturn.Rows) { if (dgvrow.Cells["dgvtxtProductId"].Value != null && dgvrow.Cells["dgvtxtProductId"].Value.ToString() != string.Empty) { infoPurchaseReturnDetails.ExtraDate = DateTime.Now; infoPurchaseReturnDetails.Extra1 = string.Empty; infoPurchaseReturnDetails.Extra2 = string.Empty; infoPurchaseReturnDetails.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterId; infoPurchaseReturnDetails.ProductId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtproductId"].Value)); infoPurchaseReturnDetails.Qty = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtqty"].Value)); infoPurchaseReturnDetails.Rate = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtrate"].Value)); if (btnSave.Text == "Save") { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); infoPurchaseReturnDetails.UnitConversionId = SPUnitConversion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId); } else { if (Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value) == 0) { try { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); } catch { infoPurchaseReturnDetails.UnitId = spUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString())); } infoPurchaseReturnDetails.UnitConversionId = SPUnitConversion.UnitconversionIdViewByUnitIdAndProductId(infoPurchaseReturnDetails.UnitId, infoPurchaseReturnDetails.ProductId); } else { try { infoPurchaseReturnDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); } catch { infoPurchaseReturnDetails.UnitId = spUnit.UnitIdByUnitName(Convert.ToString(dgvrow.Cells["dgvcmbUnit"].Value.ToString())); } } infoPurchaseReturnDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value); } infoPurchaseReturnDetails.Discount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtdiscount"].Value)); if (dgvrow.Cells["dgvcmbTax"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value) != string.Empty && dgvrow.Cells["dgvcmbTax"].Value as string != "NA") { infoPurchaseReturnDetails.TaxId = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvcmbTax"].Value)); if (strTaxComboFill != string.Empty) { infoPurchaseReturnDetails.TaxAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtTaxAmount"].Value)); } } else { infoPurchaseReturnDetails.TaxId = 0; } if (dgvrow.Cells["dgvcmbBatch"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbBatch"].Value) != string.Empty) { infoPurchaseReturnDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value); } else { infoPurchaseReturnDetails.GodownId = 0; } if (dgvrow.Cells["dgvcmbGodown"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbGodown"].Value) != string.Empty) { infoPurchaseReturnDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value); } else { infoPurchaseReturnDetails.RackId = 0; } if (dgvrow.Cells["dgvcmbRack"].Value != null && Convert.ToString(dgvrow.Cells["dgvcmbRack"].Value) != string.Empty) { infoPurchaseReturnDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value); } infoPurchaseReturnDetails.GrossAmount = Convert.ToDecimal(dgvrow.Cells["dgvtxtgrossValue"].Value.ToString()); infoPurchaseReturnDetails.NetAmount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtNetAmount"].Value)); infoPurchaseReturnDetails.Amount = Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtAmount"].Value)); infoPurchaseReturnDetails.SlNo = Convert.ToInt32(Convert.ToString(dgvrow.Cells["dgvtxtSlNo"].Value)); infoPurchaseReturnDetails.PurchaseDetailsId = (dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value != null) ? Convert.ToDecimal(Convert.ToString(dgvrow.Cells["dgvtxtPurchaseDetailsId"].Value)) : 0; if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value != null) { if (dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == "0" || dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString() == string.Empty) { SPPurchaseReturnDetails.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails); } else { infoPurchaseReturnDetails.PurchaseReturnDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxtPurchaseReturnDetailsId"].Value.ToString()); SPPurchaseReturnDetails.PurchaseReturnDetailsEdit(infoPurchaseReturnDetails); } } else { SPPurchaseReturnDetails.PurchaseReturnDetailsAddWithReturnIdentity(infoPurchaseReturnDetails); } if (btnSave.Text == "Save") { infoPurchaseMaster = SPPurchaseMaster.PurchaseMasterView(infoPurchaseReturnMaster.PurchaseMasterId); } infoStockPosting.Date = infoPurchaseReturnMaster.Date; infoStockPosting.ProductId = infoPurchaseReturnDetails.ProductId; infoStockPosting.BatchId = infoPurchaseReturnDetails.BatchId; infoStockPosting.UnitId = infoPurchaseReturnDetails.UnitId; infoStockPosting.GodownId = infoPurchaseReturnDetails.GodownId; infoStockPosting.RackId = infoPurchaseReturnDetails.RackId; decimal decConversionId = SPUnitConversion.UnitConversionRateByUnitConversionId(infoPurchaseReturnDetails.UnitConversionId); //infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty / (decConversionId == 0 ? 1 : decConversionId); infoStockPosting.OutwardQty = infoPurchaseReturnDetails.Qty; infoStockPosting.InwardQty = 0; infoStockPosting.Rate = infoPurchaseReturnDetails.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; if (infoPurchaseReturnDetails.PurchaseDetailsId != 0) { infoStockPosting.AgainstVoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoStockPosting.AgainstVoucherNo = infoPurchaseMaster.VoucherNo; infoStockPosting.AgainstInvoiceNo = infoPurchaseMaster.InvoiceNo; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = txtReturnNo.Text.Trim(); infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId; decAgainstVoucherTypeId = infoStockPosting.VoucherTypeId; } else { infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoStockPosting.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoStockPosting.VoucherTypeId = decPurchaseReturnVoucherTypeId; decAgainstVoucherTypeId = 0; } spStockPosting.StockPostingAdd(infoStockPosting); } } if (btnSave.Text == "Update") { removePurchaseReturnDetails(); } infoAccountLedger = spAccountLedger.AccountLedgerView(infoPurchaseReturnMaster.LedgerId); if (infoAccountLedger.BillByBill == true) { infoPartyBalance.Date = infoPurchaseReturnMaster.Date; infoPartyBalance.LedgerId = infoPurchaseReturnMaster.LedgerId; if (decAgainstVoucherTypeId != 0) { infoPartyBalance.VoucherTypeId = infoPurchaseMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoPurchaseMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoPurchaseMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoPartyBalance.AgainstVoucherNo = infoPurchaseReturnMaster.VoucherNo; infoPartyBalance.AgainstInvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoPartyBalance.ReferenceType = "Against"; } else { infoPartyBalance.VoucherTypeId = infoPurchaseReturnMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoPurchaseReturnMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoPurchaseReturnMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "NA"; infoPartyBalance.AgainstInvoiceNo = "NA"; infoPartyBalance.ReferenceType ="New"; } infoPartyBalance.Debit = infoPurchaseReturnMaster.TotalAmount; infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = 0; infoPartyBalance.ExchangeRateId = infoPurchaseReturnMaster.ExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; spPartyBalance.PartyBalanceAdd(infoPartyBalance); } foreach (DataGridViewRow item in dgvPurchaseReturnTax.Rows) { if (item.Cells["dgvtxtTaxId"].Value != null) { infoPurchaseReturnBillTax.PurchaseReturnMasterId = (btnSave.Text == "Save") ? decPurchaseReturnMasterIds : decPurchaseReturnMasterIds; infoPurchaseReturnBillTax.TaxId = Convert.ToDecimal(item.Cells["dgvtxtTaxId"].Value.ToString()); infoPurchaseReturnBillTax.TaxAmount = (item.Cells["dgvtxtAmounts"].Value == null) ? 0 : Convert.ToDecimal(item.Cells["dgvtxtAmounts"].Value.ToString()); infoPurchaseReturnBillTax.Extra1 = string.Empty; infoPurchaseReturnBillTax.Extra2 = string.Empty; spPurchaseReturnBillTax.PurchaseReturnBilltaxAdd(infoPurchaseReturnBillTax); } } if (btnSave.Text == "Save") { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseReturnMasterIds); } else { Print(decPurchaseReturnMasterIds); } } Clear(); } else { decDiscount = Convert.ToDecimal(txtBillDiscount.Text); Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseReturnMasterId); } else { Print(decPurchaseReturnMasterId); } } if (frmPurchaseReturnRegisterObj != null) { frmPurchaseReturnRegisterObj.GridFill(); frmPurchaseReturnRegisterObj.Enabled = true; } if (ObjPurchaseReturnReport != null) { ObjPurchaseReturnReport.PurchaseReturnReportGridFill(); ObjPurchaseReturnReport.Enabled = true; } if (frmLedgerDetailsObj != null) { frmLedgerDetailsObj.LedgerDetailsView(); frmLedgerDetailsObj.Enabled = true; } this.Close(); } } catch (Exception ex) { MessageBox.Show("PR:49" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the voucher details for edit /// </summary> public void MaterialReceiptDetailsEditFill() { ProductInfo infoProduct = new ProductInfo(); MaterialReceiptDetailsInfo infoMaterialReceiptDetails = new MaterialReceiptDetailsInfo(); StockPostingSP spstockposting = new StockPostingSP(); MaterialReceiptMasterSP spMaterialReceiptMaster = new MaterialReceiptMasterSP(); MaterialReceiptDetailsSP spMaterialReceiptDetails = new MaterialReceiptDetailsSP(); ProductSP spproduct = new ProductSP(); try { for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++) { decimal decStatus = spMaterialReceiptMaster.MaterialReceiptDetailsReferenceCheck(decMaterialReceiptDetailId); if (decStatus == 1) { dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvtxtProductName"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvcmbUnit"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvtxtBarcode"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvCmbRack"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvcmbGodown"].ReadOnly = true; dgvProduct.Rows[inI].Cells["dgvtxtRate"].ReadOnly = true; } if (dgvProduct.Rows[inI].Cells["dgvtxtProductName"].Value != null) { if (dgvProduct.Rows[inI].Cells["dgvtxtMaterialReceiptdetailsId"].Value == null || dgvProduct.Rows[inI].Cells["dgvtxtMaterialReceiptdetailsId"].Value.ToString() == string.Empty) { infoMaterialReceiptDetails.MaterialReceiptMasterId = decMaterialReceiptMasterId; 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; infoMaterialReceiptDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoMaterialReceiptDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoMaterialReceiptDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value); 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(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); } else { infoMaterialReceiptDetails.BatchId = 1; } 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); } else { infoMaterialReceiptDetails.MaterialReceiptMasterId = decMaterialReceiptMasterId; infoMaterialReceiptDetails.MaterialReceiptDetailsId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtMaterialReceiptdetailsId"].Value); 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; infoMaterialReceiptDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoMaterialReceiptDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoMaterialReceiptDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value); infoMaterialReceiptDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); 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(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); } else { infoMaterialReceiptDetails.BatchId = 1; } 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.MaterialReceiptDetailsEdit(infoMaterialReceiptDetails); } StockPostingInfo infoStockPosting = new StockPostingInfo(); infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); 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 && dgvProduct.Rows[inI].Cells["dgvtxtvoucherNo"].Value.ToString() != "NA") { 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 && dgvProduct.Rows[inI].Cells["dgvtxtinvoiceNo"].Value.ToString() != "NA") { 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 && Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtvouchertypeId"].Value.ToString()) != 0) { 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"; } spstockposting.StockPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decMaterialReceiptVoucherTypeId); infoStockPosting.InwardQty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].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); isEdit = true; } } if (isEdit) { cmbCashOrParty.Enabled = true; cmbOrderNo.Enabled = true; cmbcurrency.Enabled = true; txtDate.Enabled = true; cmbVoucherType.Enabled = true; } } catch (Exception ex) { MessageBox.Show("MR37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save function /// </summary> public void SaveFunction() { SalesMasterSP spSalesMaster = new SalesMasterSP(); SalesDetailsSP spSalesDetails = new SalesDetailsSP(); StockPostingInfo infoStockPosting = new StockPostingInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); SalesDetailsInfo InfoSalesDetails = new SalesDetailsInfo(); StockPostingSP spStockPosting = new StockPostingSP(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); SalesBillTaxInfo infoSalesBillTax = new SalesBillTaxInfo(); SalesBillTaxSP spSalesBillTax = new SalesBillTaxSP(); UnitConvertionSP SPUnitConversion = new UnitConvertionSP(); try { InfoSalesMaster.AdditionalCost = Convert.ToDecimal(lblLedgerTotalAmount.Text); InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text.Trim()); InfoSalesMaster.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.Trim().ToString()); InfoSalesMaster.CustomerName = txtCustomer.Text.Trim(); InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text.ToString()); InfoSalesMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); InfoSalesMaster.VoucherTypeId = DecSalesInvoiceVoucherTypeId; if (isAutomatic) { InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim(); InfoSalesMaster.VoucherNo = strVoucherNo; InfoSalesMaster.SuffixPrefixId = decSalseInvoiceSuffixPrefixId; } else { InfoSalesMaster.InvoiceNo = txtInvoiceNo.Text.Trim(); InfoSalesMaster.VoucherNo = strVoucherNo; InfoSalesMaster.SuffixPrefixId = 0; } if (cmbSalesMode.Text == "Against SalesOrder") { InfoSalesMaster.OrderMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.OrderMasterId = 0; } if (cmbSalesMode.Text == "Against Delivery Note") { InfoSalesMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.DeliveryNoteMasterId = 0; } if (cmbSalesMode.Text == "Against Quotation") { InfoSalesMaster.QuotationMasterId = Convert.ToDecimal(cmbSalesModeOrderNo.SelectedValue.ToString()); } else { InfoSalesMaster.QuotationMasterId = 0; } InfoSalesMaster.Narration = txtNarration.Text.Trim(); InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text.Trim()); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text.Trim()); } else { InfoSalesMaster.TaxAmount = 0; } InfoSalesMaster.UserId = PublicVariables._decCurrentUserId; InfoSalesMaster.LrNo = txtVehicleNo.Text; InfoSalesMaster.TransportationCompany = txtTransportCompany.Text.Trim(); InfoSalesMaster.POS = false; InfoSalesMaster.CounterId = 0; InfoSalesMaster.ExtraDate = DateTime.Now; InfoSalesMaster.Extra1 = string.Empty; InfoSalesMaster.Extra2 = string.Empty; decimal decSalesMasterId = spSalesMaster.SalesMasterAdd(InfoSalesMaster); int inRowCount = dgvSalesInvoice.RowCount; InfoSalesDetails.SalesMasterId = decSalesMasterId; InfoSalesDetails.ExtraDate = DateTime.Now; InfoSalesDetails.Extra1 = string.Empty; InfoSalesDetails.Extra2 = string.Empty; string strAgainstInvoiceN0 = txtInvoiceNo.Text.Trim(); for (int inI = 0; inI < inRowCount - 1; inI++) { if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty) { if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty) { if (cmbSalesMode.Text == "Against SalesOrder") { InfoSalesDetails.OrderDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value.ToString()); } else { InfoSalesDetails.OrderDetailsId = 0; } if (cmbSalesMode.Text == "Against Delivery Note") { InfoSalesDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()); } else { InfoSalesDetails.DeliveryNoteDetailsId = 0; } if (cmbSalesMode.Text == "Against Quotation") { InfoSalesDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value.ToString()); } else { InfoSalesDetails.QuotationDetailsId = 0; } InfoSalesDetails.SlNo = Convert.ToInt32(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSlno"].Value.ToString()); InfoSalesDetails.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); InfoSalesDetails.Qty = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()); InfoSalesDetails.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); InfoSalesDetails.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value.ToString()); InfoSalesDetails.Discount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString()); InfoSalesDetails.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { InfoSalesDetails.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); } else { InfoSalesDetails.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { InfoSalesDetails.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { InfoSalesDetails.RackId = 0; } if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesDetails.TaxId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString()); InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString()); } else { InfoSalesDetails.TaxId = 1; InfoSalesDetails.TaxAmount = 0; } InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString()); InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString()); InfoSalesDetails.Amount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceAmount"].Value.ToString()); spSalesDetails.SalesDetailsAdd(InfoSalesDetails); infoStockPosting.Date = Convert.ToDateTime(txtDate.Text.Trim().ToString()); infoStockPosting.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); infoStockPosting.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); infoStockPosting.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { infoStockPosting.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); } else { infoStockPosting.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { infoStockPosting.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { infoStockPosting.RackId = 0; } infoStockPosting.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.ExtraDate = DateTime.Now; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()) != 0) { infoStockPosting.InwardQty = InfoSalesDetails.Qty / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.VoucherNo = strVoucherNoTostockPost; infoStockPosting.AgainstVoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = strInvoiceNoTostockPost; infoStockPosting.AgainstInvoiceNo = strAgainstInvoiceN0; infoStockPosting.VoucherTypeId = decVouchertypeIdTostockPost; infoStockPosting.AgainstVoucherTypeId = DecSalesInvoiceVoucherTypeId; spStockPosting.StockPostingAdd(infoStockPosting); } } infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = InfoSalesDetails.Qty / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.VoucherNo = InfoSalesMaster.VoucherNo; ; infoStockPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoStockPosting.InvoiceNo = InfoSalesMaster.InvoiceNo; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; spStockPosting.StockPostingAdd(infoStockPosting); } } } if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { int inTaxRowCount = dgvSalesInvoiceTax.RowCount; infoSalesBillTax.SalesMasterId = decSalesMasterId; infoSalesBillTax.ExtraDate = DateTime.Now; infoSalesBillTax.Extra1 = string.Empty; infoSalesBillTax.Extra2 = string.Empty; for (int inI = 0; inI < inTaxRowCount; inI++) { if (dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value != null && dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty) { if (dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value != null && dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value.ToString() != string.Empty) { decimal decAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value); if (decAmount > 0) { infoSalesBillTax.TaxId = Convert.ToInt32(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxId"].Value.ToString()); infoSalesBillTax.TaxAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inI].Cells["dgvtxtTtaxAmount"].Value.ToString()); spSalesBillTax.SalesBillTaxAdd(infoSalesBillTax); } } } } } int inAddRowCount = dgvSalesInvoiceLedger.RowCount; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; for (int inI = 0; inI < inAddRowCount; inI++) { if (dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { if (dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null && dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != string.Empty) { infoAdditionalCost.LedgerId = Convert.ToInt32(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()); if (!cmbCashOrbank.Visible) { infoAdditionalCost.Debit = 0; infoAdditionalCost.Credit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); } else { infoAdditionalCost.Debit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inI].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); infoAdditionalCost.Credit = 0; } spAdditionalCost.AdditionalCostAdd(infoAdditionalCost); } } } if (!cmbCashOrbank.Visible) { decimal decCAshOrBankId = 0; decCAshOrBankId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString()); if (decTotalAddAmount > 0) { infoAdditionalCost.Debit = decTotalAddAmount; infoAdditionalCost.Credit = 0; infoAdditionalCost.LedgerId = decCAshOrBankId; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; spAdditionalCost.AdditionalCostAdd(infoAdditionalCost); } } else { if (cmbCashOrbank.Visible) { decimal decCAshOrBankId = 0; decCAshOrBankId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString()); if (decTotalAddAmount > 0) { infoAdditionalCost.Debit = 0; infoAdditionalCost.Credit = decTotalAddAmount; infoAdditionalCost.LedgerId = decCAshOrBankId; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; spAdditionalCost.AdditionalCostAdd(infoAdditionalCost); } } } ledgerPostingAdd(); if (spSalesMaster.SalesInvoiceInvoicePartyCheckEnableBillByBillOrNot(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()))) { partyBalanceAdd(); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked == true) { SettingsSP spSettings = new SettingsSP(); if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesMasterId); } else { Print(decSalesMasterId); } } Clear(); } catch (Exception ex) { MessageBox.Show("SI: 70" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo(); DeliveryNoteDetailsInfo infoDeliveryNoteDetails = new DeliveryNoteDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); StockPostingSP spStockPosting = new StockPostingSP(); DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP(); DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP(); SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderMasterSP spSalesOrderMaster = new SalesOrderMasterSP(); SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); SalesQuotationMasterSP spSalesQuotationMaster = new SalesQuotationMasterSP(); infoDeliveryNoteMaster.InvoiceNo = txtDeliveryNoteNo.Text; infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId; infoDeliveryNoteMaster.Date = Convert.ToDateTime(txtDate.Text); infoDeliveryNoteMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoDeliveryNoteMaster.VoucherNo = strVoucherNo; infoDeliveryNoteMaster.SuffixPrefixId = decDeliveryNoteSuffixPrefixId; if (btnSave.Text == "Save") { if (cmbOrderNo.SelectedValue != null) { if (cmbDeliveryMode.Text == "Against Order") { infoDeliveryNoteMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesQuotationMaster = spSalesQuotationMaster.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId); } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0; } } else { infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0; } infoDeliveryNoteMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); if (cmbSalesMan.SelectedIndex != -1) { infoDeliveryNoteMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { infoDeliveryNoteMaster.EmployeeId = 0; } infoDeliveryNoteMaster.Narration = txtNarration.Text; infoDeliveryNoteMaster.TotalAmount = Convert.ToDecimal(txtTotalAmnt.Text); infoDeliveryNoteMaster.UserId = PublicVariables._decCurrentUserId; infoDeliveryNoteMaster.LrNo = txtLRNo.Text; infoDeliveryNoteMaster.TransportationCompany = txtTraspotationCompany.Text; infoDeliveryNoteMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoDeliveryNoteMaster.Extra1 = string.Empty; infoDeliveryNoteMaster.Extra2 = string.Empty; infoDeliveryNoteMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); if (decDelivryNoteIdToEdit == 0) { decDeliveryNoteMasterId = Convert.ToDecimal(spDeliveryNoteMaster.DeliveryNoteMasterAdd(infoDeliveryNoteMaster)); } int inRowcount = dgvProduct.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value == null) { if (cmbDeliveryMode.Text == "Against Order") { if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null) { infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else if (cmbDeliveryMode.Text == "Against Quotation") { if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null) { infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else { if (cmbOrderNo.SelectedText != string.Empty) { if (cmbDeliveryMode.Text == "Against Order") { infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } infoDeliveryNoteDetails.ProductId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtProductId"].Value.ToString()); infoDeliveryNoteDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoDeliveryNoteDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); infoDeliveryNoteDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoDeliveryNoteDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); infoDeliveryNoteDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString()); infoDeliveryNoteDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); infoDeliveryNoteDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); infoDeliveryNoteDetails.SlNo = Convert.ToInt32(dgvProduct.Rows[inI].Cells["Col"].Value.ToString()); infoDeliveryNoteDetails.Extra1 = string.Empty; infoDeliveryNoteDetails.Extra2 = string.Empty; if (decDelivryNoteIdToEdit == 0) { infoDeliveryNoteDetails.DeliveryNoteMasterId = decDeliveryNoteMasterId; spDeliveryNoteDetails.DeliveryNoteDetailsAdd(infoDeliveryNoteDetails); } else { infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit; spDeliveryNoteDetails.DeliveryNoteDetailsEdit(infoDeliveryNoteDetails); } infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null) { if (cmbDeliveryMode.SelectedItem.ToString() != "NA") { if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null) { infoStockPosting.VoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value); } else { infoStockPosting.VoucherTypeId = 0; } if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value != null) { infoStockPosting.VoucherNo = dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value.ToString(); } else { infoStockPosting.VoucherNo = string.Empty; } if (dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value != null) { infoStockPosting.InvoiceNo = dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value.ToString(); } else { infoStockPosting.InvoiceNo = string.Empty; } if (decDeliveryNoteVoucherTypeId != 0) { infoStockPosting.AgainstVoucherTypeId = decDeliveryNoteVoucherTypeId; } else { infoStockPosting.AgainstVoucherTypeId = 0; } if (strVoucherNo != string.Empty) { infoStockPosting.AgainstVoucherNo = strVoucherNo; } else { infoStockPosting.AgainstVoucherNo = string.Empty; } if (txtDeliveryNoteNo.Text != string.Empty) { infoStockPosting.AgainstInvoiceNo = txtDeliveryNoteNo.Text; } else { infoStockPosting.AgainstInvoiceNo = string.Empty; } } } else { infoStockPosting.InvoiceNo = txtDeliveryNoteNo.Text; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decDeliveryNoteVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; } infoStockPosting.ProductId = infoDeliveryNoteDetails.ProductId; infoStockPosting.BatchId = infoDeliveryNoteDetails.BatchId; infoStockPosting.UnitId = infoDeliveryNoteDetails.UnitId; infoStockPosting.GodownId = infoDeliveryNoteDetails.GodownId; infoStockPosting.RackId = infoDeliveryNoteDetails.RackId; infoStockPosting.OutwardQty = infoDeliveryNoteDetails.Qty; infoStockPosting.Rate = infoDeliveryNoteDetails.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; spStockPosting.StockPostingAdd(infoStockPosting); } Messages.SavedMessage(); if (cbxPrint.Checked) { SettingsSP spSettings = new SettingsSP(); if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decDeliveryNoteMasterId); } else { Print(decDeliveryNoteMasterId); } } } if (btnSave.Text == "Update") { SettingsSP spSettings = new SettingsSP(); infoDeliveryNoteMaster.DeliveryNoteMasterId = decDelivryNoteIdToEdit; infoDeliveryNoteMaster.SuffixPrefixId = Convert.ToDecimal(decDeliveryNoteSuffixPrefixId); infoDeliveryNoteMaster.VoucherNo = strVoucherNo; infoDeliveryNoteMaster.UserId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid infoDeliveryNoteMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); if (cmbSalesMan.SelectedIndex != -1) { infoDeliveryNoteMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { infoDeliveryNoteMaster.EmployeeId = 0; } infoDeliveryNoteMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; if (cmbOrderNo.SelectedValue != null) { if (cmbDeliveryMode.Text == "Against Order") { infoDeliveryNoteMaster.OrderMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesOrderMaster = spSalesOrderMaster.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesQuotationMaster = spSalesQuotationMaster.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId); } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0; } } else { infoDeliveryNoteMaster.OrderMasterId = 0; infoDeliveryNoteMaster.QuotationMasterId = 0; } infoDeliveryNoteMaster.Narration = txtNarration.Text.Trim(); infoDeliveryNoteMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoDeliveryNoteMaster.TotalAmount = Convert.ToDecimal(txtTotalAmnt.Text); infoDeliveryNoteMaster.TransportationCompany = txtTraspotationCompany.Text; infoDeliveryNoteMaster.LrNo = txtLRNo.Text; infoDeliveryNoteMaster.Extra1 = string.Empty; infoDeliveryNoteMaster.Extra2 = string.Empty; spDeliveryNoteMaster.DeliveryNoteMasterEdit(infoDeliveryNoteMaster); RemoveDeliveryNoteDetails(); infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId; spDeliveryNoteMaster.StockPostDeletingForDeliveryNote(decDeliveryNoteVoucherTypeId, strVoucherNo, txtDeliveryNoteNo.Text); DeliveryNoteDetails(); Messages.UpdatedMessage(); if (frmDeliveryNoteRegisterObj != null) { if (cbxPrint.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decDelivryNoteIdToEdit); } else { Print(decDelivryNoteIdToEdit); } } frmDeliveryNoteRegisterObj.GridFill(); } if (frmDeliveryNoteReportObj != null) { if (cbxPrint.Checked) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decDelivryNoteIdToEdit); } else { Print(decDelivryNoteIdToEdit); } } frmDeliveryNoteReportObj.GridFill(); } this.Close(); } Clear(); } catch (Exception ex) { MessageBox.Show("DN35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save an item into table /// </summary> public void Save() { ExchangeRateSP spExchangeRate = new ExchangeRateSP(); SalesReturnMasterSP spSalesReturnMaster = new SalesReturnMasterSP(); SalesReturnDetailsSP spSalesReturnDetails = new SalesReturnDetailsSP(); StockPostingSP spStockPosting = new StockPostingSP(); LedgerPostingSP spLedgerPosting = new LedgerPostingSP(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); UnitConvertionSP spUnitConvertion = new UnitConvertionSP(); UnitSP spUnit = new UnitSP(); try { if (txtReturnNo.Text.Trim() == string.Empty) { MessageBox.Show("Enter return no", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); txtReturnNo.Focus(); } else if (spSalesReturnMaster.SalesReturnNumberCheckExistence(txtReturnNo.Text.Trim(), 0, decSalesReturnVoucherTypeId) == true && btnSave.Text == "Save") { Messages.InformationMessage("Return number already exist"); txtReturnNo.Focus(); } //else if ((txtReturnNo .Text!=ManualReturnNo)&&(spSalesReturnMaster.SalesReturnNumberCheckExistence(txtReturnNo.Text.Trim(), 0, decSalesReturnVoucherTypeId) == true && btnSave.Text == "Update")) //{ // Messages.InformationMessage("Return number already exist"); // txtReturnNo.Focus(); //} else if (txtDate.Text == "") { MessageBox.Show("Select a date in between financial year", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); txtDate.Focus(); } else if (cmbCashOrParty.SelectedValue == null) { MessageBox.Show("Select cash/party", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbCashOrParty.Focus(); } else if (cmbSalesAccount.SelectedValue == null) { MessageBox.Show("Select sales account", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbSalesAccount.Focus(); } else if (cmbCurrency.SelectedValue == null) { MessageBox.Show("Select currency", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); cmbCurrency.Focus(); } else { if (isAutomatic) { if (strVoucherNo != string.Empty) { infoSalesReturnMaster.VoucherNo = strVoucherNo; } if (txtReturnNo.Text != string.Empty) { infoSalesReturnMaster.InvoiceNo = txtReturnNo.Text; } } else { infoSalesReturnMaster.VoucherNo = txtReturnNo.Text; infoSalesReturnMaster.InvoiceNo = txtReturnNo.Text; } if (decSalesReturnVoucherTypeId != 0) { infoSalesReturnMaster.VoucherTypeId = decSalesReturnVoucherTypeId; } if (decSalesReturnSuffixPrefixId != 0) { infoSalesReturnMaster.SuffixPrefixId = decSalesReturnSuffixPrefixId; } if (cmbCashOrParty.SelectedValue != null) { infoSalesReturnMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); } if (cmbInvoiceNo.SelectedValue != null) { infoSalesReturnMaster.SalesMasterId = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString()); } else { infoSalesReturnMaster.SalesMasterId = 0; } if (cmbSalesAccount.SelectedValue != null) { infoSalesReturnMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); } if (cmbPricingLevel.SelectedValue != null) { infoSalesReturnMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } else { infoSalesReturnMaster.PricinglevelId = 0; } if (cmbSalesMan.SelectedValue != null) { infoSalesReturnMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { infoSalesReturnMaster.EmployeeId = 0; } if (cmbCurrency.SelectedValue != null) { infoSalesReturnMaster.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); decExchangeRate = spExchangeRate.ExchangeRateViewByExchangeRateId(infoSalesReturnMaster.ExchangeRateId); } infoSalesReturnMaster.Narration = txtNarration.Text.Trim(); infoSalesReturnMaster.UserId = PublicVariables._decCurrentUserId; infoSalesReturnMaster.LrNo = txtLRNo.Text.Trim(); infoSalesReturnMaster.TransportationCompany = txtTransportationComp.Text.Trim(); infoSalesReturnMaster.Date = Convert.ToDateTime(txtDate.Text); if (txtTotalAmount.Text != string.Empty) { infoSalesReturnMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); } if (txtGrandTotal.Text != string.Empty) { infoSalesReturnMaster.grandTotal = Convert.ToDecimal(txtGrandTotal.Text); } if (lblTaxAmount.Text != string.Empty) { infoSalesReturnMaster.TaxAmount = Convert.ToDecimal(lblTaxAmount.Text); } infoSalesReturnMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoSalesReturnMaster.Extra1 = string.Empty; infoSalesReturnMaster.Extra2 = string.Empty; if (txtBillDiscount.Text != string.Empty) { infoSalesReturnMaster.Discount = Convert.ToDecimal(txtBillDiscount.Text); } else { infoSalesReturnMaster.Discount = 0; } decimal decNetTotal = 0; decimal decGrandTotal = 0; string strQuantities = string.Empty; if (btnSave.Text == "Update") { infoSalesReturnMaster.SalesReturnMasterId = decSalesReturnMasterId; spSalesReturnMaster.SalesReturnMasterEdit(infoSalesReturnMaster); spLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decSalesReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text); spLedgerPosting.LedgerPostingAndPartyBalanceDeleteByVoucherTypeIdAndLedgerIdAndVoucherNo(decSalesReturnVoucherTypeId, strVoucherNo, txtReturnNo.Text); spStockPosting.StockPostingDeleteByVoucherTypeAndVoucherNo(strVoucherNo, decSalesReturnVoucherTypeId); spSalesReturnBillTax.SalesReturnBillTaxDeleteBySalesReturnMasterId(decSalesReturnMasterId); } else { decSalesReturnMasterId = spSalesReturnMaster.SalesReturnMasterAdd(infoSalesReturnMaster); } SalesReturnDetailsInfo infoSalesReturnDetailsInfo = new SalesReturnDetailsInfo(); infoSalesReturnDetailsInfo.Extra1 = string.Empty; infoSalesReturnDetailsInfo.Extra2 = string.Empty; if (btnSave.Text == "Update") { foreach (var strId in lstArrOfRemove) { decimal decDeleteId = Convert.ToDecimal(strId); spSalesReturnDetails.SalesReturnDetailsDelete(decDeleteId); } } foreach (DataGridViewRow DGVSalesReturn in dgvSalesReturn.Rows) { if (DGVSalesReturn.Cells["productId"].Value != null && DGVSalesReturn.Cells["productId"].Value.ToString() != string.Empty) { infoSalesReturnDetailsInfo.SalesReturnMasterId = decSalesReturnMasterId; infoSalesReturnDetailsInfo.ProductId = Convert.ToDecimal(DGVSalesReturn.Cells["productId"].Value.ToString()); if (DGVSalesReturn.Cells["dgvTextQty"].Value != null) { infoSalesReturnDetailsInfo.Qty = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextQty"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextRate"].Value != null) { infoSalesReturnDetailsInfo.Rate = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextRate"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvCmbUnit"].Value != null) { infoSalesReturnDetailsInfo.UnitId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbUnit"].Value.ToString()); } if (DGVSalesReturn.Cells["unitConversionId"].Value != null) { infoSalesReturnDetailsInfo.UnitConversionId = Convert.ToDecimal(DGVSalesReturn.Cells["unitConversionId"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextDiscountAmount"].Value != null) { infoSalesReturnDetailsInfo.Discount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextDiscountAmount"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvCmbTax"].Value != null) { infoSalesReturnDetailsInfo.TaxId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbTax"].Value.ToString()); } else { infoSalesReturnDetailsInfo.TaxId = 0; } if (DGVSalesReturn.Cells["dgvCmbBatch"].Value != null) { infoSalesReturnDetailsInfo.BatchId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbBatch"].Value.ToString()); } else { infoSalesReturnDetailsInfo.BatchId = 0; } if (DGVSalesReturn.Cells["dgvCmbBatch"].Value != null) { infoSalesReturnDetailsInfo.BatchId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbBatch"].Value.ToString()); } else { infoSalesReturnDetailsInfo.BatchId = 0; } if (DGVSalesReturn.Cells["dgvCmbGodown"].Value != null) { infoSalesReturnDetailsInfo.GodownId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbGodown"].Value.ToString()); } else { infoSalesReturnDetailsInfo.GodownId = 0; } if (DGVSalesReturn.Cells["dgvCmbRack"].Value != null) { infoSalesReturnDetailsInfo.RackId = Convert.ToDecimal(DGVSalesReturn.Cells["dgvCmbRack"].Value.ToString()); } else { infoSalesReturnDetailsInfo.RackId = 0; } if (DGVSalesReturn.Cells["dgvTextTaxAmount"].Value != null) { infoSalesReturnDetailsInfo.TaxAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextTaxAmount"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextGrossValue"].Value != null) { infoSalesReturnDetailsInfo.GrossAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextGrossValue"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextNetValue"].Value != null) { infoSalesReturnDetailsInfo.NetAmount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextNetValue"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvTextAmount1"].Value != null) { infoSalesReturnDetailsInfo.Amount = Convert.ToDecimal(DGVSalesReturn.Cells["dgvTextAmount1"].Value.ToString()); } if (DGVSalesReturn.Cells["dgvSNo"].Value != null) { infoSalesReturnDetailsInfo.SlNo = Convert.ToInt32(DGVSalesReturn.Cells["dgvSNo"].Value.ToString()); } if (DGVSalesReturn.Cells["salesDetailsId"].Value != null && cmbInvoiceNo.SelectedValue != null) { infoSalesReturnDetailsInfo.SalesDetailsId = Convert.ToDecimal(DGVSalesReturn.Cells["salesDetailsId"].Value.ToString()); } else { infoSalesReturnDetailsInfo.SalesDetailsId = 0; } if (DGVSalesReturn.Cells["salesReturnDetailsId"].Value != null) { infoSalesReturnDetailsInfo.SalesReturnDetailsId = Convert.ToDecimal(DGVSalesReturn.Cells["salesReturnDetailsId"].Value.ToString()); spSalesReturnDetails.SalesReturnDetailsEdit(infoSalesReturnDetailsInfo); } else { decSalesReturnDetailId = spSalesReturnDetails.SalesReturnDetailsAdd(infoSalesReturnDetailsInfo); } StockPostingInfo infoStockPosting = new StockPostingInfo(); infoStockPosting.Date = infoSalesReturnMaster.Date; if (DGVSalesReturn.Cells["voucherTypeId"].Value != null) { infoStockPosting.VoucherTypeId = Convert.ToDecimal(DGVSalesReturn.Cells["voucherTypeId"].Value.ToString()); decAgainstVoucherTypeId = infoStockPosting.VoucherTypeId; infoStockPosting.AgainstVoucherTypeId = decSalesReturnVoucherTypeId; } else { infoStockPosting.VoucherTypeId = decSalesReturnVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; } if (DGVSalesReturn.Cells["voucherNo"].Value != null) { infoStockPosting.VoucherNo = DGVSalesReturn.Cells["voucherNo"].Value.ToString(); strAgainstVoucherNo = infoStockPosting.VoucherNo; infoStockPosting.AgainstVoucherNo = strVoucherNo; } else { infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.AgainstVoucherNo = "NA"; } if (DGVSalesReturn.Cells["invoiceNo"].Value != null) { infoStockPosting.InvoiceNo = DGVSalesReturn.Cells["invoiceNo"].Value.ToString(); strAgainstInvoiceNo = infoStockPosting.InvoiceNo; infoStockPosting.AgainstInvoiceNo = txtReturnNo.Text.Trim(); } else { infoStockPosting.InvoiceNo = txtReturnNo.Text; infoStockPosting.AgainstInvoiceNo = "NA"; } infoStockPosting.ProductId = infoSalesReturnDetailsInfo.ProductId; infoStockPosting.BatchId = infoSalesReturnDetailsInfo.BatchId; infoStockPosting.UnitId = infoSalesReturnDetailsInfo.UnitId; infoStockPosting.GodownId = infoSalesReturnDetailsInfo.GodownId; infoStockPosting.RackId = infoSalesReturnDetailsInfo.RackId; if (infoSalesReturnDetailsInfo.ProductId != 0 && infoSalesReturnDetailsInfo.UnitId != 0) { decimal decUnitConvertionRate = 0; infoProduct = spProduct.ProductView(infoSalesReturnDetailsInfo.ProductId); DataTable dtbl = spUnitConvertion.DGVUnitConvertionRateByUnitId(infoSalesReturnDetailsInfo.UnitId, infoProduct.ProductName); foreach (DataRow drowDetails in dtbl.Rows) { decUnitConvertionRate = Convert.ToDecimal(drowDetails["conversionRate"].ToString()); } strQuantities = spUnit.UnitConversionCheck(infoSalesReturnDetailsInfo.UnitId, infoSalesReturnDetailsInfo.ProductId); if (strQuantities != string.Empty) { infoStockPosting.InwardQty = infoSalesReturnDetailsInfo.Qty / decUnitConvertionRate; } else { infoStockPosting.InwardQty = infoSalesReturnDetailsInfo.Qty; } } infoStockPosting.OutwardQty = 0; infoStockPosting.Rate = infoSalesReturnDetailsInfo.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; spStockPosting.StockPostingAdd(infoStockPosting); } } decGrandTotal = Convert.ToDecimal(txtGrandTotal.Text); decNetTotal = TotalNetAmountForLedgerPosting(); LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); infoLedgerPosting.Date = infoSalesReturnMaster.Date; infoLedgerPosting.ChequeDate = infoSalesReturnMaster.Date; infoLedgerPosting.ChequeNo = String.Empty; infoLedgerPosting.VoucherTypeId = infoSalesReturnMaster.VoucherTypeId; infoLedgerPosting.VoucherNo = infoSalesReturnMaster.VoucherNo; infoLedgerPosting.LedgerId = infoSalesReturnMaster.LedgerId; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = (decGrandTotal * decExchangeRate); infoLedgerPosting.YearId = PublicVariables._decCurrentFinancialYearId; infoLedgerPosting.InvoiceNo = infoSalesReturnMaster.InvoiceNo; infoLedgerPosting.Extra1 = string.Empty; infoLedgerPosting.Extra2 = string.Empty; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); infoLedgerPosting.LedgerId = infoSalesReturnMaster.SalesAccount; infoLedgerPosting.Debit = (decNetTotal * decExchangeRate); infoLedgerPosting.Credit = 0; spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); if (Convert.ToDecimal(txtBillDiscount.Text == string.Empty ? "0" : txtBillDiscount.Text) > 0) { infoLedgerPosting.LedgerId = 8; infoLedgerPosting.Debit = 0; infoLedgerPosting.Credit = (Convert.ToDecimal(txtBillDiscount.Text) * decExchangeRate); spLedgerPosting.LedgerPostingAdd(infoLedgerPosting); } LedegrPostingForTax(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); infoPartyBalance.Date = infoSalesReturnMaster.Date; infoPartyBalance.LedgerId = infoSalesReturnMaster.LedgerId; if (decAgainstVoucherTypeId != 0) { infoPartyBalance.VoucherTypeId = decAgainstVoucherTypeId; infoPartyBalance.VoucherNo = strAgainstVoucherNo; infoPartyBalance.InvoiceNo = strAgainstInvoiceNo; infoPartyBalance.AgainstVoucherTypeId = infoSalesReturnMaster.VoucherTypeId; infoPartyBalance.AgainstVoucherNo = infoSalesReturnMaster.VoucherNo; infoPartyBalance.AgainstInvoiceNo = infoSalesReturnMaster.InvoiceNo; infoPartyBalance.ReferenceType = "Against"; } else { infoPartyBalance.VoucherTypeId = infoSalesReturnMaster.VoucherTypeId; infoPartyBalance.VoucherNo = infoSalesReturnMaster.VoucherNo; infoPartyBalance.InvoiceNo = infoSalesReturnMaster.InvoiceNo; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "NA"; infoPartyBalance.AgainstInvoiceNo = "NA"; infoPartyBalance.ReferenceType = "New"; } infoPartyBalance.Credit = infoSalesReturnMaster.TotalAmount; infoPartyBalance.Debit = 0; infoPartyBalance.CreditPeriod = 0; infoPartyBalance.ExchangeRateId = infoSalesReturnMaster.ExchangeRateId; infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; spPartyBalance.PartyBalanceAdd(infoPartyBalance); SalesReturnBillTaxInfo infoSalesReturnBillTax = new SalesReturnBillTaxInfo(); foreach (DataGridViewRow item in dgvSalesReturn2.Rows) { if (item.Cells["dgvTextTaxId"].Value != null) { infoSalesReturnBillTax.SalesReturnMasterId = decSalesReturnMasterId; infoSalesReturnBillTax.TaxId = Convert.ToDecimal(item.Cells["dgvTextTaxId"].Value.ToString()); infoSalesReturnBillTax.TaxAmount = Convert.ToDecimal(item.Cells["dgvTextAmount"].Value.ToString()); infoSalesReturnBillTax.Extra1 = string.Empty; infoSalesReturnBillTax.Extra2 = string.Empty; spSalesReturnBillTax.SalesReturnBillTaxAdd(infoSalesReturnBillTax); } } if (btnSave.Text == "Save") { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked == true) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesReturnMasterId); } else { Print(decSalesReturnMasterId); } } clear(); } else { Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked == true) { if (spSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesReturnMasterId); } else { Print(decSalesReturnMasterId); } } this.Close(); } } } catch (Exception ex) { MessageBox.Show("SR36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save or edit function /// </summary> public void SaveOrEdit() { SettingsSP spSetting = new SettingsSP(); try { decimal decIdentity = 0; DeliveryNoteMasterSP SpDeliveryNoteMaster = new DeliveryNoteMasterSP(); DeliveryNoteMasterInfo InfoDeliveryNoteMaster = new DeliveryNoteMasterInfo(); InfoDeliveryNoteMaster = SpDeliveryNoteMaster.DeliveryNoteMasterView(Convert.ToDecimal(cmbDeliveryNoteNo.SelectedValue)); RejectionInMasterInfo InfoRejectionInMaster = new RejectionInMasterInfo(); RejectionInDetailsInfo InfoRejectionInDetails = new RejectionInDetailsInfo(); RejectionInDetailsSP SpRejectionInDetails = new RejectionInDetailsSP(); StockPostingInfo InfoStockPosting = new StockPostingInfo(); StockPostingSP SpStockPosting = new StockPostingSP(); if (isAutomatic) { InfoRejectionInMaster.VoucherNo = strVoucherNo; InfoRejectionInMaster.InvoiceNo = txtRejectionInNo.Text; } else { InfoRejectionInMaster.VoucherNo = txtRejectionInNo.Text; InfoRejectionInMaster.InvoiceNo = txtRejectionInNo.Text; } InfoRejectionInMaster.VoucherTypeId = decRejectionInVoucherTypeId; InfoRejectionInMaster.SuffixPrefixId = decRejectionInSuffixPrefixId; InfoRejectionInMaster.Date = DateTime.Parse(txtDate.Text); InfoRejectionInMaster.LedgerId = Convert.ToDecimal(cmbCashorParty.SelectedValue.ToString()); InfoRejectionInMaster.PricinglevelId = cmbPricingLevel.SelectedValue == null ? 0 : Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); InfoRejectionInMaster.EmployeeId = cmbSalesMan.SelectedValue == null ? 1 : Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); InfoRejectionInMaster.Narration = txtNarration.Text.Trim(); InfoRejectionInMaster.ExchangeRateId = cmbCurrency.SelectedValue == null ? 0 : Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); InfoRejectionInMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); InfoRejectionInMaster.UserId = PublicVariables._decCurrentUserId; InfoRejectionInMaster.LrNo = txtLRNo.Text.Trim(); InfoRejectionInMaster.TransportationCompany = txtTransportationCompany.Text.Trim(); InfoRejectionInMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoRejectionInMaster.Extra1 = string.Empty; InfoRejectionInMaster.Extra2 = string.Empty; InfoRejectionInMaster.DeliveryNoteMasterId = Convert.ToDecimal(cmbDeliveryNoteNo.SelectedValue == null ? "" : cmbDeliveryNoteNo.SelectedValue.ToString()); if (decRejectionInIdToEdit == 0) { decIdentity = spRejectionInMaster.RejectionInMasterAdd(InfoRejectionInMaster); } else { InfoRejectionInMaster.RejectionInMasterId = decRejectionInIdToEdit; spRejectionInMaster.RejectionInMasterEdit(InfoRejectionInMaster); } if (decRejectionInIdToEdit == 0) { InfoRejectionInDetails.RejectionInMasterId = decIdentity; } else { SpRejectionInDetails.DeleteRejectionInDetailsByRejectionInMasterId(decRejectionInIdToEdit); SpStockPosting.DeleteStockPostingByAgnstVouTypeIdAndAgnstVouNo(decRejectionInVoucherTypeId, strVoucherNo); InfoRejectionInDetails.RejectionInMasterId = decRejectionInIdToEdit; } foreach (DataGridViewRow dgvrow in dgvProduct.Rows) { InfoRejectionInDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvrow.Cells["dgvtxDeliveryNoteDetailsId"].Value.ToString()); InfoRejectionInDetails.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString()); InfoRejectionInDetails.Qty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString()); InfoRejectionInDetails.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString()); InfoRejectionInDetails.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); InfoRejectionInDetails.UnitConversionId = Convert.ToDecimal(dgvrow.Cells["dgvtxtUnitConversionId"].Value.ToString());//0;//check InfoRejectionInDetails.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString()); InfoRejectionInDetails.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString()); InfoRejectionInDetails.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString()); InfoRejectionInDetails.Amount = Convert.ToDecimal(dgvrow.Cells["dgvtxtAmount"].Value.ToString()); InfoRejectionInDetails.SlNo = Convert.ToInt32(dgvrow.Cells["dgvtxtSlNo"].Value.ToString()); InfoRejectionInDetails.Extra1 = string.Empty; InfoRejectionInDetails.Extra2 = string.Empty; SpRejectionInDetails.RejectionInDetailsAdd(InfoRejectionInDetails); InfoStockPosting.Date = Convert.ToDateTime(txtDate.Text); InfoStockPosting.VoucherTypeId = InfoDeliveryNoteMaster.VoucherTypeId; InfoStockPosting.VoucherNo = InfoDeliveryNoteMaster.VoucherNo; InfoStockPosting.InvoiceNo = InfoDeliveryNoteMaster.InvoiceNo; InfoStockPosting.ProductId = Convert.ToDecimal(dgvrow.Cells["dgvtxtProductId"].Value.ToString()); InfoStockPosting.BatchId = Convert.ToDecimal(dgvrow.Cells["dgvcmbBatch"].Value.ToString()); InfoStockPosting.UnitId = Convert.ToDecimal(dgvrow.Cells["dgvcmbUnit"].Value.ToString()); InfoStockPosting.GodownId = Convert.ToDecimal(dgvrow.Cells["dgvcmbGodown"].Value.ToString()); InfoStockPosting.RackId = Convert.ToDecimal(dgvrow.Cells["dgvcmbRack"].Value.ToString()); InfoStockPosting.AgainstVoucherTypeId = decRejectionInVoucherTypeId; if (isAutomatic) { InfoStockPosting.AgainstInvoiceNo = txtRejectionInNo.Text; InfoStockPosting.AgainstVoucherNo = strVoucherNo; } else { InfoStockPosting.AgainstInvoiceNo = txtRejectionInNo.Text; InfoStockPosting.AgainstVoucherNo = txtRejectionInNo.Text; } InfoStockPosting.InwardQty = Convert.ToDecimal(dgvrow.Cells["dgvtxtQuantity"].Value.ToString()); InfoStockPosting.OutwardQty = 0; InfoStockPosting.Rate = Convert.ToDecimal(dgvrow.Cells["dgvtxtRate"].Value.ToString()); InfoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoStockPosting.Extra1 = string.Empty; InfoStockPosting.Extra2 = string.Empty; SpStockPosting.StockPostingAdd(InfoStockPosting); } if (decRejectionInIdToEdit == 0) { Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (spSetting.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } } else { Messages.UpdatedMessage(); if (cbxPrintAfterSave.Checked) { if (spSetting.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decRejectionInIdToEdit); } else { Print(decRejectionInIdToEdit); } } this.Close(); } } catch (Exception ex) { MessageBox.Show("RI:23" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get particular values from StockPosting Table based on the parameter /// </summary> /// <param name="stockPostingId"></param> /// <returns></returns> public StockPostingInfo StockPostingView(decimal stockPostingId) { StockPostingInfo stockpostinginfo = new StockPostingInfo(); SqlDataReader sdrreader = null; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StockPostingView", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@stockPostingId", SqlDbType.Decimal); sprmparam.Value = stockPostingId; sdrreader = sccmd.ExecuteReader(); while (sdrreader.Read()) { stockpostinginfo.StockPostingId = decimal.Parse(sdrreader[0].ToString()); stockpostinginfo.Date = DateTime.Parse(sdrreader[1].ToString()); stockpostinginfo.VoucherTypeId = decimal.Parse(sdrreader[2].ToString()); stockpostinginfo.VoucherNo = sdrreader[3].ToString(); stockpostinginfo.InvoiceNo = sdrreader[4].ToString(); stockpostinginfo.ProductId = decimal.Parse(sdrreader[5].ToString()); stockpostinginfo.BatchId = decimal.Parse(sdrreader[6].ToString()); stockpostinginfo.UnitId = decimal.Parse(sdrreader[7].ToString()); stockpostinginfo.GodownId = decimal.Parse(sdrreader[8].ToString()); stockpostinginfo.RackId = decimal.Parse(sdrreader[9].ToString()); stockpostinginfo.AgainstVoucherTypeId = decimal.Parse(sdrreader[10].ToString()); stockpostinginfo.AgainstInvoiceNo = sdrreader[11].ToString(); stockpostinginfo.AgainstVoucherNo = sdrreader[12].ToString(); stockpostinginfo.InwardQty = decimal.Parse(sdrreader[13].ToString()); stockpostinginfo.OutwardQty = decimal.Parse(sdrreader[14].ToString()); stockpostinginfo.Rate = decimal.Parse(sdrreader[15].ToString()); stockpostinginfo.FinancialYearId = decimal.Parse(sdrreader[16].ToString()); stockpostinginfo.ExtraDate = DateTime.Parse(sdrreader[17].ToString()); stockpostinginfo.Extra1 = sdrreader[18].ToString(); stockpostinginfo.Extra2 = sdrreader[19].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sdrreader.Close(); sqlcon.Close(); } return stockpostinginfo; }
/// <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 add data to StockTable With Batch /// </summary> public void BatchTableWithStockAndProductBatchFill() { try { BatchSP spBatch = new BatchSP(); BatchInfo infoBatch = new BatchInfo(); StockPostingSP spStockPosting = new StockPostingSP(); StockPostingInfo infoStockPosting = new StockPostingInfo(); for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++) { infoBatch.ManufacturingDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxManfDate"].Value); infoBatch.ExpiryDate = Convert.ToDateTime(dgvProductCreation.Rows[inI].Cells["dgvtxtExpDate"].Value); infoBatch.BatchNo = dgvProductCreation.Rows[inI].Cells["dgvtxtbatch"].Value.ToString(); if (btnSave.Text == "Update") { infoBatch.ProductId = decProductIdForEdit; } else { infoBatch.ProductId = decSaveProduct; } infoBatch.Extra1 = string.Empty; infoBatch.Extra2 = string.Empty; infoBatch.ExtraDate = DateTime.Now; infoBatch.narration = string.Empty; infoBatch.barcode = Convert.ToString(spBatch.AutomaticBarcodeGeneration()); decBatchId = spBatch.BatchAddReturnIdentity(infoBatch); infoStockPosting.AgainstInvoiceNo = string.Empty; infoStockPosting.AgainstVoucherNo = string.Empty; infoStockPosting.Date = PublicVariables._dtCurrentDate; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.InvoiceNo = Convert.ToString(decSaveProduct); infoStockPosting.VoucherNo = Convert.ToString(decSaveProduct); infoStockPosting.VoucherTypeId = 2; infoStockPosting.UnitId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbUnit"].Value); infoStockPosting.InwardQty = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtqty"].Value); infoStockPosting.OutwardQty = 0; infoStockPosting.Rate = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtrate"].Value); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; infoStockPosting.ExtraDate = DateTime.Now; if ((dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Visible) == false) { infoStockPosting.RackId = 1; } else { infoStockPosting.RackId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Value); } if ((dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Visible) == false) { infoStockPosting.GodownId = 1; } else { infoStockPosting.GodownId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Value); } if (btnSave.Text == "Update") { infoStockPosting.ProductId = decProductIdForEdit; } else { infoStockPosting.ProductId = decSaveProduct; } if (cmbAllowBatch.SelectedIndex == 0) { infoStockPosting.BatchId = 0; } else { infoStockPosting.BatchId = decBatchId; } decCheck = spStockPosting.StockPostingAdd(infoStockPosting); } } catch (Exception ex) { MessageBox.Show("PC:18" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Update values in StockPosting Table /// </summary> /// <param name="stockpostinginfo"></param> /// <returns></returns> public bool StockPostingEdit(StockPostingInfo stockpostinginfo) { decimal decresult = 0; try { if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } SqlCommand sccmd = new SqlCommand("StockPostingEdit", sqlcon); sccmd.CommandType = CommandType.StoredProcedure; SqlParameter sprmparam = new SqlParameter(); sprmparam = sccmd.Parameters.Add("@stockPostingId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.StockPostingId; sprmparam = sccmd.Parameters.Add("@date", SqlDbType.DateTime); sprmparam.Value = stockpostinginfo.Date; sprmparam = sccmd.Parameters.Add("@voucherTypeId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.VoucherTypeId; sprmparam = sccmd.Parameters.Add("@voucherNo", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.VoucherNo; sprmparam = sccmd.Parameters.Add("@invoiceNo", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.InvoiceNo; sprmparam = sccmd.Parameters.Add("@productId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.ProductId; sprmparam = sccmd.Parameters.Add("@batchId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.BatchId; sprmparam = sccmd.Parameters.Add("@unitId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.UnitId; sprmparam = sccmd.Parameters.Add("@godownId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.GodownId; sprmparam = sccmd.Parameters.Add("@rackId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.RackId; sprmparam = sccmd.Parameters.Add("@againstVoucherTypeId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.AgainstVoucherTypeId; sprmparam = sccmd.Parameters.Add("@againstInvoiceNo", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.AgainstInvoiceNo; sprmparam = sccmd.Parameters.Add("@againstVoucherNo", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.AgainstVoucherNo; sprmparam = sccmd.Parameters.Add("@inwardQty", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.InwardQty; sprmparam = sccmd.Parameters.Add("@outwardQty", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.OutwardQty; sprmparam = sccmd.Parameters.Add("@rate", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.Rate; sprmparam = sccmd.Parameters.Add("@financialYearId", SqlDbType.Decimal); sprmparam.Value = stockpostinginfo.FinancialYearId; sprmparam = sccmd.Parameters.Add("@extraDate", SqlDbType.DateTime); sprmparam.Value = stockpostinginfo.ExtraDate; sprmparam = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.Extra1; sprmparam = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar); sprmparam.Value = stockpostinginfo.Extra2; decresult = sccmd.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { sqlcon.Close(); } if (decresult > 0) { return(true); } else { return(false); } }
/// <summary> /// Function to save data to StockPosting Table /// </summary> public void StockPostingTableFill() { try { StockPostingSP spStockPosting = new StockPostingSP(); StockPostingInfo infoStockPosting = new StockPostingInfo(); for (int inI = 0; inI < dgvProductCreation.RowCount - 1; inI++) { infoStockPosting.AgainstInvoiceNo = string.Empty; infoStockPosting.AgainstVoucherNo = string.Empty; infoStockPosting.Date = PublicVariables._dtCurrentDate; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.InvoiceNo = Convert.ToString(decSaveProduct); infoStockPosting.VoucherNo = Convert.ToString(decSaveProduct); infoStockPosting.VoucherTypeId = 2; infoStockPosting.UnitId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbUnit"].Value); infoStockPosting.InwardQty = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtqty"].Value); infoStockPosting.OutwardQty = 0; infoStockPosting.Rate = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvtxtrate"].Value); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; infoStockPosting.ExtraDate = DateTime.Now; if ((dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Visible) == false) { infoStockPosting.RackId = 0; } else { infoStockPosting.RackId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbrack"].Value); } if ((dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Visible) == false) { infoStockPosting.GodownId = 1; } else { infoStockPosting.GodownId = Convert.ToDecimal(dgvProductCreation.Rows[inI].Cells["dgvcmbtgodown"].Value); } if (btnSave.Text == "Update") { infoStockPosting.ProductId = decProductIdForEdit; } else { infoStockPosting.ProductId = decSaveProduct; } if (cmbAllowBatch.SelectedIndex == 0) { infoStockPosting.BatchId = inBatchIdWithPartNoNA; } else { infoStockPosting.BatchId = decBatchId; } decCheck = spStockPosting.StockPostingAdd(infoStockPosting); } } catch (Exception ex) { MessageBox.Show("PC:22" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Stock posting add function /// </summary> /// <param name="decProductId"></param> /// <param name="strMaster"></param> public void AddtoStockPosting(decimal decProductId, string strMaster) { try { StockPostingSP spStockPosting = new StockPostingSP(); StockPostingInfo infoStockPosting = new StockPostingInfo(); decimal decCurrentQty = infoPhysicalStockDetails.Qty; decimal decGId = infoPhysicalStockDetails.GodownId; decimal decBId = infoPhysicalStockDetails.BatchId; decimal decRId = infoPhysicalStockDetails.RackId; decimal decOldStock = spStockPosting.ProductGetCurrentStock(decProductId, decGId, decBId, decRId); if (decCurrentQty >= 0) { if (decOldStock >= 0) { decimal decBalance = decCurrentQty - decOldStock; if (decBalance >= 0) { infoStockPosting.InwardQty = decBalance; infoStockPosting.OutwardQty = 0; } else { infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = -decBalance; } } else { infoStockPosting.InwardQty = -decOldStock + decCurrentQty; infoStockPosting.OutwardQty = 0; } } else { if (decOldStock >= 0) { infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = -decCurrentQty + decOldStock; } else { decimal decBalance = -decCurrentQty + decOldStock; if (decBalance >= 0) { infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = decBalance; } else { infoStockPosting.InwardQty = -decBalance; infoStockPosting.OutwardQty = 0; } } } infoStockPosting.VoucherNo = strMaster; infoStockPosting.BatchId = infoPhysicalStockDetails.BatchId; infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; infoStockPosting.GodownId = infoPhysicalStockDetails.GodownId; infoStockPosting.ProductId = decProductId; infoStockPosting.Rate = infoPhysicalStockDetails.Rate; infoStockPosting.UnitId = infoPhysicalStockDetails.UnitId; infoStockPosting.RackId = infoPhysicalStockDetails.RackId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.VoucherTypeId = decPhysicalStockVoucherTypeId; infoStockPosting.InvoiceNo = strMaster; spStockPosting.StockPostingAdd(infoStockPosting); } catch (Exception ex) { MessageBox.Show("PS:21" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to get the Details /// </summary> public void DeliveryNoteDetails() { try { ProductInfo infoProduct = new ProductInfo(); ProductSP spProduct = new ProductSP(); DeliveryNoteDetailsInfo infoDeliveryNoteDetails = new DeliveryNoteDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); StockPostingSP spStockPosting = new StockPostingSP(); DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP(); UnitSP spUnit = new UnitSP(); for (int inI = 0; inI < dgvProduct.Rows.Count - 1; inI++) { if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value == null) { if (cmbDeliveryMode.Text == "Against Order") { if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null) { infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else if (cmbDeliveryMode.Text == "Against Quotation") { if (dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value != null) { infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value == null ? string.Empty : dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else { if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value != null) { if (cmbDeliveryMode.Text == "Against Order") { infoDeliveryNoteDetails.OrderDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteDetails.QuotationDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtOrderDetailsId"].Value.ToString()); } else if (cmbDeliveryMode.Text == "NA") { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } else { infoDeliveryNoteDetails.OrderDetails1Id = 0; infoDeliveryNoteDetails.QuotationDetails1Id = 0; } } if (dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value == null || dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value.ToString() == string.Empty || Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value) == 0) { infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit; infoProduct = spProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoDeliveryNoteDetails.ProductId = infoProduct.ProductId; infoDeliveryNoteDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value); infoDeliveryNoteDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); infoDeliveryNoteDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); infoDeliveryNoteDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString()); infoDeliveryNoteDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); infoDeliveryNoteDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoDeliveryNoteDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoDeliveryNoteDetails.SlNo = Convert.ToInt32(dgvProduct.Rows[inI].Cells["Col"].Value.ToString()); infoDeliveryNoteDetails.Extra1 = string.Empty; infoDeliveryNoteDetails.Extra2 = string.Empty; spDeliveryNoteDetails.DeliveryNoteDetailsAdd(infoDeliveryNoteDetails); } else { infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit; infoDeliveryNoteDetails.DeliveryNoteDetails1Id = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value); infoProduct = spProduct.ProductViewByCode(dgvProduct.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoDeliveryNoteDetails.ProductId = infoProduct.ProductId; infoDeliveryNoteDetails.Qty = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); if (Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtDetailsId"].Value) == 0) { infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].Value.ToString()); } else { infoDeliveryNoteDetails.UnitId = Convert.ToDecimal(spUnit.UnitIdByUnitName(dgvProduct.Rows[inI].Cells["dgvcmbUnit"].FormattedValue.ToString())); } infoDeliveryNoteDetails.BatchId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbBatch"].Value.ToString()); infoDeliveryNoteDetails.GodownId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbGodown"].Value.ToString()); infoDeliveryNoteDetails.RackId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvcmbRack"].Value.ToString()); infoDeliveryNoteDetails.UnitConversionId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); infoDeliveryNoteDetails.Rate = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoDeliveryNoteDetails.Amount = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoDeliveryNoteDetails.SlNo = Convert.ToInt32(dgvProduct.Rows[inI].Cells["Col"].Value.ToString()); spDeliveryNoteDetails.DeliveryNoteDetailsEdit(infoDeliveryNoteDetails); } infoStockPosting.Date = Convert.ToDateTime(txtDate.Text); if (Convert.ToInt32(dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value) != 0) { if (cmbDeliveryMode.SelectedItem.ToString() != "NA") { if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value != null) { infoStockPosting.VoucherTypeId = Convert.ToDecimal(dgvProduct.Rows[inI].Cells["dgvtxtVoucherTypeId"].Value); } else { infoStockPosting.VoucherTypeId = 0; } if (dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value != null) { infoStockPosting.VoucherNo = dgvProduct.Rows[inI].Cells["dgvtxtVoucherNo"].Value.ToString(); } else { infoStockPosting.VoucherNo = string.Empty; } if (dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value != null) { infoStockPosting.InvoiceNo = dgvProduct.Rows[inI].Cells["dgvtxtInvoiceNo"].Value.ToString(); } else { infoStockPosting.InvoiceNo = string.Empty; } if (decDeliveryNoteVoucherTypeId != 0) { infoStockPosting.AgainstVoucherTypeId = decDeliveryNoteVoucherTypeId; } else { infoStockPosting.AgainstVoucherTypeId = 0; } if (strVoucherNo != string.Empty) { infoStockPosting.AgainstVoucherNo = strVoucherNo; } else { infoStockPosting.AgainstVoucherNo = string.Empty; } if (txtDeliveryNoteNo.Text != string.Empty) { infoStockPosting.AgainstInvoiceNo = txtDeliveryNoteNo.Text; } else { infoStockPosting.AgainstInvoiceNo = string.Empty; } } } else { infoStockPosting.InvoiceNo = txtDeliveryNoteNo.Text; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = decDeliveryNoteVoucherTypeId; infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; } infoStockPosting.ProductId = infoDeliveryNoteDetails.ProductId; infoStockPosting.BatchId = infoDeliveryNoteDetails.BatchId; infoStockPosting.UnitId = infoDeliveryNoteDetails.UnitId; infoStockPosting.GodownId = infoDeliveryNoteDetails.GodownId; infoStockPosting.RackId = infoDeliveryNoteDetails.RackId; infoStockPosting.OutwardQty = infoDeliveryNoteDetails.Qty; infoStockPosting.Rate = infoDeliveryNoteDetails.Rate; infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; spStockPosting.StockPostingAdd(infoStockPosting); } } catch (Exception ex) { MessageBox.Show("DN36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <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 SalesInvoiceDetailsEditFill() { SalesMasterSP spSalesMaster = new SalesMasterSP(); SalesDetailsSP spSalesDetails = new SalesDetailsSP(); PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo(); SalesDetailsInfo InfoSalesDetails = new SalesDetailsInfo(); StockPostingInfo infoStockPosting = new StockPostingInfo(); SalesMasterInfo InfoSalesMaster = new SalesMasterInfo(); StockPostingSP spStockPosting = new StockPostingSP(); PartyBalanceSP spPartyBalance = new PartyBalanceSP(); AdditionalCostInfo infoAdditionalCost = new AdditionalCostInfo(); AdditionalCostSP spAdditionalCost = new AdditionalCostSP(); SalesBillTaxSP spSalesBillTax = new SalesBillTaxSP(); SalesBillTaxInfo infoSalesBillTax = new SalesBillTaxInfo(); UnitConvertionSP SPUnitConversion = new UnitConvertionSP(); try { string strAgainstInvoiceN0 = txtInvoiceNo.Text.Trim(); for (int inI = 0; inI < dgvSalesInvoice.Rows.Count - 1; inI++) { decimal decRefStatus = spSalesMaster.SalesInvoiceReferenceCheckForEdit(decSalesInvoiceIdToEdit); if (decRefStatus != 0) { dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductCode"].ReadOnly = true; dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].ReadOnly = true; dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceBarcode"].ReadOnly = true; dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].ReadOnly = true; dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].ReadOnly = true; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value == null || dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() == string.Empty || dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value.ToString() == "0") // here check the row added or editing current row { InfoSalesDetails.SalesMasterId = decSalesInvoiceIdToEdit; InfoSalesDetails.ExtraDate = DateTime.Now; InfoSalesDetails.Extra1 = string.Empty; InfoSalesDetails.Extra2 = string.Empty; if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductName"].Value.ToString() != string.Empty) { if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString() != string.Empty) { if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value != null) { InfoSalesDetails.OrderDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value.ToString()); } else { InfoSalesDetails.OrderDetailsId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { InfoSalesDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()); } else { InfoSalesDetails.DeliveryNoteDetailsId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value != null) { InfoSalesDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value.ToString()); } else { InfoSalesDetails.QuotationDetailsId = 0; } InfoSalesDetails.SlNo = Convert.ToInt32(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSlno"].Value.ToString()); InfoSalesDetails.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); decimal decQty = spSalesMaster.SalesInvoiceQuantityDetailsAgainstSalesReturn(DecSalesInvoiceVoucherTypeId, strVoucherNo); if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()) < decQty) { dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value = 0; decRefStatus = 1; MessageBox.Show("Quantity should be greater than " + decQty, "Open_Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvSalesInvoice.Focus(); } else { InfoSalesDetails.Qty = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()); InfoSalesDetails.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); InfoSalesDetails.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value.ToString()); InfoSalesDetails.Discount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString()); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesDetails.TaxId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString()); InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString()); } else { InfoSalesDetails.TaxId = 0; InfoSalesDetails.TaxAmount = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != string.Empty) { InfoSalesDetails.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); } else { InfoSalesDetails.BatchId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { InfoSalesDetails.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); } else { InfoSalesDetails.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { InfoSalesDetails.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { InfoSalesDetails.RackId = 0; } InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString()); InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString()); InfoSalesDetails.Amount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceAmount"].Value.ToString()); spSalesDetails.SalesDetailsAdd(InfoSalesDetails); } } } } else { InfoSalesDetails.SalesMasterId = decSalesInvoiceIdToEdit; InfoSalesDetails.SalesDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value); InfoSalesDetails.SlNo = Convert.ToInt32(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceSlno"].Value.ToString()); InfoSalesDetails.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); InfoSalesDetails.Qty = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQty"].Value.ToString()); InfoSalesDetails.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value.ToString()); InfoSalesDetails.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); InfoSalesDetails.Discount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value.ToString()); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { InfoSalesDetails.TaxId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceTaxName"].Value.ToString()); InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceTaxAmount"].Value.ToString()); } else { InfoSalesDetails.TaxId = 0; InfoSalesDetails.TaxAmount = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString() != string.Empty) { InfoSalesDetails.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); } else { InfoSalesDetails.BatchId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { InfoSalesDetails.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); RackComboFill(InfoSalesDetails.GodownId, inI, dgvSalesInvoice.Columns["dgvcmbSalesInvoiceRack"].Index); } else { InfoSalesDetails.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { InfoSalesDetails.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { InfoSalesDetails.RackId = 0; } InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceGrossValue"].Value.ToString()); InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceNetAmount"].Value.ToString()); InfoSalesDetails.Amount = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceAmount"].Value.ToString()); InfoSalesDetails.ExtraDate = DateTime.Now; InfoSalesDetails.Extra1 = string.Empty; InfoSalesDetails.Extra2 = string.Empty; if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value != null) { InfoSalesDetails.OrderDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSISalesOrderDetailsId"].Value.ToString()); } else { InfoSalesDetails.OrderDetailsId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { InfoSalesDetails.DeliveryNoteDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()); } else { InfoSalesDetails.DeliveryNoteDetailsId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value != null) { InfoSalesDetails.QuotationDetailsId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value.ToString()); } else { InfoSalesDetails.QuotationDetailsId = 0; } spSalesDetails.SalesDetailsEdit(InfoSalesDetails); } infoStockPosting.Date = Convert.ToDateTime(txtDate.Text.Trim().ToString()); infoStockPosting.ProductId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceProductId"].Value.ToString()); infoStockPosting.BatchId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceBatch"].Value.ToString()); infoStockPosting.UnitId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoicembUnitName"].Value.ToString()); if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString() != string.Empty) { infoStockPosting.GodownId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()); } else { infoStockPosting.GodownId = 0; } if (dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value != null && dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString() != string.Empty) { infoStockPosting.RackId = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvcmbSalesInvoiceRack"].Value.ToString()); } else { infoStockPosting.RackId = 0; } if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value) == 0) { decimal decResult = spStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote(0, "NA", strVoucherNo, DecSalesInvoiceVoucherTypeId); } else { decimal decResult = spStockPosting.StockPostingDeleteForSalesInvoiceAgainstDeliveryNote(DecSalesInvoiceVoucherTypeId, strVoucherNo, strVoucherNoTostockPost, decVouchertypeIdTostockPost); } infoStockPosting.Rate = Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceRate"].Value.ToString()); infoStockPosting.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoStockPosting.ExtraDate = DateTime.Now; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; if (dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value != null) { if (Convert.ToDecimal(dgvSalesInvoice.Rows[inI].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value.ToString()) != 0) { infoStockPosting.InwardQty = InfoSalesDetails.Qty / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.OutwardQty = 0; infoStockPosting.VoucherNo = strVoucherNoTostockPost; infoStockPosting.AgainstVoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = strInvoiceNoTostockPost; infoStockPosting.AgainstInvoiceNo = strAgainstInvoiceN0; infoStockPosting.VoucherTypeId = decVouchertypeIdTostockPost; infoStockPosting.AgainstVoucherTypeId = DecSalesInvoiceVoucherTypeId; spStockPosting.StockPostingAdd(infoStockPosting); } } infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = InfoSalesDetails.Qty / SPUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoStockPosting.InvoiceNo = strAgainstInvoiceN0; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstVoucherTypeId = 0; spStockPosting.StockPostingAdd(infoStockPosting); } int inAddRowCount = dgvSalesInvoiceLedger.RowCount; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; if (isAutomatic) { infoAdditionalCost.VoucherNo = strVoucherNo; } else { infoAdditionalCost.VoucherNo = txtInvoiceNo.Text; } infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; for (int inIAdc = 0; inIAdc < inAddRowCount; inIAdc++) { if (dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvCmbAdditionalCostledgerName"].Value != null && dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString() != string.Empty) { if (dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCoastledgerAmount"].Value != null && dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString() != string.Empty) { infoAdditionalCost.LedgerId = Convert.ToInt32(dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvCmbAdditionalCostledgerName"].Value.ToString()); if (cmbDrorCr.SelectedItem.ToString() != "Dr") { infoAdditionalCost.Debit = 0; infoAdditionalCost.Credit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); } else { infoAdditionalCost.Debit = Convert.ToDecimal(dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCoastledgerAmount"].Value.ToString()); infoAdditionalCost.Credit = 0; } if (dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCostId"].Value != null && dgvSalesInvoiceLedger.Rows[inIAdc].Cells["dgvtxtAdditionalCostId"].Value.ToString() != string.Empty) { spAdditionalCost.AdditionalCostEditByVoucherTypeIdAndVoucherNo(infoAdditionalCost); } else { spAdditionalCost.AdditionalCostAdd(infoAdditionalCost); } } } } if (cmbDrorCr.SelectedItem.ToString() != "Dr") // here we are debit the cash or bank { decimal decCAshOrPartyId = 0; decCAshOrPartyId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString()); infoAdditionalCost.Debit = decTotalAddAmount; infoAdditionalCost.Credit = 0; infoAdditionalCost.LedgerId = decCAshOrPartyId; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; spAdditionalCost.AdditionalCostEditByVoucherTypeIdAndVoucherNo(infoAdditionalCost); } else { decimal decCAshOrBankId = 0; // here we are credit the cash or bank decCAshOrBankId = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString()); decimal decTotalAddAmount = Convert.ToDecimal(lblLedgerTotalAmount.Text.Trim().ToString()); infoAdditionalCost.Debit = 0; infoAdditionalCost.Credit = decTotalAddAmount; infoAdditionalCost.LedgerId = decCAshOrBankId; infoAdditionalCost.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoAdditionalCost.VoucherNo = strVoucherNo; infoAdditionalCost.ExtraDate = DateTime.Now; infoAdditionalCost.Extra1 = string.Empty; infoAdditionalCost.Extra2 = string.Empty; spAdditionalCost.AdditionalCostEditByVoucherTypeIdAndVoucherNo(infoAdditionalCost); } removeSalesInvoiceAdditionalDetails(); if (dgvSalesInvoice.Columns["dgvcmbSalesInvoiceTaxName"].Visible) { int inTaxRowCount = dgvSalesInvoiceTax.RowCount; infoSalesBillTax.SalesMasterId = decSalesInvoiceIdToEdit; infoSalesBillTax.ExtraDate = DateTime.Now; infoSalesBillTax.Extra1 = string.Empty; infoSalesBillTax.Extra2 = string.Empty; for (int inTax = 0; inTax < inTaxRowCount; inTax++) { if (dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxId"].Value != null && dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty) { if (dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxAmount"].Value != null && dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxAmount"].Value.ToString() != string.Empty) { decimal decAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxAmount"].Value); if (decAmount > 0) { infoSalesBillTax.TaxId = Convert.ToInt32(dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxId"].Value.ToString()); infoSalesBillTax.TaxAmount = Convert.ToDecimal(dgvSalesInvoiceTax.Rows[inTax].Cells["dgvtxtTtaxAmount"].Value.ToString()); spSalesBillTax.SalesBillTaxEditBySalesMasterIdAndTaxId(infoSalesBillTax); } } } } } if (spSalesMaster.SalesInvoiceInvoicePartyCheckEnableBillByBillOrNot(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()))) { infoPartyBalance.Date = Convert.ToDateTime(txtDate.Text.ToString()); infoPartyBalance.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPartyBalance.VoucherNo = strVoucherNo; infoPartyBalance.InvoiceNo = txtInvoiceNo.Text.Trim(); infoPartyBalance.VoucherTypeId = DecSalesInvoiceVoucherTypeId; infoPartyBalance.AgainstVoucherTypeId = 0; infoPartyBalance.AgainstVoucherNo = "0"; infoPartyBalance.AgainstInvoiceNo = "0"; infoPartyBalance.ReferenceType = "New"; infoPartyBalance.Debit = Convert.ToDecimal(txtGrandTotal.Text.Trim().ToString()); decimal decBalAmount = spSalesDetails.SalesInvoiceReciptVoucherDetailsAgainstSI(DecSalesInvoiceVoucherTypeId, strVoucherNo); decimal decCurrentAmount = Convert.ToDecimal(txtGrandTotal.Text.ToString()); if (decCurrentAmount < decBalAmount) { MessageBox.Show("Amount should be greater than " + decBalAmount, "Open_Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); dgvSalesInvoice.Focus(); } else { infoPartyBalance.Credit = 0; infoPartyBalance.CreditPeriod = Convert.ToInt32(txtCreditPeriod.Text.ToString()); infoPartyBalance.ExchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue); infoPartyBalance.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPartyBalance.ExtraDate = DateTime.Now; infoPartyBalance.Extra1 = string.Empty; infoPartyBalance.Extra2 = string.Empty; spPartyBalance.PartyBalanceEditByVoucherNoVoucherTypeIdAndReferenceType(infoPartyBalance); } } } catch (Exception ex) { MessageBox.Show("SI: 81" + 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); } }