/// <summary> /// Function to check the status of AutomaticProductCode generation /// </summary> /// <returns></returns> public bool AutomaticProductCode() { bool isAuto = false; try { SettingsBll BllSettings = new SettingsBll(); isAuto = BllSettings.AutomaticProductCodeGeneration(); } catch (Exception ex) { MessageBox.Show("MPC16:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isAuto; }
/// <summary> /// Function to return amount in words /// </summary> /// <param name="decAmount"></param> /// <param name="decCurrId"></param> /// <returns></returns> public string AmountWords(decimal decAmount, decimal decCurrId) { string AountInWords = string.Empty; // To return the amount in words CurrencyInfo currencyInfo = new CurrencyBll().CurrencyView(decCurrId); decAmount = Math.Round(decAmount, currencyInfo.NoOfDecimalPlaces); //Rounding according to decimal places of currency string strAmount = decAmount.ToString(); // Just keeping the whole amount as string for performing split operation on it string strAmountinwordsOfIntiger = string.Empty; // To hold amount in words of intiger string strAmountInWordsOfDecimal = string.Empty; // To hold amoutn in words of decimal part string[] strPartsArray = strAmount.Split('.'); // Splitting with "." to get intiger part and decimal part seperately string strDecimaPart = string.Empty; // To hold decimal part if (strPartsArray.Length > 1) if (strPartsArray[1] != null) strDecimaPart = strPartsArray[1]; // Holding decimal portion if any if (strPartsArray[0] != null) strAmount = strPartsArray[0]; // Holding intiger part of amount else strAmount = string.Empty; ; if (strAmount.Trim() != string.Empty && decimal.Parse(strAmount) != 0) strAmountinwordsOfIntiger = NumberToText(long.Parse(strAmount)); if (strDecimaPart.Trim() != string.Empty && decimal.Parse(strDecimaPart) != 0) strAmountInWordsOfDecimal = NumberToText(long.Parse(strDecimaPart)); SettingsBll BllSetting = new SettingsBll(); if (BllSetting.SettingsStatusCheck("ShowCurrencySymbol") != "Yes") { // Showing currency as suffix if (strAmountinwordsOfIntiger != string.Empty) AountInWords = strAmountinwordsOfIntiger + " " + currencyInfo.CurrencyName; if (strAmountInWordsOfDecimal != string.Empty) AountInWords = AountInWords + " and " + strAmountInWordsOfDecimal + " " + currencyInfo.SubunitName; AountInWords = AountInWords + " only"; } else { // Showing currency as prefix if (strAmountinwordsOfIntiger != string.Empty) AountInWords = currencyInfo.CurrencyName + " " + strAmountinwordsOfIntiger; if (strAmountInWordsOfDecimal != string.Empty) AountInWords = AountInWords + " and " + currencyInfo.SubunitName + " " + strAmountInWordsOfDecimal; AountInWords = AountInWords + " only"; } return AountInWords; }
/// <summary> /// On value change of dtpVoucherDate /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dtpVoucherDate_ValueChanged(object sender, EventArgs e) { try { SettingsBll BllSettings = new SettingsBll(); DateTime date = this.dtpVoucherDate.Value; txtVoucherDate.Text = date.ToString("dd-MMM-yyyy"); txtVoucherDate.Focus(); CurrencyComboFill(); if (BllSettings.SettingsStatusCheck("MultiCurrency") == "Yes") { cmbCurrency.Enabled = true; } else { cmbCurrency.Enabled = false; } } catch (Exception ex) { MessageBox.Show("SV 53 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// CurrencyComboFill /// </summary> public void CurrencyComboFill() { bool IsTrue = false; TransactionsGeneralFillBll TransactionGenerateFillObj = new TransactionsGeneralFillBll(); try { IsTrue = true; List<DataTable> listObj = new List<DataTable>(); CurrencyBll BllCurrency = new CurrencyBll(); SettingsBll BllSettings = new SettingsBll(); listObj = TransactionGenerateFillObj.CurrencyComboByDate(dtpDate.Value); cmbCurrency.DataSource = listObj[0]; cmbCurrency.DisplayMember = "currencyName"; cmbCurrency.ValueMember = "exchangeRateId"; cmbCurrency.SelectedValue = 1m; if (BllSettings.SettingsStatusCheck("MultiCurrency") == "Yes") { cmbCurrency.Enabled = true; } else { cmbCurrency.Enabled = false; } IsTrue = false; } catch (Exception ex) { MessageBox.Show("DN32:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// When Form Loads /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmDeliveryNote_Load(object sender, EventArgs e) { try { Clear(); PrintCheck(); FillProducts(false, null); SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("ShowProductCode") == "Yes") { dgvProduct.Columns["dgvtxtProductCode"].Visible = true; } else { dgvProduct.Columns["dgvtxtProductCode"].Visible = false; } if (BllSettings.SettingsStatusCheck("barcode") == "Yes") { dgvProduct.Columns["dgvtxtBarcode"].Visible = true; } else { dgvProduct.Columns["dgvtxtBarcode"].Visible = false; } if (BllSettings.SettingsStatusCheck("ShowUnit") == "Yes") { dgvProduct.Columns["dgvcmbUnit"].Visible = true; } else { dgvProduct.Columns["dgvcmbUnit"].Visible = false; } if (BllSettings.SettingsStatusCheck("AllowGodown") == "Yes") { dgvProduct.Columns["dgvcmbGodown"].Visible = true; dgvProduct.Columns["dgvcmbRack"].Visible = true; } else { dgvProduct.Columns["dgvcmbGodown"].Visible = false; dgvProduct.Columns["dgvcmbRack"].Visible = false; } if (BllSettings.SettingsStatusCheck("AllowRack") == "Yes") { if (BllSettings.SettingsStatusCheck("AllowGodown") == "Yes") dgvProduct.Columns["dgvcmbRack"].Visible = true; else dgvProduct.Columns["dgvcmbRack"].Visible = false; } else { dgvProduct.Columns["dgvcmbRack"].Visible = false; } if (BllSettings.SettingsStatusCheck("AllowBatch") == "Yes") { dgvProduct.Columns["dgvcmbBatch"].Visible = true; } else { dgvProduct.Columns["dgvcmbBatch"].Visible = false; } } catch (Exception ex) { MessageBox.Show("DN51:" + 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(); StockPostingBll BllStockPosting = new StockPostingBll(); // StockPostingSP spStockPosting = new StockPostingSP(); //DeliveryNoteMasterSP spDeliveryNoteMaster = new DeliveryNoteMasterSP(); //DeliveryNoteDetailsSP spDeliveryNoteDetails = new DeliveryNoteDetailsSP(); DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll(); SalesOrderMasterInfo infoSalesOrderMaster = new SalesOrderMasterInfo(); SalesOrderBll bllSalesOrder = new SalesOrderBll(); SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo(); SalesQuotationBll bllSalesQuotation = new SalesQuotationBll(); 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 = bllSalesOrder.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesQuotationMaster = bllSalesQuotation.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(bllDeliveryNote.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; bllDeliveryNote.DeliveryNoteDetailsAdd(infoDeliveryNoteDetails); } else { infoDeliveryNoteDetails.DeliveryNoteMasterId = decDelivryNoteIdToEdit; bllDeliveryNote.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; BllStockPosting.StockPostingAdd(infoStockPosting); } Messages.SavedMessage(); if (cbxPrint.Checked) { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decDeliveryNoteMasterId); } else { Print(decDeliveryNoteMasterId); } } } if (btnSave.Text == "Update") { SettingsBll BllSettings = new SettingsBll(); 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 = bllSalesOrder.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId); } else if (cmbDeliveryMode.Text == "Against Quotation") { infoDeliveryNoteMaster.QuotationMasterId = Convert.ToDecimal(cmbOrderNo.SelectedValue.ToString()); infoSalesQuotationMaster = bllSalesQuotation.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; bllDeliveryNote.DeliveryNoteMasterEdit(infoDeliveryNoteMaster); RemoveDeliveryNoteDetails(); infoDeliveryNoteMaster.VoucherTypeId = decDeliveryNoteVoucherTypeId; bllDeliveryNote.StockPostDeletingForDeliveryNote(decDeliveryNoteVoucherTypeId, strVoucherNo, txtDeliveryNoteNo.Text); DeliveryNoteDetails(); Messages.UpdatedMessage(); if (frmDeliveryNoteRegisterObj != null) { if (cbxPrint.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decDelivryNoteIdToEdit); } else { Print(decDelivryNoteIdToEdit); } } frmDeliveryNoteRegisterObj.GridFill(); } if (frmDeliveryNoteReportObj != null) { if (cbxPrint.Checked) { if (BllSettings.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 fill Datagridview after calculation /// </summary> public void GridFill() { try { if (!isFormLoad) { string calculationMethod = string.Empty; SettingsInfo InfoSettings = new SettingsInfo(); SettingsBll BllSettings = new SettingsBll(); //--------------- Selection Of Calculation Method According To Settings ------------------// if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO") { calculationMethod = "FIFO"; } else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost") { calculationMethod = "Average Cost"; } else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost") { calculationMethod = "High Cost"; } else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost") { calculationMethod = "Low Cost"; } else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate") { calculationMethod = "Last Purchase Rate"; } FinancialStatementBll bllFinancialStatement = new FinancialStatementBll(); DataTable dtbl1 = new DataTable(); CurrencyInfo InfoCurrency = new CurrencyInfo(); CurrencyBll BllCurrency = new CurrencyBll(); int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces; decimal dcClosingStock = bllFinancialStatement.StockValueGetOnDate(Convert.ToDateTime(txtTodate.Text), calculationMethod, false, false); dcClosingStock = Math.Round(dcClosingStock, inDecimalPlaces); //---------------------Opening Stock----------------------- decimal dcOpeninggStock = bllFinancialStatement.StockValueGetOnDate(PublicVariables._dtFromDate, calculationMethod, true, true); decimal dcProfit = 0; DataSet dsetProfitAndLoss = new DataSet(); dsetProfitAndLoss = bllFinancialStatement.ProfitAndLossAnalysisUpToaDateForBalansheet(PublicVariables._dtFromDate, DateTime.Parse(txtTodate.Text)); DataTable dtblProfit = new DataTable(); dtblProfit = dsetProfitAndLoss.Tables[0]; for (int i = 0; i < dsetProfitAndLoss.Tables.Count; ++i) { dtbl1 = dsetProfitAndLoss.Tables[i]; decimal dcSum = 0; if (i == 0 || (i % 2) == 0) { if (dtbl1.Rows.Count > 0) { dcSum = decimal.Parse(dtbl1.Compute("Sum(Debit)", string.Empty).ToString()); } } else { if (dtbl1.Rows.Count > 0) { dcSum = decimal.Parse(dtbl1.Compute("Sum(Credit)", string.Empty).ToString()); } } } DateValidation objValidation = new DateValidation(); objValidation.DateValidationFunction(txtTodate); if (txtTodate.Text == string.Empty) txtTodate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); Font newFont = new Font(dgvTrailBalance.Font, FontStyle.Bold); DataSet DsetTrailbalance = new DataSet(); DataTable dtbl = new DataTable(); decimal dcTotalCredit = 0; decimal dcTotalDebit = 0; DateValidation objvalidation = new DateValidation(); objvalidation.DateValidationFunction(txtFromDate); if (txtFromDate.Text == string.Empty) { txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy"); } objvalidation.DateValidationFunction(txtTodate); if (txtTodate.Text == string.Empty) { txtTodate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); } DataTable dtblTrail = new DataTable(); DataTable dtblTrail1 = new DataTable(); DataTable dtblProfitAndLossAcc = new DataTable(); DataTable dtblProfitAndLossAcc1 = new DataTable(); DataSet dsTrial = new DataSet(); Font newfont = new Font(dgvTrailBalance.Font, FontStyle.Bold); dgvTrailBalance.Rows.Clear(); dsTrial = bllFinancialStatement.TrialBalance(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtTodate.Text), 0); dtblTrail = dsTrial.Tables[0]; dtblProfitAndLossAcc = dsTrial.Tables[1]; if (dgvTrailBalance.RowCount > 0) { dcTotalCredit = decimal.Parse(dtblTrail.Compute("Sum(credit)", string.Empty).ToString()); dcTotalDebit = decimal.Parse(dtblTrail.Compute("Sum(debit)", string.Empty).ToString()); } for (int i = 0; i < dtblTrail.Rows.Count; ++i) { dgvTrailBalance.Rows.Add(); if (Convert.ToDecimal(dtblTrail.Rows[i]["accountGroupId"].ToString()) != 6) { dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = dtblTrail.Rows[i]["accountGroupId"]; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = dtblTrail.Rows[i]["name"]; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = dtblTrail.Rows[i]["OpeningBalance"]; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = dtblTrail.Rows[i]["Balance"]; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblTrail.Rows[i]["credit"]; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblTrail.Rows[i]["debit"]; dcTotalCredit += decimal.Parse(dtblTrail.Rows[i]["credit"].ToString()); dcTotalDebit += decimal.Parse(dtblTrail.Rows[i]["debit"].ToString()); } else { decimal decOpBalance = dcOpeninggStock + Convert.ToDecimal(dtblTrail.Rows[i]["OpBalance"].ToString()); decimal decBalance = dcOpeninggStock + Convert.ToDecimal(dtblTrail.Rows[i]["Balance1"].ToString()); string strOpBalance = string.Empty; string strBalance = string.Empty; if (decOpBalance < 0) { strOpBalance = Math.Round(decOpBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Cr"; } else { strOpBalance = Math.Round(decOpBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Dr"; } if (decBalance < 0) { strBalance = Math.Round(decBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Cr"; } else { strBalance = Math.Round(decBalance, PublicVariables._inNoOfDecimalPlaces).ToString() + "Dr"; } dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = dtblTrail.Rows[i]["accountGroupId"]; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = dtblTrail.Rows[i]["name"]; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = strOpBalance; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = strBalance; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblTrail.Rows[i]["credit"]; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblTrail.Rows[i]["debit"]; dcTotalCredit += decimal.Parse(dtblTrail.Rows[i]["credit"].ToString()); dcTotalDebit += decimal.Parse(dtblTrail.Rows[i]["debit"].ToString()); } } decimal OpeningProfit; dtblProfitAndLossAcc1 = dsTrial.Tables[2]; if (dgvTrailBalance.RowCount > 0) { decimal dcTotalCredit1 = decimal.Parse(dtblTrail.Compute("Sum(credit)", string.Empty).ToString()); decimal dcTotalDebit1 = decimal.Parse(dtblTrail.Compute("Sum(debit)", string.Empty).ToString()); OpeningProfit = dcTotalCredit1 + dcTotalDebit1; } DataSet DsetBalanceSheet = new DataSet(); DsetBalanceSheet = bllFinancialStatement.BalanceSheet(PublicVariables._dtFromDate, DateTime.Parse(txtTodate.Text)); DataTable dtblProf = new DataTable(); decimal dcProfitOpening = 0; dtblProf = DsetBalanceSheet.Tables[2]; decimal decProfitLedger = 0; if (dtblProf.Rows.Count > 0) { decProfitLedger = decimal.Parse(dtblProf.Compute("Sum(Balance)", string.Empty).ToString()); } DataTable dtblProfitLedgerOpening = new DataTable(); dtblProfitLedgerOpening = DsetBalanceSheet.Tables[3]; decimal decProfitLedgerOpening = 0; foreach (DataRow dRow in dtblProfitLedgerOpening.Rows) { decProfitLedgerOpening += decimal.Parse(dRow["Balance"].ToString()); } decimal decTotalProfitAndLoss = decProfitLedger; decimal OpeningProfit1; decimal openingBalance; dgvTrailBalance.Rows.Add(); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = " "; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Profit and Loss"; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = "0"; openingBalance = Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["OpeningBalance"].ToString()); { if (openingBalance > 0) { dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = openingBalance + "Dr"; } else dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = (-1) * openingBalance + "Cr"; } dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = dgvTrailBalance.Rows.Count.ToString(); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Blue; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Regular); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dtblProfitAndLossAcc.Rows[0]["credit"].ToString(); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dtblProfitAndLossAcc.Rows[0]["debit"].ToString(); OpeningProfit1 = (Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["OpeningBalance"].ToString())) + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["debit"].ToString()) - Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["credit"].ToString()); { if (OpeningProfit1 > 0) { dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decTotalProfitAndLoss + dcProfit + "Dr"; } else dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = (-1) * decTotalProfitAndLoss - dcProfit + "Cr"; }; dcTotalCredit = dcTotalCredit + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["credit"].ToString()); dcTotalDebit = dcTotalDebit + Convert.ToDecimal(dtblProfitAndLossAcc.Rows[0]["debit"].ToString()); //=================================Net profit and NetLoss transation for previousyear============== decimal decprofitLossbal = 0; decimal decbalance = 0; decimal decProfitAndLossOfPrevious = decProfitLedgerOpening; dgvTrailBalance.Rows.Add(); if (dcProfitOpening > 0) { dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = dcProfitOpening + "Dr"; decprofitLossbal = dcProfitOpening; } if (dcProfitOpening <= 0) { dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = (-1) * dcProfitOpening + "Cr"; decprofitLossbal = dcProfitOpening; } dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = " "; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Profit and Loss Opening"; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["openingBalance"].Value = "0.00Dr"; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Brown; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Regular); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtAccountGroupId"].Value = "0"; if (decProfitAndLossOfPrevious > 0) { dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = decProfitAndLossOfPrevious; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = "0.00"; decbalance = (decProfitAndLossOfPrevious); } if (decProfitAndLossOfPrevious <= 0) { dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = (-1) * (decProfitAndLossOfPrevious); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = "0.00"; decbalance = ((decProfitAndLossOfPrevious)); } if (decbalance >= 0) { dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decbalance + decprofitLossbal + "Dr"; } if (decbalance < 0) { decbalance = -(decbalance); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtBalance"].Value = decbalance + decprofitLossbal + "Cr"; } dgvTrailBalance.Rows.Add(); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = " "; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["accountGroupName"].Value = "Total:"; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["dgvtxtSlNo"].Value = string.Empty; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.ForeColor = Color.Red; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].DefaultCellStyle.Font = new Font(dgvTrailBalance.Font, FontStyle.Bold); dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["credit"].Value = dcTotalCredit; dgvTrailBalance.Rows[dgvTrailBalance.Rows.Count - 1].Cells["debit"].Value = dcTotalDebit; if (dgvTrailBalance.Columns.Count > 0) { dgvTrailBalance.Columns["credit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvTrailBalance.Columns["debit"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvTrailBalance.Columns["openingBalance"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvTrailBalance.Columns["dgvtxtBalance"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } dgvTrailBalance.ScrollBars = ScrollBars.Both; dgvTrailBalance.ClearSelection(); if (inCurrenRowIndex > 0 && dgvTrailBalance.Rows.Count > 0 && inCurrenRowIndex < dgvTrailBalance.Rows.Count) { if (dgvTrailBalance.Rows[inCurrenRowIndex].Cells[inCurrentColIndex].Visible) { dgvTrailBalance.CurrentCell = dgvTrailBalance.Rows[inCurrenRowIndex].Cells[inCurrentColIndex]; } else { dgvTrailBalance.CurrentCell = dgvTrailBalance.Rows[inCurrenRowIndex].Cells["debit"]; } dgvTrailBalance.CurrentCell.Selected = true; } inCurrenRowIndex = 0; } } catch (Exception ex) { MessageBox.Show("Tb:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// These function is used to reset the form and clear its controlls /// </summary> public void Clear() { try { if (isAutomatic) { VoucherNumberGeneration(); txtContraVoucherDate.Focus(); } else { txtVoucherNo.Text = string.Empty; txtVoucherNo.ReadOnly = false; } BankOrCashComboFill(cmbBankAccount); GridBankOrCashComboFill(); isEditMode = false; dtpContraVoucherDate.MinDate = PublicVariables._dtFromDate; dtpContraVoucherDate.MaxDate = PublicVariables._dtToDate; CompanyInfo infoComapany = new CompanyInfo(); //CompanySP spCompany = new CompanySP(); CompanyCreationBll bllCompanyCreation = new CompanyCreationBll(); infoComapany = bllCompanyCreation.CompanyView(1); DateTime dtVoucherDate = infoComapany.CurrentDate; dtpContraVoucherDate.Value = dtVoucherDate; txtContraVoucherDate.Text = dtVoucherDate.ToString("dd-MMM-yyyy"); dtpContraVoucherDate.Value = Convert.ToDateTime(txtContraVoucherDate.Text); txtContraVoucherDate.Focus(); txtContraVoucherDate.SelectAll(); if (txtVoucherNo.ReadOnly) { txtContraVoucherDate.Focus(); } else { txtVoucherNo.Focus(); } cmbBankAccount.SelectedIndex = -1; txtNarration.Text = string.Empty; txtTotal.Text = string.Empty; dgvContraVoucher.ClearSelection(); rbtnDeposit.Checked = true; btnDelete.Enabled = false; btnSave.Text = "Save"; dgvContraVoucher.Rows.Clear(); if (frmContraRegisterObj != null) { frmContraRegisterObj.Close(); } if (frmContraReportObj != null) { frmContraReportObj.Close(); } SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("TickPrintAfterSave") == "Yes") { cbxPrintafterSave.Checked = true; } else { cbxPrintafterSave.Checked = false; } } catch (Exception ex) { MessageBox.Show("CV:09" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Functions to clear the form controls based on the settings /// </summary> public void ClearFunctions() { try { CurrencyBll BllCurrency = new CurrencyBll(); SettingsBll BllSettings = new SettingsBll(); strCurrencySymbol = BllCurrency.CurrencyView(PublicVariables._decCurrencyId).CurrencySymbol; if (BllSettings.SettingsStatusCheck("AllowGodown") == "Yes") { cmbGodown.Visible = true; lblGodown.Visible = true; } else { cmbGodown.Visible = false; lblGodown.Visible = false; } if (BllSettings.SettingsStatusCheck("AllowRack") == "Yes") { cmbRack.Visible = true; lblRack.Visible = true; } else { cmbRack.Visible = false; lblRack.Visible = false; } if (BllSettings.SettingsStatusCheck("AllowBatch") == "Yes") { cmbBatch.Visible = true; lblBatch.Visible = true; } else { cmbBatch.Visible = false; lblBatch.Visible = false; } if (BllSettings.SettingsStatusCheck("ShowProductCode") == "Yes") { lblProductcode.Visible = true; txtProductCode.Visible = true; dgvPointOfSales.Columns["dgvtxtProductCode"].Visible = true; } else { lblProductcode.Visible = false; txtProductCode.Visible = false; dgvPointOfSales.Columns["dgvtxtProductCode"].Visible = false; } if (BllSettings.SettingsStatusCheck("Barcode") == "Yes") { lblBarcode.Visible = true; txtBarcode.Visible = true; } else { lblBarcode.Visible = false; txtBarcode.Visible = false; } if (BllSettings.SettingsStatusCheck("ShowDiscountAmount") == "Yes") { txtDiscountAmount.Visible = true; lblDiscountAmt.Visible = true; dgvPointOfSales.Columns["dgvtxtDiscount"].Visible = true; } else { txtDiscountAmount.Visible = false; lblDiscountAmt.Visible = false; dgvPointOfSales.Columns["dgvtxtDiscount"].Visible = false; } if (BllSettings.SettingsStatusCheck("ShowDiscountPercentage") == "Yes") { txtDiscountPercentage.Visible = true; lblDiscountPercentage.Visible = true; } else { txtDiscountPercentage.Visible = false; lblDiscountPercentage.Visible = false; } if (BllSettings.SettingsStatusCheck("ShowUnit") == "Yes") { cmbUnit.Visible = true; lblUnit.Visible = true; dgvPointOfSales.Columns["dgvtxtUnit"].Visible = true; } else { cmbUnit.Visible = false; lblUnit.Visible = false; dgvPointOfSales.Columns["dgvtxtUnit"].Visible = false; } if (BllSettings.SettingsStatusCheck("Tax") == "Yes") { cmbTax.Visible = true; lblTax.Visible = true; txtTaxAmount.Visible = true; lblTaxAmount.Visible = true; lblTaxTotalAmount.Visible = true; lblLedgerTotal.Visible = true; dgvPointOfSales.Columns["dgvtxtTaxPercentage"].Visible = true; dgvPointOfSales.Columns["dgvtxtTaxAmount"].Visible = true; dgvPOSTax.Visible = true; } else { cmbTax.Visible = false; lblTax.Visible = false; txtTaxAmount.Visible = false; lblTaxAmount.Visible = false; lblTaxTotalAmount.Visible = false; lblLedgerTotal.Visible = false; dgvPointOfSales.Columns["dgvtxtTaxPercentage"].Visible = false; dgvPointOfSales.Columns["dgvtxtTaxAmount"].Visible = false; dgvPOSTax.Visible = false; } if (PrintAfetrSave()) { cbxPrintAfterSave.Checked = true; } else { cbxPrintAfterSave.Checked = false; } dtpDate.Value = PublicVariables._dtCurrentDate; dtpDate.MinDate = PublicVariables._dtFromDate; dtpDate.MaxDate = PublicVariables._dtToDate; dtpDate.CustomFormat = "dd-MMMM-yyyy"; CashorPartyComboFill(); PricingLevelComboFill(); salesManComboFill(); SalesAccountComboFill(); CounterComboFill(); ItemComboFill(); taxGridFill(); cmbTaxComboFill(); if (isAutomatic) { VoucherNumberGeneration(); } Clear(); } catch (Exception ex) { MessageBox.Show("POS : 02" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Clear function to reset the form /// </summary> public void Clear() { try { SettingsBll BllSettings = new SettingsBll(); cmbPricingLevel.SelectedIndex = 0; cmbSalesAccount.SelectedIndex = 0; cmbCashOrParty.SelectedIndex = 0; cmbSalesMan.SelectedIndex = 0; cmbCounter.SelectedIndex = 0; txtBarcode.Clear(); txtProductCode.Clear(); cmbItem.SelectedIndex = -1; txtQuantity.Text = "0"; txtRate.Text = "0"; txtDiscountAmount.Text = "0"; dgvPointOfSales.Rows.Clear(); txtNarration.Clear(); txtPaidAmount.Text = "0"; txtBalance.Text = "0"; txtTotalAmount.Text = "0"; txtBillDiscount.Text = "0"; txtGrandTotal.Text = "0"; lblTaxTotalAmount.Text = "00.00"; btnDelete.Enabled = false; btnSave.Text = "Save"; btnClear.Text = "Clear"; if (!txtVoucherNo.ReadOnly) { txtVoucherNo.Clear(); txtVoucherNo.Focus(); } else { if (BllSettings.SettingsStatusCheck("Barcode") == "Yes") { txtBarcode.Select(); } else { txtProductCode.Select(); } } ClearGroupbox(); } catch (Exception ex) { MessageBox.Show("POS : 03" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// For enter key and backspace navigation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void txtQuantity_KeyDown(object sender, KeyEventArgs e) { string strtxt = txtQuantity.Text.Trim(); try { SettingsBll BllSettings = new SettingsBll(); if (e.KeyCode == Keys.Enter) { if (BllSettings.SettingsStatusCheck("ShowUnit") == "Yes") { cmbUnit.Focus(); } else { txtRate.Focus(); txtRate.Select(); } } else if (e.KeyCode == Keys.Back) { if (txtQuantity.SelectionLength > 0) { txtQuantity.Text = strtxt.Trim(); txtQuantity.SelectionStart = 0; txtQuantity.SelectionLength = 0; if (BllSettings.SettingsStatusCheck("AllowBatch") == "Yes") { cmbBatch.Focus(); } else if (BllSettings.SettingsStatusCheck("AllowGodown") == "Yes") { cmbRack.Focus(); } else { cmbItem.Focus(); } } } } catch (Exception ex) { MessageBox.Show("POS: 101" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// For enter key and backspace navigation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbItem_KeyDown(object sender, KeyEventArgs e) { string strProductName; try { SettingsBll BllSettings = new SettingsBll(); if (e.KeyCode == Keys.Enter) { if (BllSettings.SettingsStatusCheck("AllowGodown") == "Yes") { cmbGodown.Focus(); cmbGodown.SelectionStart = 0; } else if (BllSettings.SettingsStatusCheck("AllowBatch") == "Yes") { cmbBatch.Focus(); } else { txtQuantity.Focus(); txtQuantity.Select(); } } else if (e.KeyCode == Keys.Back) { if (txtProductCode.Visible) { if (txtProductCode.Text.Trim() != string.Empty || txtProductCode.SelectionLength == 0) { txtProductCode.SelectionStart = 0; txtProductCode.Focus(); } } else { txtBarcode.Focus(); txtBarcode.Select(); } } else if (e.KeyCode == Keys.F && Control.ModifierKeys == Keys.Control) //Pop Up { if (cmbItem.Focused) { cmbItem.DropDownStyle = ComboBoxStyle.DropDown; } else { cmbItem.DropDownStyle = ComboBoxStyle.DropDownList; } if (cmbItem.SelectedIndex != -1) { frmProductSearchPopup frmProductSearchPopupObj = new frmProductSearchPopup(); frmProductSearchPopupObj.MdiParent = formMDI.MDIObj; frmProductSearchPopupObj.CallFromPOS(this, cmbItem.SelectedIndex, txtProductCode.Text); } else { frmProductSearchPopup frmProductSearchPopupObj = new frmProductSearchPopup(); frmProductSearchPopupObj.MdiParent = formMDI.MDIObj; frmProductSearchPopupObj.CallFromPOS(this, cmbItem.SelectedIndex, string.Empty); } } else if (e.KeyCode == Keys.C && Control.ModifierKeys == Keys.Alt) //Creation { frmProductCreation frmProductCreationObj = new frmProductCreation(); bool isFromItemCombo = true; if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, "frmProductCreation", "Save")) { if (cmbItem.SelectedValue != null) { strProductName = cmbItem.SelectedValue.ToString(); } else { strProductName = string.Empty; } frmProductCreationObj.MdiParent = formMDI.MDIObj; frmProductCreationObj.CallFromPOSForProductCreation(this, isFromItemCombo); } else { MessageBox.Show("You don’t have privilege", "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { MessageBox.Show("POS: 116" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// For enter key and backspace navigation /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbBatch_KeyDown(object sender, KeyEventArgs e) { try { SettingsBll BllSettings = new SettingsBll(); if (e.KeyCode == Keys.Enter) { txtQuantity.Focus(); } else if (e.KeyCode == Keys.Back) { if (BllSettings.SettingsStatusCheck("AllowGodown") == "Yes") { cmbRack.Focus(); } else { cmbItem.Focus(); cmbItem.Select(); } } } catch (Exception ex) { MessageBox.Show("POS: 119" + ex.Message, "Open Miracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to save An items to table /// </summary> public void SaveFunction() { LedgerPostingInfo infoLedgerPosting = new LedgerPostingInfo(); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); UnitConvertionBll bllUnitConversion = new UnitConvertionBll(); ExchangeRateBll BllExchangeRate = new ExchangeRateBll(); try { InfoSalesMaster.InvoiceNo = txtVoucherNo.Text.Trim(); InfoSalesMaster.AdditionalCost = 0; InfoSalesMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); InfoSalesMaster.BillDiscount = Convert.ToDecimal(txtBillDiscount.Text); if (cmbCounter.SelectedIndex > -1) { InfoSalesMaster.CounterId = Convert.ToDecimal(cmbCounter.SelectedValue.ToString()); } else { InfoSalesMaster.CounterId = 0; } InfoSalesMaster.CreditPeriod = 0; InfoSalesMaster.CustomerName = string.Empty; InfoSalesMaster.Date = Convert.ToDateTime(txtDate.Text); InfoSalesMaster.DeliveryNoteMasterId = 0; if (cmbSalesMan.SelectedValue.ToString() != null) { InfoSalesMaster.EmployeeId = Convert.ToDecimal(cmbSalesMan.SelectedValue.ToString()); } else { InfoSalesMaster.EmployeeId = 0; } decimal decExachangeRateId = BllExchangeRate.ExchangerateViewByCurrencyId(PublicVariables._decCurrencyId); InfoSalesMaster.ExchangeRateId = decExachangeRateId; InfoSalesMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; InfoSalesMaster.GrandTotal = Convert.ToDecimal(txtGrandTotal.Text.Trim()); InfoSalesMaster.LrNo = string.Empty; InfoSalesMaster.Narration = txtNarration.Text.Trim(); InfoSalesMaster.OrderMasterId = 0; InfoSalesMaster.POS = true; if (cmbPricingLevel.SelectedValue.ToString() != null) { InfoSalesMaster.PricinglevelId = Convert.ToDecimal(cmbPricingLevel.SelectedValue.ToString()); } else { InfoSalesMaster.PricinglevelId = 0; } InfoSalesMaster.QuotationMasterId = 0; InfoSalesMaster.SalesAccount = Convert.ToDecimal(cmbSalesAccount.SelectedValue.ToString()); InfoSalesMaster.TaxAmount = Convert.ToDecimal(lblTaxTotalAmount.Text.ToString()); InfoSalesMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); InfoSalesMaster.TransportationCompany = string.Empty; InfoSalesMaster.UserId = PublicVariables._decCurrentUserId; InfoSalesMaster.VoucherTypeId = DecPOSVoucherTypeId; if (isAutomatic) { InfoSalesMaster.SuffixPrefixId = decPOSSuffixPrefixId; InfoSalesMaster.VoucherNo = strVoucherNo; } else { InfoSalesMaster.SuffixPrefixId = 0; InfoSalesMaster.VoucherNo = txtVoucherNo.Text; } InfoSalesMaster.ExtraDate = DateTime.Now; InfoSalesMaster.Extra1 = string.Empty; InfoSalesMaster.Extra2 = string.Empty; decSalesMasterId = BllSalesInvoice.SalesMasterAdd(InfoSalesMaster); int inRowCount = dgvPointOfSales.RowCount; InfoSalesDetails.SalesMasterId = decSalesMasterId; InfoSalesDetails.ExtraDate = DateTime.Now; InfoSalesDetails.Extra1 = string.Empty; InfoSalesDetails.Extra2 = string.Empty; for (int inI = 0; inI < inRowCount; inI++) { if (dgvPointOfSales.Rows[inI].Cells["dgvtxtProductName"].Value != null && dgvPointOfSales.Rows[inI].Cells["dgvtxtProductName"].Value.ToString() != string.Empty) { if (dgvPointOfSales.Rows[inI].Cells["dgvtxtQuantity"].Value != null && dgvPointOfSales.Rows[inI].Cells["dgvtxtQuantity"].Value.ToString() != string.Empty) { InfoSalesDetails.SlNo = Convert.ToInt32(dgvPointOfSales.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); InfoSalesDetails.ProductId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtProductId"].Value.ToString()); InfoSalesDetails.Qty = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtQuantity"].Value.ToString()); InfoSalesDetails.Rate = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); InfoSalesDetails.UnitId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtUnitId"].Value.ToString()); InfoSalesDetails.UnitConversionId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtunitconversionId"].Value.ToString()); InfoSalesDetails.Discount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtDiscount"].Value.ToString()); InfoSalesDetails.TaxId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxttaxid"].Value.ToString()); InfoSalesDetails.BatchId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtBatchId"].Value.ToString()); InfoSalesDetails.GodownId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtGodownId"].Value.ToString()); InfoSalesDetails.RackId = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtRackId"].Value.ToString()); InfoSalesDetails.TaxAmount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtTaxAmount"].Value.ToString()); InfoSalesDetails.GrossAmount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtGrossValue"].Value.ToString()); InfoSalesDetails.NetAmount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtNetAmount"].Value.ToString()); InfoSalesDetails.Amount = Convert.ToDecimal(dgvPointOfSales.Rows[inI].Cells["dgvtxtTotalAmount"].Value.ToString()); BllSalesInvoice.SalesDetailsAdd(InfoSalesDetails); infoStockPosting.Date = InfoSalesMaster.Date; infoStockPosting.VoucherTypeId = DecPOSVoucherTypeId; infoStockPosting.VoucherNo = strVoucherNo; infoStockPosting.InvoiceNo = txtVoucherNo.Text.Trim(); infoStockPosting.AgainstVoucherTypeId = 0; infoStockPosting.AgainstVoucherNo = "NA"; infoStockPosting.AgainstInvoiceNo = "NA"; infoStockPosting.ProductId = InfoSalesDetails.ProductId; infoStockPosting.BatchId = InfoSalesDetails.BatchId; infoStockPosting.UnitId = InfoSalesDetails.UnitId; infoStockPosting.GodownId = InfoSalesDetails.GodownId; infoStockPosting.RackId = InfoSalesDetails.RackId; infoStockPosting.InwardQty = 0; infoStockPosting.OutwardQty = InfoSalesDetails.Qty / bllUnitConversion.UnitConversionRateByUnitConversionId(InfoSalesDetails.UnitConversionId); ; infoStockPosting.Rate = InfoSalesDetails.Rate; infoStockPosting.FinancialYearId = InfoSalesMaster.FinancialYearId; infoStockPosting.Extra1 = string.Empty; infoStockPosting.Extra2 = string.Empty; BllStockPosting.StockPostingAdd(infoStockPosting); } } } int inTaxRowCount = dgvPOSTax.RowCount; InfoSalesBillTax.SalesMasterId = decSalesMasterId; InfoSalesBillTax.ExtraDate = DateTime.Now; InfoSalesBillTax.Extra1 = string.Empty; InfoSalesBillTax.Extra2 = string.Empty; for (int inI = 0; inI < inTaxRowCount; inI++) { if (dgvPOSTax.Rows[inI].Cells["dgvtxttax"].Value != null && dgvPOSTax.Rows[inI].Cells["dgvtxttax"].Value.ToString() != string.Empty) { if (dgvPOSTax.Rows[inI].Cells["dgvtxtTaxAmt"].Value != null && dgvPOSTax.Rows[inI].Cells["dgvtxtTaxAmt"].Value.ToString() != string.Empty) { InfoSalesBillTax.TaxId = Convert.ToInt32(dgvPOSTax.Rows[inI].Cells["dgvtxttax"].Value.ToString()); InfoSalesBillTax.TaxAmount = Convert.ToDecimal(dgvPOSTax.Rows[inI].Cells["dgvtxtTaxAmt"].Value.ToString()); BllSalesInvoice.SalesBillTaxAdd(InfoSalesBillTax); } } } ledgerPostingAdd(); if (BllSalesInvoice.SalesInvoiceInvoicePartyCheckEnableBillByBillOrNot(Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()))) { partyBalanceAdd(); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decSalesMasterId); } else { Print(decSalesMasterId); } } ClearFunctions(); } catch (Exception ex) { MessageBox.Show("POS:44" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to Quantity Status Check /// </summary> public void QuantityStatusCheck() { try { decimal decProductId = 0; decimal decBatchId = 0; decimal decCalcQty = 0; StockPostingBll BllStockPosting = new StockPostingBll(); SettingsBll BllSettings = new SettingsBll(); string strStatus = BllSettings.SettingsStatusCheck("NegativeStockStatus"); bool isNegativeLedger = false; if (cmbItem.SelectedIndex != -1) { decProductId = Convert.ToDecimal(cmbItem.SelectedValue.ToString()); batchcombofill(); decBatchId = Convert.ToDecimal(cmbBatch.SelectedValue.ToString()); decimal decCurrentStock = BllStockPosting.StockCheckForProductSale(decProductId, decBatchId); if (txtQuantity.Text != null || txtQuantity.Text != string.Empty) { decCalcQty = decCurrentStock - Convert.ToDecimal(txtQuantity.Text.Trim().ToString()); } if (decCalcQty < 0) { isNegativeLedger = true; } } if (isNegativeLedger) { if (strStatus == "Warn") { if (MessageBox.Show("Negative Stock balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { AddToGrid(); } else { cmbItem.Focus(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); cmbItem.Focus(); } else { AddToGrid(); } } else { AddToGrid(); } } catch (Exception ex) { MessageBox.Show("POS :42 " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Checking invalid entries for save or update and call its curresponding function /// </summary> public void SaveOrEditFuction() { try { decimal decCalcAmount = 0; decimal decBalance = 0; string strStatus = string.Empty; //ContraMasterSP spContraMaster = new ContraMasterSP(); ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll(); AccountLedgerBll bllAccountLedger = new AccountLedgerBll(); SettingsBll BllSettings = new SettingsBll(); if (txtVoucherNo.Text == string.Empty) { Messages.InformationMessage("Enter voucher number"); txtVoucherNo.Focus(); } else if (cmbBankAccount.SelectedIndex == -1) { Messages.InformationMessage("Select cash or bank account"); cmbBankAccount.Focus(); } else { if (RemoveIncompleteRowsFromGrid()) { if (dtpContraVoucherDate.Value.ToString() != string.Empty) { strStatus = BllSettings.SettingsStatusCheck("NegativeCashTransaction"); if (rbtnWithdrawal.Checked) { decBalance = bllAccountLedger.CheckLedgerBalance(Convert.ToDecimal(cmbBankAccount.SelectedValue.ToString())); decCalcAmount = decBalance - Convert.ToDecimal(txtTotal.Text); if (decCalcAmount < 0) { if (strStatus == "Warn") { if (MessageBox.Show("Negative balance exists,Do you want to Continue", "Openmiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveOrEdit(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative balance", "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { SaveOrEdit(); } } else { SaveOrEdit(); } } else { bool isNegativeLedger = false; int inRowCount = dgvContraVoucher.RowCount; for (int i = 0; i < inRowCount - 1; i++) { decCalcAmount = 0; decimal decledgerId = 0; if (dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value != null && dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString() != "") { decledgerId = Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value.ToString()); } decBalance = bllAccountLedger.CheckLedgerBalance(decledgerId); decCalcAmount = decBalance - Convert.ToDecimal(dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value.ToString()); if (decCalcAmount < 0) { isNegativeLedger = true; break; } } if (isNegativeLedger) { if (strStatus == "Warn") { if (MessageBox.Show("Negative balance exists,Do you want to Continue", "Openmiracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveOrEdit(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative balance", "Openmiracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { SaveOrEdit(); } } else { SaveOrEdit(); } } } } } } catch (Exception ex) { MessageBox.Show("CV:15" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Checking the multicurrency and set the read only mode of currency combo as per the basis of settings /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dtpContraVoucherDate_ValueChanged(object sender, EventArgs e) { try { GridCurrencyComboFill(); SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("MultiCurrency") == "Yes") { dgvcmbCurrency.ReadOnly = false; } else { dgvcmbCurrency.ReadOnly = true; } } catch (Exception ex) { MessageBox.Show("CV:38" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Calls the corresponding voucher on click in Quick Launch menu /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn1_Click(object sender, EventArgs e) { this.SendToBack(); Form frmObj = null; Form open = null; SettingsBll BllSettings = new SettingsBll(); try { string str = ((Button)sender).Text; btnFocus.Focus(); switch (str) { case "Contra Voucher": formMDI.MDIObj.ContraVoucherClick(); break; case "Payment Voucher": formMDI.MDIObj.PaymentVoucherClick(); break; case "Receipt Voucher": formMDI.MDIObj.ReceiptVoucherClick(); break; case "Journal Voucher": formMDI.MDIObj.JournalVoucherClick(); break; case "Sales Invoice": formMDI.MDIObj.SalesInvoiceClick(); break; case "Purchase Invoice": formMDI.MDIObj.PurchaseInvoiceClick(); break; case "POS": formMDI.MDIObj.POSClick(); break; case "PDC Payable": formMDI.MDIObj.PDCPayableClick(); break; case "PDC Receivable": formMDI.MDIObj.PDCReceivableClick(); break; case "PDC Clearance": formMDI.MDIObj.PDCClearenceClick(); break; case "Bank Reconciliation": frmObj = new frmBankReconciliation(); open = Application.OpenForms["frmBankReconciliation"] as frmBankReconciliation; break; case "Purchase Order": formMDI.MDIObj.PurchaseOrderClick(); break; case "Material Reciept": formMDI.MDIObj.MaterialReceiptClick(); break; case "Rejection Out": formMDI.MDIObj.RejectionOutClick(); break; case "Purchase Return": formMDI.MDIObj.PurchaseReturnClick(); break; case "Sales Quotation": formMDI.MDIObj.SalesQuotationClick(); break; case "Sales Order": formMDI.MDIObj.SalesOrderClick(); break; case "Delivery Note": formMDI.MDIObj.DeliveryNoteClick(); break; case "Rejection In": formMDI.MDIObj.RejectionInClick(); break; case "Sales Return": formMDI.MDIObj.SalesReturnClick(); break; case "Physical Stock": formMDI.MDIObj.PhysicalStockClick(); break; case "Service Voucher": formMDI.MDIObj.ServiceVoucherClick(); break; case "Credit Note": formMDI.MDIObj.CreditNoteClick(); break; case "Debit Note": formMDI.MDIObj.DebitNoteClick(); break; case "Stock Journal": //frmObj = new frmStockJournal(); //open = Application.OpenForms["frmStockJournal"] as frmStockJournal; formMDI.MDIObj.StockJournalClick(); break; case "Bill Allocation": frmObj = new frmBillallocation(); open = Application.OpenForms["frmBillallocation"] as frmBillallocation; break; case "Account Group": frmObj = new frmAccountGroup(); open = Application.OpenForms["frmAccountGroup"] as frmAccountGroup; break; case "Account Ledger": frmObj = new frmAccountLedger(); open = Application.OpenForms["frmAccountLedger"] as frmAccountLedger; break; case "Multiple Account Ledgers": frmObj = new frmmultipleAccountLedger(); open = Application.OpenForms["frmmultipleAccountLedger"] as frmmultipleAccountLedger; break; case "Product Group": frmObj = new frmProductGroup(); open = Application.OpenForms["frmProductGroup"] as frmProductGroup; break; case "Product Creation": frmObj = new frmProductCreation(); open = Application.OpenForms["frmProductCreation"] as frmProductCreation; break; case "Multiple Product Creation": frmObj = new frmMultipleProductCreation(); open = Application.OpenForms["frmMultipleProductCreation"] as frmMultipleProductCreation; break; case "Batch": if (BllSettings.SettingsStatusCheck("AllowBatch") == "Yes") { frmObj = new frmBatch(); open = Application.OpenForms["frmBatch"] as frmBatch; } break; case "Brand": frmObj = new frmBrand(); open = Application.OpenForms["frmBrand"] as frmBrand; break; case "Model Number": if (BllSettings.SettingsStatusCheck("AllowModelNo") == "Yes") { frmObj = new frmModalNo(); open = Application.OpenForms["frmModalNo"] as frmModalNo; } break; case "Size": if (BllSettings.SettingsStatusCheck("AllowSize") == "Yes") { frmObj = new frmSize(); open = Application.OpenForms["frmSize"] as frmSize; } break; case "Unit": frmObj = new frmUnit(); open = Application.OpenForms["frmUnit"] as frmUnit; break; case "Godown": if (BllSettings.SettingsStatusCheck("AllowGodown") == "Yes") { frmObj = new frmGodown(); open = Application.OpenForms["frmGodown"] as frmGodown; } break; case "Rack": if (BllSettings.SettingsStatusCheck("AllowRack") == "Yes") { frmObj = new frmRack(); open = Application.OpenForms["frmRack"] as frmRack; } break; case "Pricing Level": frmObj = new frmPricingLevel(); open = Application.OpenForms["frmPricingLevel"] as frmPricingLevel; break; case "Price List": frmObj = new frmPriceList(); open = Application.OpenForms["frmPriceList"] as frmPriceList; break; case "Standard Rate": frmObj = new frmStandardRate(); open = Application.OpenForms["frmStandardRate"] as frmStandardRate; break; case "Tax": if (BllSettings.SettingsStatusCheck("Tax") == "Yes") { frmObj = new frmTax(); open = Application.OpenForms["frmTax"] as frmTax; } break; case "Currency": if (BllSettings.SettingsStatusCheck("MultiCurrency") == "Yes") { frmObj = new frmCurrency(); open = Application.OpenForms["frmCurrency"] as frmCurrency; } break; case "Exchange Rate": frmObj = new frmExchangeRate(); open = Application.OpenForms["frmExchangeRate"] as frmExchangeRate; break; case "Service Category": frmObj = new frmServiceCategory(); open = Application.OpenForms["frmServiceCategory"] as frmServiceCategory; break; case "Services": frmObj = new frmServices(); open = Application.OpenForms["frmServices"] as frmServices; break; case "Voucher Type": frmObj = new frmVoucherType(); open = Application.OpenForms["frmVoucherType"] as frmVoucherType; break; case "Area": frmObj = new frmArea(); open = Application.OpenForms["frmArea"] as frmArea; break; case "Route": frmObj = new frmRoute(); open = Application.OpenForms["frmRoute"] as frmRoute; break; case "Counter": frmObj = new frmCounter(); open = Application.OpenForms["frmCounter"] as frmCounter; break; case "Product Register": frmObj = new frmProductRegister(); open = Application.OpenForms["frmProductRegister"] as frmProductRegister; break; case "Salesman": frmObj = new frmSalesman(); open = Application.OpenForms["frmSalesman"] as frmSalesman; break; case "Contra Register": frmObj = new frmContraRegister(); open = Application.OpenForms["frmContraRegister"] as frmContraRegister; break; case "Payment Register": frmObj = new frmPaymentRegister(); open = Application.OpenForms["frmPaymentRegister"] as frmPaymentRegister; break; case "Receipt Register": frmObj = new frmReceiptRegister(); open = Application.OpenForms["frmReceiptRegister"] as frmReceiptRegister; break; case "Journal Register": frmObj = new frmJournalRegister(); open = Application.OpenForms["frmJournalRegister"] as frmJournalRegister; break; case "PDC Payable Register": frmObj = new frmPDCPayableRegister(); open = Application.OpenForms["frmPDCPayableRegister"] as frmPDCPayableRegister; break; case "PDC Receivable Register": frmObj = new frmPDCReceivableRegister(); open = Application.OpenForms["frmPDCReceivableRegister"] as frmPDCReceivableRegister; break; case "PDC Clearance Register": frmObj = new frmPdcClearanceRegister(); open = Application.OpenForms["frmPdcClearanceRegister"] as frmPdcClearanceRegister; break; case "Purchase Order Register": frmObj = new frmPurchaseOrderRegister(); open = Application.OpenForms["frmPurchaseOrderRegister"] as frmPurchaseOrderRegister; break; case "Material Receipt Register": frmObj = new frmMaterialReceiptRegister(); open = Application.OpenForms["frmMaterialReceiptRegister"] as frmMaterialReceiptRegister; break; case "Rejection Out Register": frmObj = new frmRejectionOutRegister(); open = Application.OpenForms["frmRejectionOutRegister"] as frmRejectionOutRegister; break; case "Purchase Invoice Register": frmObj = new frmPurchaseInvoiceRegister(); open = Application.OpenForms["frmPurchaseInvoiceRegister"] as frmPurchaseInvoiceRegister; break; case "Purchase Return Register": frmObj = new frmPurchaseReturnRegister(); open = Application.OpenForms["frmPurchaseReturnRegister"] as frmPurchaseReturnRegister; break; case "Sales Quotation Register": frmObj = new frmSalesQuotationRegister(); open = Application.OpenForms["frmSalesQuotationRegister"] as frmSalesQuotationRegister; break; case "Sales Order Register": frmObj = new frmSalesOrderRegister(); open = Application.OpenForms["frmSalesOrderRegister"] as frmSalesOrderRegister; break; case "Delivery Note Register": frmObj = new frmDeliveryNoteRegister(); open = Application.OpenForms["frmDeliveryNoteRegister"] as frmDeliveryNoteRegister; break; case "Rejection In Register": frmObj = new frmRejectionInRegister(); open = Application.OpenForms["frmRejectionInRegister"] as frmRejectionInRegister; break; case "Sales Invoice Register": frmObj = new frmSalesInvoiceRegister(); open = Application.OpenForms["frmSalesInvoiceRegister"] as frmSalesInvoiceRegister; break; case "Sales Return Register": frmObj = new frmSalesReturnRegister(); open = Application.OpenForms["frmSalesReturnRegister"] as frmSalesReturnRegister; break; case "Physical Stock Register": frmObj = new frmPhysicalStockRegister(); open = Application.OpenForms["frmPhysicalStockRegister"] as frmPhysicalStockRegister; break; case "Service Voucher Register": frmObj = new frmServiceVoucherRegister(); open = Application.OpenForms["frmServiceVoucherRegister"] as frmServiceVoucherRegister; break; case "Credit Note Register": frmObj = new frmCreditNoteRegister(); open = Application.OpenForms["frmCreditNoteRegister"] as frmCreditNoteRegister; break; case "Debit Note Register": frmObj = new frmDebitNoteRegister(); open = Application.OpenForms["frmDebitNoteRegister"] as frmDebitNoteRegister; break; case "Stock Journal Register": frmObj = new frmStockJournalRegister(); open = Application.OpenForms["frmStockJournalRegister"] as frmStockJournalRegister; break; case "Designation": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmDesignation(); open = Application.OpenForms["frmDesignation"] as frmDesignation; } break; case "Pay Head": { frmObj = new frmPayHead(); open = Application.OpenForms["frmPayHead"] as frmPayHead; } break; case "Salary Package Creation": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmSalaryPackageCreation(); open = Application.OpenForms["frmSalaryPackageCreation"] as frmSalaryPackageCreation; } break; case "Salary Package Register": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmSalaryPackageRegister(); open = Application.OpenForms["frmSalaryPackageRegister"] as frmSalaryPackageRegister; } break; case "Employee Creation": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmEmployeeCreation(); open = Application.OpenForms["frmEmployeeCreation"] as frmEmployeeCreation; } break; case "Employee Register": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmEmployeeRegister(); open = Application.OpenForms["frmEmployeeRegister"] as frmEmployeeRegister; } break; case "Holiday Settings": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmHolydaySettings(); open = Application.OpenForms["frmHolydaySettings"] as frmHolydaySettings; } break; case "Monthly Salary Settings": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmMonthlySalarySettings(); open = Application.OpenForms["frmMonthlySalarySettings"] as frmMonthlySalarySettings; } break; case "Attendance": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmAttendance(); open = Application.OpenForms["frmAttendance"] as frmAttendance; } break; case "Advance Payment": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmAdvancePayment(); open = Application.OpenForms["frmAdvancePayment"] as frmAdvancePayment; } break; case "Advance Register": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmAdvanceRegister(); open = Application.OpenForms["frmAdvanceRegister"] as frmAdvanceRegister; } break; case "Bonus Deduction": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmBonusDeduction(); open = Application.OpenForms["frmBonusDeduction"] as frmBonusDeduction; } break; case "Bonus Deduction Register": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmBonusDeductionRegister(); open = Application.OpenForms["frmBonusDeductionRegister"] as frmBonusDeductionRegister; } break; case "Monthly Salary Voucher": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmMonthlySalaryVoucher(); open = Application.OpenForms["frmMonthlySalaryVoucher"] as frmMonthlySalaryVoucher; } break; case "Monthly Salary Register": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmMonthlySalaryRegister(); open = Application.OpenForms["frmMonthlySalaryRegister"] as frmMonthlySalaryRegister; } break; case "Daily Salary Voucher": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmDailySalaryVoucher(); open = Application.OpenForms["frmDailySalaryVoucher"] as frmDailySalaryVoucher; } break; case "Daily Salary Register": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmDailySalaryRegister(); open = Application.OpenForms["frmDailySalaryRegister"] as frmDailySalaryRegister; } break; case "Pay Slip": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmPaySlip(); open = Application.OpenForms["frmPaySlip"] as frmPaySlip; } break; case "Budget": if (BllSettings.SettingsStatusCheck("Budget") == "Yes") { frmObj = new frmBudget(); open = Application.OpenForms["frmBudget"] as frmBudget; } break; case "Budget Variance": if (BllSettings.SettingsStatusCheck("Budget") == "Yes") { frmObj = new frmBudgetVariance(); open = Application.OpenForms["frmBudgetVariance"] as frmBudgetVariance; } break; case "Change Current Date": frmObj = new frmChangeCurrentDate(); open = Application.OpenForms["frmChangeCurrentDate"] as frmChangeCurrentDate; break; case "Settings": frmObj = new frmSettings(); open = Application.OpenForms["frmSettings"] as frmSettings; break; case "Role": frmObj = new frmRole(); open = Application.OpenForms["frmRole"] as frmRole; break; case "Role Privilege Settings": frmObj = new frmRolePrivilegeSettings(); open = Application.OpenForms["frmRolePrivilegeSettings"] as frmRolePrivilegeSettings; break; case "User Creation": frmObj = new frmUserCreation(); open = Application.OpenForms["frmUserCreation"] as frmUserCreation; break; case "Change Password": frmObj = new frmChangePassword(); open = Application.OpenForms["frmChangePassword"] as frmChangePassword; break; case "New Financial Year": frmObj = new frmNewFinancialYear(); open = Application.OpenForms["frmNewFinancialYear"] as frmNewFinancialYear; break; case "Change Financial Year": frmObj = new frmChangeFinancialYear(); open = Application.OpenForms["frmChangeFinancialYear"] as frmChangeFinancialYear; break; case "Barcode Settings": frmObj = new frmBarcodeSettings(); open = Application.OpenForms["frmBarcodeSettings"] as frmBarcodeSettings; break; case "Barcode Printing": frmObj = new frmBarcodePrinting(); open = Application.OpenForms["frmBarcodePrinting"] as frmBarcodePrinting; break; case "Suffix Prefix Settings": frmObj = new frmSuffixPrefixSettings(); open = Application.OpenForms["frmSuffixPrefixSettings"] as frmSuffixPrefixSettings; break; case "Change Product Tax": frmObj = new frmChangeProductTax(); open = Application.OpenForms["frmChangeProductTax"] as frmChangeProductTax; break; case "Product Search": frmObj = new frmProductSearch(); open = Application.OpenForms["frmProductSearch"] as frmProductSearch; break; case "Voucher Search": frmObj = new frmVoucherSearch(); open = Application.OpenForms["frmVoucherSearch"] as frmVoucherSearch; break; case "Voucher Wise Product Search": frmObj = new frmVoucherWiseProductSearch(); open = Application.OpenForms["frmVoucherWiseProductSearch"] as frmVoucherWiseProductSearch; break; case "Personal Reminder": frmObj = new frmPersonalReminder(); open = Application.OpenForms["frmPersonalReminder"] as frmPersonalReminder; break; case "Overdue Purchase Order": frmObj = new frmOverduePurchaseOrder(); open = Application.OpenForms["frmOverduePurchaseOrder"] as frmOverduePurchaseOrder; break; case "Overdue Sales Order": frmObj = new frmOverdueSalesOrder(); open = Application.OpenForms["frmOverdueSalesOrder"] as frmOverdueSalesOrder; break; case "Short Expiry": frmObj = new frmShortExpiry(); open = Application.OpenForms["frmShortExpiry"] as frmShortExpiry; break; case "Stock": frmObj = new frmStock(); open = Application.OpenForms["frmStock"] as frmStock; break; case "Trial Balance": frmObj = new frmTrialBalance(); open = Application.OpenForms["frmTrialBalance"] as frmTrialBalance; break; case "Balance Sheet": frmObj = new frmBalanceSheet(); open = Application.OpenForms["frmBalanceSheet"] as frmBalanceSheet; break; case "Profit and Loss": frmObj = new frmProfitAndLoss(); open = Application.OpenForms["frmProfitAndLoss"] as frmProfitAndLoss; break; case "Cash Flow": frmObj = new frmCashFlow(); open = Application.OpenForms["frmCashFlow"] as frmCashFlow; break; case "Fund Flow": frmObj = new frmFundFlow(); open = Application.OpenForms["frmFundFlow"] as frmFundFlow; break; case "Chart of Account": frmObj = new frmChartOfAccount(); open = Application.OpenForms["frmChartOfAccount"] as frmChartOfAccount; break; case "Contra Report": frmObj = new frmContraReport(); open = Application.OpenForms["frmContraReport"] as frmContraReport; break; case "Payment Report": frmObj = new frmPaymentReport(); open = Application.OpenForms["frmPaymentReport"] as frmPaymentReport; break; case "Receipt Report": frmObj = new frmReceiptReport(); open = Application.OpenForms["frmReceiptReport"] as frmReceiptReport; break; case "Journal Report": frmObj = new frmJournalReport(); open = Application.OpenForms["frmJournalReport"] as frmJournalReport; break; case "PDC Payable Report": frmObj = new frmPDCPayableReport(); open = Application.OpenForms["frmPDCPayableReport"] as frmPDCPayableReport; break; case "PDC Receivable Report": frmObj = new frmPDCRecievableReport(); open = Application.OpenForms["frmPDCRecievableReport"] as frmPDCRecievableReport; break; case "PDC Clearance Report": frmObj = new frmPDCClearanceReport(); open = Application.OpenForms["frmPDCClearanceReport"] as frmPDCClearanceReport; break; case "Purchase Order Report": frmObj = new frmPurchaseOrderReport(); open = Application.OpenForms["frmPurchaseOrderReport"] as frmPurchaseOrderReport; break; case "Material Receipt Report": frmObj = new frmMaterialReceiptReport(); open = Application.OpenForms["frmMaterialReceiptReport"] as frmMaterialReceiptReport; break; case "Rejection Out Report": frmObj = new frmRejectionOutReport(); open = Application.OpenForms["frmRejectionOutReport"] as frmRejectionOutReport; break; case "Purchase Invoice Report": frmObj = new frmPurchaseReport(); open = Application.OpenForms["frmPurchaseReport"] as frmPurchaseReport; break; case "Purchase Return Report": frmObj = new frmPurchaseReturnReport(); open = Application.OpenForms["frmPurchaseReturnReport"] as frmPurchaseReturnReport; break; case "Sales Quotation Report": frmObj = new frmSalesQuotationReport(); open = Application.OpenForms["frmSalesQuotationReport"] as frmSalesQuotationReport; break; case "Sales Order Report": frmObj = new frmSalesOrderReport(); open = Application.OpenForms["frmSalesOrderReport"] as frmSalesOrderReport; break; case "Delivery Note Report": frmObj = new frmDeliveryNoteReport(); open = Application.OpenForms["frmDeliveryNoteReport"] as frmDeliveryNoteReport; break; case "Rejection In Report": frmObj = new frmRejectionInReport(); open = Application.OpenForms["frmRejectionInReport"] as frmRejectionInReport; break; case "Sales Invoice Report": frmObj = new frmSalesReport(); open = Application.OpenForms["frmSalesReport"] as frmSalesReport; break; case "Sales Return Report": frmObj = new frmSalesReturnReport(); open = Application.OpenForms["frmSalesReturnReport"] as frmSalesReturnReport; break; case "Physical Stock Report": frmObj = new frmPhysicalStockReport(); open = Application.OpenForms["frmPhysicalStockReport"] as frmPhysicalStockReport; break; case "Service Report": frmObj = new frmServiceReport(); open = Application.OpenForms["frmServiceReport"] as frmServiceReport; break; case "Credit Note Report": frmObj = new frmCreditNoteReport(); open = Application.OpenForms["frmCreditNoteReport"] as frmCreditNoteReport; break; case "Debit Note Report": frmObj = new frmDebitNoteReport(); open = Application.OpenForms["frmDebitNoteReport"] as frmDebitNoteReport; break; case "Stock Journal Report": frmObj = new frmStockJournelReport(); open = Application.OpenForms["frmStockJournelReport"] as frmStockJournelReport; break; case "Employee Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmEmployeeReport(); open = Application.OpenForms["frmEmployeeReport"] as frmEmployeeReport; } break; case "Daily Attendance Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmDailyAttendanceReport(); open = Application.OpenForms["frmDailyAttendanceReport"] as frmDailyAttendanceReport; } break; case "Monthly Attendance Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmMonthlyAttendanceReport(); open = Application.OpenForms["frmMonthlyAttendanceReport"] as frmMonthlyAttendanceReport; } break; case "Daily Salary Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmDailySalaryReport(); open = Application.OpenForms["frmDailySalaryReport"] as frmDailySalaryReport; } break; case "Monthly Salary Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmMonthlySalaryReport(); open = Application.OpenForms["frmMonthlySalaryReport"] as frmMonthlySalaryReport; } break; case "Payhead Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmPayHeadReport(); open = Application.OpenForms["frmPayHeadReport"] as frmPayHeadReport; } break; case "Salary Package Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmSalaryPackageReport(); open = Application.OpenForms["frmSalaryPackageReport"] as frmSalaryPackageReport; } break; case "Advance Payment Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmAdvancePaymentReport(); open = Application.OpenForms["frmAdvancePaymentReport"] as frmAdvancePaymentReport; } break; case "Bonus Deduction Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmBonusDeductionReport(); open = Application.OpenForms["frmBonusDeductionReport"] as frmBonusDeductionReport; } break; case "Employee Address Book Report": if (BllSettings.SettingsStatusCheck("Payroll") == "Yes") { frmObj = new frmEmployeeAddressBook(); open = Application.OpenForms["frmEmployeeAddressBook"] as frmEmployeeAddressBook; } break; case "Day Book": frmObj = new frmDayBook(); open = Application.OpenForms["frmDayBook"] as frmDayBook; break; case "Cash/Bank Book": frmObj = new frmCashBankBookReport(); open = Application.OpenForms["frmCashBankBookReport"] as frmCashBankBookReport; break; case "Account Groupwise Report": frmObj = new frmAccountGroupwiseReport(); open = Application.OpenForms["frmAccountGroupwiseReport"] as frmAccountGroupwiseReport; break; case "Account Ledger Report": frmObj = new frmAccountLedgerReport(); open = Application.OpenForms["frmAccountLedgerReport"] as frmAccountLedgerReport; break; case "Outstanding Report": frmObj = new frmOutstandingReport(); open = Application.OpenForms["frmOutstandingReport"] as frmOutstandingReport; break; case "Ageing Report": frmObj = new frmAgeingReport(); open = Application.OpenForms["frmAgeingReport"] as frmAgeingReport; break; case "Party's Address Book": frmObj = new frmPartyAddressBook(); open = Application.OpenForms["frmPartyAddressBook"] as frmPartyAddressBook; break; case "Stock Report": frmObj = new frmStockReport(); open = Application.OpenForms["frmStockReport"] as frmStockReport; break; case "Short Expiry Report": frmObj = new frmShortExpiryReport(); open = Application.OpenForms["frmShortExpiryReport"] as frmShortExpiryReport; break; case "Product Statistics": frmObj = new frmProductStatistics(); open = Application.OpenForms["frmProductStatistics"] as frmProductStatistics; break; case "Price List Report": frmObj = new frmPriceListReport(); open = Application.OpenForms["frmPriceListReport"] as frmPriceListReport; break; case "Tax Report": frmObj = new frmTaxReport(); open = Application.OpenForms["frmTaxReport"] as frmTaxReport; break; case "VAT Report": frmObj = new frmVatReturnReport(); open = Application.OpenForms["frmVatReturnReport"] as frmVatReturnReport; break; case "Cheque Report": frmObj = new frmChequeReport(); open = Application.OpenForms["frmChequeReport"] as frmChequeReport; break; case "Free Sale Report": frmObj = new frmFreeSaleReport(); open = Application.OpenForms["frmFreeSaleReport"] as frmFreeSaleReport; break; case "Product Vs Batch Report": frmObj = new frmProductVsBatchReport(); open = Application.OpenForms["frmProductVsBatchReport"] as frmProductVsBatchReport; break; case "Customer": frmObj = new frmCustomer(); open = Application.OpenForms["frmCustomer"] as frmCustomer; break; case "Supplier": frmObj = new frmSupplier(); open = Application.OpenForms["frmSupplier"] as frmSupplier; break; } if (frmObj != null) { if (open == null) { frmObj.MdiParent = formMDI.MDIObj; frmObj.Show(); } else { open.Activate(); if (open.WindowState == FormWindowState.Minimized) { open.WindowState = FormWindowState.Normal; } } } } catch (Exception ex) { MessageBox.Show("QL:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save function /// </summary> public void SaveFunction() { try { DateValidation Objdatevalidation = new DateValidation(); OtherDateValidationFunction ObjotherdateValidation = new OtherDateValidationFunction(); Objdatevalidation.DateValidationFunction(txtVoucherDate); ObjotherdateValidation.DateValidationFunction(txtCheckDate, false); DataTable dtblMaster = new DataTable(); SettingsBll BllSettings = new SettingsBll(); PDCRecivebleBll BllPdcreceivable = new PDCRecivebleBll(); PDCReceivableMasterInfo InfopdcRecivable = new PDCReceivableMasterInfo(); PartyBalanceBll BllPartyBalance = new PartyBalanceBll(); InfopdcRecivable.VoucherNo = strVoucherNo; InfopdcRecivable.InvoiceNo = txtVoucherNo.Text.Trim(); InfopdcRecivable.Date = DateTime.Parse(txtVoucherDate.Text); InfopdcRecivable.LedgerId = Convert.ToDecimal(cmbAccountLedger.SelectedValue.ToString()); InfopdcRecivable.Amount = decimal.Parse(txtAmount.Text); InfopdcRecivable.Narration = txtNarration.Text; if (txtcheckNo.Text != string.Empty) InfopdcRecivable.ChequeNo = txtcheckNo.Text; else InfopdcRecivable.ChequeNo = string.Empty; if (txtCheckDate.Text != string.Empty) InfopdcRecivable.ChequeDate = Convert.ToDateTime(txtCheckDate.Text); else InfopdcRecivable.ChequeDate = DateTime.Now; InfopdcRecivable.UserId = PublicVariables._decCurrentUserId; InfopdcRecivable.VoucherTypeId = decPDCReceivableVoucherTypeId; if (cmbBank.SelectedValue != null && cmbBank.SelectedValue.ToString() != string.Empty) { InfopdcRecivable.BankId = Convert.ToDecimal(cmbBank.SelectedValue.ToString()); } else InfopdcRecivable.BankId = 0; InfopdcRecivable.ExtraDate = DateTime.Now; InfopdcRecivable.Extra1 = string.Empty; InfopdcRecivable.Extra2 = string.Empty; if (!isInEditMode) { decimal decIdentity = BllPdcreceivable.PDCReceivableMasterAdd(InfopdcRecivable); LedgerPosting(); PartyBalanceAddOrEdit(); Messages.SavedMessage(); if (cbxPrint.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } ClearFunction(); } else { decimal decIdentity = decPDCReceivableEditId; InfopdcRecivable.PdcReceivableMasterId = decPDCReceivableEditId; BllPdcreceivable.PDCReceivableMasterEdit(InfopdcRecivable); LedgerPostingBll BllLedgerPosting = new LedgerPostingBll(); BllLedgerPosting.LedgerPostingDeleteByVoucherNoVoucherTypeIdAndLedgerId(strVoucherNo, decPDCReceivableVoucherTypeId, 12); BllPartyBalance.PartyBalanceDeleteByVoucherTypeAndVoucherNo(decPDCReceivableVoucherTypeId, strVoucherNo); PartyBalanceAddOrEdit(); LedgerPostingEdit(decPDCReceivableEditId); Messages.UpdatedMessage(); if (cbxPrint.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decIdentity); } else { Print(decIdentity); } } this.Close(); } } catch (Exception ex) { MessageBox.Show("PR9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Save Function /// </summary> public void SaveFunction() { try { PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo(); PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); PurchaseOrderDetailsInfo infoPurchaseOrderDetails = new PurchaseOrderDetailsInfo(); ProductInfo infoProduct = new ProductInfo(); ProductCreationBll BllProductCreation = new ProductCreationBll(); SettingsBll BllSettings = new SettingsBll(); if (cbxCancel.Checked) { infoPurchaseOrderMaster.Cancelled = true; } else { infoPurchaseOrderMaster.Cancelled = false; } infoPurchaseOrderMaster.Date = Convert.ToDateTime(txtDate.Text); infoPurchaseOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text); infoPurchaseOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); if (isAutomatic == true) { infoPurchaseOrderMaster.SuffixPrefixId = decPurchaseSuffixPrefixId; infoPurchaseOrderMaster.VoucherNo = strVoucherNo; } else { infoPurchaseOrderMaster.SuffixPrefixId = 0; infoPurchaseOrderMaster.VoucherNo = BllPurchaseOrder.VoucherNoMax(decPurchaseOrderTypeId); } infoPurchaseOrderMaster.VoucherTypeId = decPurchaseOrderTypeId; infoPurchaseOrderMaster.InvoiceNo = txtOrderNo.Text; infoPurchaseOrderMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseOrderMaster.EmployeeId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid infoPurchaseOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseOrderMaster.Narration = txtNarration.Text.Trim(); infoPurchaseOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoPurchaseOrderMaster.exchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoPurchaseOrderMaster.Extra1 = string.Empty; infoPurchaseOrderMaster.Extra2 = string.Empty; decPurchaseOrderMasterIdentity = Convert.ToDecimal(BllPurchaseOrder.PurchaseOrderMasterAdd(infoPurchaseOrderMaster)); int inRowcount = dgvPurchaseOrder.Rows.Count; for (int inI = 0; inI < inRowcount - 1; inI++) { infoPurchaseOrderDetails.PurchaseOrderMasterId = decPurchaseOrderMasterIdentity; if (dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString() != "") { infoProduct = BllProductCreation.ProductViewByCode(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtProductCode"].Value.ToString()); infoPurchaseOrderDetails.ProductId = infoProduct.ProductId; } if (dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString() != "") { infoPurchaseOrderDetails.Qty = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtQty"].Value.ToString()); } if (dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value != null && dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value.ToString() != "") { infoPurchaseOrderDetails.UnitId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvcmbUnit"].Value); infoPurchaseOrderDetails.UnitConversionId = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtUnitConversionId"].Value.ToString()); } infoPurchaseOrderDetails.Rate = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtRate"].Value.ToString()); infoPurchaseOrderDetails.Amount = Convert.ToDecimal(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtAmount"].Value.ToString()); infoPurchaseOrderDetails.SlNo = Convert.ToInt32(dgvPurchaseOrder.Rows[inI].Cells["dgvtxtSlNo"].Value.ToString()); infoPurchaseOrderDetails.Extra1 = string.Empty; infoPurchaseOrderDetails.Extra2 = string.Empty; BllPurchaseOrder.PurchaseOrderDetailsAdd(infoPurchaseOrderDetails); } Messages.SavedMessage(); if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseOrderMasterIdentity); } else { Print(decPurchaseOrderMasterIdentity); } } Clear(); } catch (Exception ex) { MessageBox.Show("PO35:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Checking the Settings of TickPrintAfterSave checkBox /// </summary> public void PrintCheck() { try { SettingsBll BllSettings = new SettingsBll(); cbxPrint.Checked = new SettingsBll().SettingsStatusCheck("TickPrintAfterSave") == "Yes" ? true : false; } catch (Exception ex) { MessageBox.Show("DN08: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// To check the product code status based on settings /// </summary> /// <returns></returns> public bool ShowProductCode() { bool isShow = false; try { SettingsBll BllSettings = new SettingsBll(); isShow = BllSettings.ShowProductCode(); } catch (Exception ex) { MessageBox.Show("PO2:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } return isShow; }
/// <summary> ///Function for Save Or Edit while changing NegativeStockStatus in Settings /// </summary> public void SaveOrEditFunction() { try { decimal decProductId = 0; decimal decBatchId = 0; decimal decCalcQty = 0; SettingsBll BllSettings = new SettingsBll(); string strStatus = BllSettings.SettingsStatusCheck("NegativeStockStatus"); bool isNegativeLedger = false; StockPostingBll BllStockPosting = new StockPostingBll(); //StockPostingSP spStockPosting = new StockPostingSP(); int inRowCount = dgvProduct.RowCount; for (int i = 0; i < inRowCount; i++) { if (dgvProduct.Rows[i].Cells["dgvtxtproductId"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtproductId"].Value.ToString() != string.Empty) { decProductId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtproductId"].Value.ToString()); if (dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value != null && dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value.ToString() != string.Empty) { decBatchId = Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvcmbBatch"].Value.ToString()); } decimal decCurrentStock = BllStockPosting.StockCheckForProductSale(decProductId, decBatchId); if (dgvProduct.Rows[i].Cells["dgvtxtQty"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtQty"].Value.ToString() != string.Empty) { decCalcQty = decCurrentStock - Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtQty"].Value.ToString()); } if (decCalcQty < 0) { isNegativeLedger = true; break; } } } if (isNegativeLedger) { if (strStatus == "Warn") { if (MessageBox.Show("Negative Stock balance exists,Do you want to Continue", "Open miracle", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { SaveOrEdit(); } } else if (strStatus == "Block") { MessageBox.Show("Cannot continue ,due to negative stock balance", "Open miracle", MessageBoxButtons.OK, MessageBoxIcon.Stop); // Clear(); } else { SaveOrEdit(); } } else { SaveOrEdit(); } } catch (Exception ex) { MessageBox.Show("DN46 :" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Clear function and voucherno generation based on settings /// </summary> public void Clear() { try { PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); SettingsBll BllSettings = new SettingsBll(); if (isAutomatic) { strVoucherNo = BllPurchaseOrder.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString(); if (strVoucherNo == string.Empty) { strVoucherNo = "0"; } strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); if (strVoucherNo != BllPurchaseOrder.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString()) { strVoucherNo = BllPurchaseOrder.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId).ToString(); strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); if (BllPurchaseOrder.PurchaseOrderVoucherMasterMax(decPurchaseOrderTypeId) == "0") { strVoucherNo = "0"; strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decPurchaseOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); } } infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPurchaseOrderTypeId, dtpDate.Value); strPrefix = infoSuffixPrefix.Prefix; strSuffix = infoSuffixPrefix.Suffix; decPurchaseSuffixPrefixId = infoSuffixPrefix.SuffixprefixId; strOrderNo = strPrefix + strVoucherNo + strSuffix; txtOrderNo.Text = strOrderNo; txtOrderNo.ReadOnly = true; txtDate.Focus(); } else { txtOrderNo.Text = string.Empty; txtOrderNo.ReadOnly = false; txtOrderNo.Focus(); } dtpDate.Value = PublicVariables._dtCurrentDate; dtpDate.MinDate = PublicVariables._dtFromDate; dtpDate.MaxDate = PublicVariables._dtToDate; dtpDueDate.Value = PublicVariables._dtCurrentDate; this.txtDueDate.Text = this.dtpDueDate.Value.ToString("dd-MMM-yyyy"); dtpDueDate.MinDate = PublicVariables._dtFromDate; dtpDueDate.MaxDate = PublicVariables._dtToDate; txtDueDays.Text = "0"; CashOrPartyComboFill(); if (!ShowProductCode()) { this.dgvPurchaseOrder.Columns["dgvtxtProductCode"].Visible = false; } if (!ShowBarcode()) { this.dgvPurchaseOrder.Columns["dgvtxtBarcode"].Visible = false; } if (BllSettings.SettingsStatusCheck("ShowUnit") == "Yes") { dgvPurchaseOrder.Columns["dgvcmbUnit"].Visible = true; } else { dgvPurchaseOrder.Columns["dgvcmbUnit"].Visible = false; } if (PrintAfetrSave()) { cbxPrintAfterSave.Checked = true; } else { cbxPrintAfterSave.Checked = false; } txtNarration.Text = string.Empty; btnSave.Text = "Save"; btnDelete.Enabled = false; cbxCancel.Enabled = true; cbxCancel.Checked = false; dgvPurchaseOrder.Rows.Clear(); txtTotalAmount.Text = string.Empty; } catch (Exception ex) { MessageBox.Show("PO28:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// To check whether the values of grid is valid or not /// </summary> /// <param name="e"></param> public void CheckInvalidEntries(DataGridViewCellEventArgs e) { try { SettingsBll BllSettings = new SettingsBll(); if (dgvProduct.CurrentRow != null) { if (!isValueChange) { if (dgvProduct.CurrentRow.Cells["dgvtxtProductCode"].Value == null || dgvProduct.CurrentRow.Cells["dgvtxtProductCode"].Value.ToString().Trim() == "") { isValueChange = true; dgvProduct.CurrentRow.HeaderCell.Value = "X"; dgvProduct.CurrentRow.HeaderCell.Style.ForeColor = Color.Red; } else if (dgvProduct.CurrentRow.Cells["dgvtxtQty"].Value == null || dgvProduct.CurrentRow.Cells["dgvtxtQty"].Value.ToString().Trim() == "") { isValueChange = true; dgvProduct.CurrentRow.HeaderCell.Value = "X"; dgvProduct.CurrentRow.HeaderCell.Style.ForeColor = Color.Red; } else if (BllSettings.SettingsStatusCheck("AllowZeroValueEntry") == "No" && Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtAmount"].Value) == 0) { isValueChange = true; dgvProduct.CurrentRow.HeaderCell.Value = "X"; dgvProduct.CurrentRow.HeaderCell.Style.ForeColor = Color.Red; } else if (dgvProduct.CurrentRow.Cells["dgvtxtQty"].Value == null || dgvProduct.CurrentRow.Cells["dgvtxtQty"].Value.ToString().Trim() == "" || Convert.ToDecimal(dgvProduct.CurrentRow.Cells["dgvtxtQty"].Value) == 0) { isValueChange = true; dgvProduct.CurrentRow.HeaderCell.Value = "X"; dgvProduct.CurrentRow.HeaderCell.Style.ForeColor = Color.Red; } else if (dgvProduct.CurrentRow.Cells["dgvtxtProductName"].Value == null || dgvProduct.CurrentRow.Cells["dgvtxtProductName"].Value.ToString().Trim() == "") { isValueChange = true; dgvProduct.CurrentRow.HeaderCell.Value = "X"; dgvProduct.CurrentRow.HeaderCell.Style.ForeColor = Color.Red; } else if (dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value == null || dgvProduct.CurrentRow.Cells["dgvcmbGodown"].Value.ToString().Trim() == string.Empty) { isValueChange = true; dgvProduct.CurrentRow.HeaderCell.Value = "X"; dgvProduct.CurrentRow.HeaderCell.Style.ForeColor = Color.Red; } else { isValueChange = true; dgvProduct.CurrentRow.HeaderCell.Value = ""; } } isValueChange = false; } } catch (Exception ex) { MessageBox.Show("DN24: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Currency Combofill Function /// </summary> public void CurrencyComboFill() { try { List<DataTable> listObjCurrency = new List<DataTable>(); SettingsBll BllSettings = new SettingsBll(); ; listObjCurrency = TransactionGeneralFillObj.CurrencyComboByDate(Convert.ToDateTime(txtDate.Text)); cmbCurrency.DataSource = listObjCurrency[0]; cmbCurrency.DisplayMember = "currencyName"; cmbCurrency.ValueMember = "exchangeRateId"; cmbCurrency.SelectedValue = 1m; if (BllSettings.SettingsStatusCheck("MultiCurrency") == "Yes") { cmbCurrency.Enabled = true; } else { cmbCurrency.Enabled = false; } } catch (Exception ex) { MessageBox.Show("PO1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Checking "TickPrintAfterSave" is set TRUE or FALSE /// </summary> public void PrintCheck() { try { SettingsBll BllSettings = new SettingsBll(); if (BllSettings.SettingsStatusCheck("TickPrintAfterSave") == "Yes") { cbxPrintAfterSave.Checked = true; } else { cbxPrintAfterSave.Checked = false; } } catch (Exception ex) { MessageBox.Show("SV 12 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Edit function /// </summary> public void EditFunction() { try { PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo(); PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll(); SettingsBll BllSettings = new SettingsBll(); infoPurchaseOrderMaster.PurchaseOrderMasterId = decPurchaseOrderMasterId; if (CheckCancelStatus(decPurchaseOrderMasterId)) { infoPurchaseOrderMaster.Cancelled = true; } else { infoPurchaseOrderMaster.Cancelled = false; } infoPurchaseOrderMaster.Date = Convert.ToDateTime(txtDate.Text); infoPurchaseOrderMaster.DueDate = Convert.ToDateTime(txtDueDate.Text); infoPurchaseOrderMaster.LedgerId = Convert.ToDecimal(cmbCashOrParty.SelectedValue.ToString()); infoPurchaseOrderMaster.SuffixPrefixId = Convert.ToDecimal(decPurchaseSuffixPrefixId); infoPurchaseOrderMaster.VoucherNo = strVoucherNo; infoPurchaseOrderMaster.VoucherTypeId = decPurchaseVoucherId; infoPurchaseOrderMaster.InvoiceNo = txtOrderNo.Text; infoPurchaseOrderMaster.UserId = PublicVariables._decCurrentUserId; infoPurchaseOrderMaster.EmployeeId = PublicVariables._decCurrentUserId;//by default current userid used as current employeeid infoPurchaseOrderMaster.FinancialYearId = PublicVariables._decCurrentFinancialYearId; infoPurchaseOrderMaster.Narration = txtNarration.Text.Trim(); infoPurchaseOrderMaster.exchangeRateId = Convert.ToDecimal(cmbCurrency.SelectedValue.ToString()); infoPurchaseOrderMaster.TotalAmount = Convert.ToDecimal(txtTotalAmount.Text); infoPurchaseOrderMaster.Extra1 = string.Empty; infoPurchaseOrderMaster.Extra2 = string.Empty; BllPurchaseOrder.PurchaseOrderMasterEdit(infoPurchaseOrderMaster); RemovePurchaseOrderDetails(); EditPurchaseOrderDetails(); Messages.UpdatedMessage(); if (frmPurchaseOrderRegisterObj != null) { if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseOrderMasterId); } else { Print(decPurchaseOrderMasterId); } } this.Close(); frmPurchaseOrderRegisterObj.GridFill(); } if (frmPurchaseOrderReportObj != null) { if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseOrderMasterId); } else { Print(decPurchaseOrderMasterId); } } this.Close(); frmPurchaseOrderReportObj.GridFill(); } if (frmDayBookObj != null) { if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseOrderMasterId); } else { Print(decPurchaseOrderMasterId); } } this.Close(); } if (objVoucherSearch != null) { if (cbxPrintAfterSave.Checked) { if (BllSettings.SettingsStatusCheck("Printer") == "Dot Matrix") { PrintForDotMatrix(decPurchaseOrderMasterId); } else { Print(decPurchaseOrderMasterId); } } this.Close(); } } catch (Exception ex) { MessageBox.Show("PO34:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill the Currency combobox /// </summary> public void CurrencyComboFill() { try { SettingsBll BllSettings = new SettingsBll(); List<DataTable> listObjCurrency = new List<DataTable>(); DateTime dtDate = Convert.ToDateTime(dtpVoucherDate.Value); TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll(); listObjCurrency = TransactionGeneralFillObj.CurrencyComboByDate(dtDate); cmbCurrency.DataSource = listObjCurrency[0]; cmbCurrency.DisplayMember = "currencyName"; cmbCurrency.ValueMember = "exchangeRateId"; cmbCurrency.SelectedValue = 1m; } catch (Exception ex) { MessageBox.Show("SV 11 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Function to fill Datagridview /// </summary> public void Gridfill() { try { if (!isFormLoad) { DateValidation objValidation = new DateValidation(); objValidation.DateValidationFunction(txtFromDate); if (txtFromDate.Text == string.Empty) txtFromDate.Text = PublicVariables._dtFromDate.ToString("dd-MMM-yyyy"); objValidation.DateValidationFunction(txtToDate); if (txtToDate.Text == string.Empty) txtToDate.Text = PublicVariables._dtToDate.ToString("dd-MMM-yyyy"); Font newFont = new Font(dgvProfitAndLoss.Font, FontStyle.Bold); CurrencyInfo InfoCurrency = new CurrencyInfo(); CurrencyBll BllCurrency = new CurrencyBll(); InfoCurrency = BllCurrency.CurrencyView(1); int inDecimalPlaces = InfoCurrency.NoOfDecimalPlaces; dgvProfitAndLoss.Rows.Clear(); FinancialStatementBll bllFinancialStatement = new FinancialStatementBll(); DataTable dtblFinancial = new DataTable(); DataSet DsetProfitAndLoss = new DataSet(); SettingsInfo infoSettings = new SettingsInfo(); SettingsBll BllSettings = new SettingsBll(); //---------check calculation method if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "FIFO") { calculationMethod = "FIFO"; } else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Average Cost") { calculationMethod = "Average Cost"; } else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "High Cost") { calculationMethod = "High Cost"; } else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Low Cost") { calculationMethod = "Low Cost"; } else if (BllSettings.SettingsStatusCheck("StockValueCalculationMethod") == "Last Purchase Rate") { calculationMethod = "Last Purchase Rate"; } DsetProfitAndLoss = bllFinancialStatement.ProfitAndLossAnalysis(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text)); //---- Opening Stock dgvProfitAndLoss.Rows.Add(); decimal dcOpeningStock = bllFinancialStatement.StockValueGetOnDate(DateTime.Parse(txtFromDate.Text), DateTime.Parse(txtToDate.Text), calculationMethod, true, false); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Opening Stock"; if (dcOpeningStock > 0) { dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = Math.Round(dcOpeningStock, inDecimalPlaces); } else { dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = -(Math.Round(dcOpeningStock, inDecimalPlaces)); } //Closing Stock decimal dcClosingStock = 0; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Closing Stock"; dcClosingStock = bllFinancialStatement.StockValueGetOnDate(DateTime.Parse(txtToDate.Text), calculationMethod, false, false); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = Math.Round(dcClosingStock, inDecimalPlaces); /// ---Purchase Account - Debit dtblFinancial = new DataTable(); dtblFinancial = DsetProfitAndLoss.Tables[0]; dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Purchase Accounts"; decimal dcPurchaseAccount = 0m; if (dtblFinancial.Rows.Count > 0) { foreach (DataRow rw in dtblFinancial.Rows) { decimal dcBalance = decimal.Parse(rw["Debit"].ToString().ToString()); dcPurchaseAccount += dcBalance; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "11"; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcPurchaseAccount.ToString(); //---Sales Account -Credit dtblFinancial = new DataTable(); dtblFinancial = DsetProfitAndLoss.Tables[1]; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Sales Accounts"; decimal dcSalesAccount = 0m; if (dtblFinancial.Rows.Count > 0) { foreach (DataRow rw in dtblFinancial.Rows) { decimal dcBalance = decimal.Parse(rw["Credit"].ToString().ToString()); dcSalesAccount += dcBalance; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "10"; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcSalesAccount.ToString(); dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows.Add(); //---Direct Expense dtblFinancial = new DataTable(); dtblFinancial = DsetProfitAndLoss.Tables[2]; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Direct Expenses"; decimal dcDirectExpense = 0m; if (dtblFinancial.Rows.Count > 0) { foreach (DataRow rw in dtblFinancial.Rows) { decimal dcBalance = Convert.ToDecimal(rw["Debit"].ToString()); dcDirectExpense += dcBalance; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "13"; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcDirectExpense.ToString(); //----Direct Income dtblFinancial = new DataTable(); dtblFinancial = DsetProfitAndLoss.Tables[3]; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Direct Incomes"; decimal dcDirectIncoome = 0m; if (dtblFinancial.Rows.Count > 0) { foreach (DataRow rw in dtblFinancial.Rows) { decimal dcBalance = Convert.ToDecimal(rw["Credit"].ToString()); dcDirectIncoome += dcBalance; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "12"; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcDirectIncoome.ToString(); dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________"; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________"; dgvProfitAndLoss.Rows.Add(); decimal dcTotalExpense = 0; decimal dcTotalIncome = 0; dcTotalExpense = dcOpeningStock + dcPurchaseAccount + dcDirectExpense; dcTotalIncome = dcClosingStock + dcSalesAccount + dcDirectIncoome; dcTotalExpense = Math.Round(dcTotalExpense, inDecimalPlaces); dcTotalIncome = Math.Round(dcTotalIncome, inDecimalPlaces); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].DefaultCellStyle.Font = newFont; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Total"; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Total"; decimal dcGrossProfit = 0; decimal dcGrossLoss = 0; if (dcTotalExpense > dcTotalIncome) { dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalExpense.ToString(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalExpense.ToString(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Value = "Gross Loss b/d "; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Value = dcTotalExpense - dcTotalIncome; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Style.ForeColor = Color.Red; dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Gross Loss b/d "; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalExpense - dcTotalIncome; dcGrossLoss = dcTotalExpense - dcTotalIncome; } else { dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcTotalIncome.ToString(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalIncome.ToString(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Value = "Gross Profit c/d "; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Value = dcTotalIncome - dcTotalExpense; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Style.ForeColor = Color.Green; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Style.ForeColor = Color.Green; dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Gross Profit c/d "; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcTotalIncome - dcTotalExpense; dcGrossProfit = dcTotalIncome - dcTotalExpense; } dgvProfitAndLoss.Rows.Add(); ///------Indirect Expense dtblFinancial = new DataTable(); dtblFinancial = DsetProfitAndLoss.Tables[4]; dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Indirect Expenses"; decimal dcIndirectExpense = 0; if (dtblFinancial.Rows.Count > 0) { foreach (DataRow rw in dtblFinancial.Rows) { decimal dcBalance = Convert.ToDecimal(rw["Debit"].ToString()); dcIndirectExpense += dcBalance; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId1"].Value = "15"; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcIndirectExpense.ToString(); ///---Indirect Income dtblFinancial = new DataTable(); dtblFinancial = DsetProfitAndLoss.Tables[5]; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Indirect Incomes"; decimal dcIndirectIncome = 0m; if (dtblFinancial.Rows.Count > 0) { foreach (DataRow rw in dtblFinancial.Rows) { decimal dcBalance = Convert.ToDecimal(rw["Credit"].ToString()); dcIndirectIncome += dcBalance; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtGroupId2"].Value = "14"; } dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcIndirectIncome.ToString(); //---- Calculating Grand total decimal dcGrandTotalExpense = dcGrossLoss + dcIndirectExpense; decimal dcGrandTotalIncome = dcGrossProfit + dcIndirectIncome; dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = "_______________________"; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = "_______________________"; dgvProfitAndLoss.Rows.Add(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtExpenses"].Value = "Grand Total"; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtIncome"].Value = "Grand Total"; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].DefaultCellStyle.Font = newFont; if (dcGrandTotalExpense > dcGrandTotalIncome) { dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcGrandTotalExpense.ToString(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcGrandTotalExpense.ToString(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Value = "Net Loss "; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Value = dcGrandTotalExpense - dcGrandTotalIncome; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtIncome"].Style.ForeColor = Color.Red; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount2"].Style.ForeColor = Color.Red; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].DefaultCellStyle.Font = newFont; decgranExTotal = dcGrandTotalExpense; } else { dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount1"].Value = dcGrandTotalIncome.ToString(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 1].Cells["dgvtxtAmount2"].Value = dcGrandTotalIncome.ToString(); dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Value = "Net Profit"; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Value = dcGrandTotalIncome - dcGrandTotalExpense; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtExpenses"].Style.ForeColor = Color.Green; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].Cells["dgvtxtAmount1"].Style.ForeColor = Color.Green; dgvProfitAndLoss.Rows[dgvProfitAndLoss.Rows.Count - 3].DefaultCellStyle.Font = newFont; decgranIncTotal = dcGrandTotalIncome; } if (dgvProfitAndLoss.Columns.Count > 0) { dgvProfitAndLoss.Columns["dgvtxtAmount1"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; dgvProfitAndLoss.Columns["dgvtxtAmount2"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight; } if (inCurrenRowIndex >= 0 && dgvProfitAndLoss.Rows.Count > 0 && inCurrenRowIndex < dgvProfitAndLoss.Rows.Count) { if (dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells[inCurrentColunIndex].Visible) { dgvProfitAndLoss.CurrentCell = dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells[inCurrentColunIndex]; } else { dgvProfitAndLoss.CurrentCell = dgvProfitAndLoss.Rows[inCurrenRowIndex].Cells["dgvtxtExpenses"]; } dgvProfitAndLoss.CurrentCell.Selected = true; } inCurrenRowIndex = 0; } } catch (Exception ex) { MessageBox.Show("PAL :01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }