/// <summary> /// Function to generate voucherNo /// </summary> public void VoucherNumberGeneration() { try { TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll(); MaterialReceiptBll bllMaterialReceiptMaster = new MaterialReceiptBll(); if (strVoucherNo == string.Empty) { strVoucherNo = "0"; } strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMaterialReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); if (Convert.ToDecimal(strVoucherNo) != bllMaterialReceiptMaster.MaterialReceiptMasterGetMaxPlusOne(decMaterialReceiptVoucherTypeId)) { strVoucherNo = bllMaterialReceiptMaster.MaterialReceiptMasterGetMax(decMaterialReceiptVoucherTypeId).ToString(); strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMaterialReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); if (bllMaterialReceiptMaster.MaterialReceiptMasterGetMax(decMaterialReceiptVoucherTypeId) == "0") { strVoucherNo = "0"; strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMaterialReceiptVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName); } } if (isAutomatic) { SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decMaterialReceiptVoucherTypeId, dtpDate.Value); strPrefix = infoSuffixPrefix.Prefix; strSuffix = infoSuffixPrefix.Suffix; decMaterialReceiptSuffixPrefixId = infoSuffixPrefix.SuffixprefixId; strReceiptNo = strPrefix + strVoucherNo + strSuffix; txtReceiptNo.Text = strReceiptNo; txtReceiptNo.ReadOnly = true; } } catch (Exception ex) { MessageBox.Show("MR1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }