/// <summary> /// Function to use the voucherno Automatic generation /// </summary> public void VoucherNumberGeneration() { string strTableName = "SalesOrderMaster"; string strPrefix = string.Empty; string strSuffix = string.Empty; string strInvoiceNo = string.Empty; try { SalesOrderBll bllSalesOrder = new SalesOrderBll(); TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll(); if (isAutomatic) { strVoucherNo = "0"; if (strVoucherNo == string.Empty) { strVoucherNo = "0"; //strMax; } strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decSalesOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName); if (Convert.ToDecimal(strVoucherNo) != bllSalesOrder.SalesOrderVoucherMasterMaxPlusOne(decSalesOrderTypeId)) { strVoucherNo = bllSalesOrder.SalesOrderVoucherMasterMax(decSalesOrderTypeId).ToString(); strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decSalesOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName); if (bllSalesOrder.SalesOrderVoucherMasterMax(decSalesOrderTypeId).ToString() == "0") { strVoucherNo = "0"; strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(decSalesOrderTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, strTableName); } } if (isAutomatic) { SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll(); SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo(); infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decSalesOrderTypeId, dtpDate.Value); strPrefix = infoSuffixPrefix.Prefix; strSuffix = infoSuffixPrefix.Suffix; strInvoiceNo = strPrefix + strVoucherNo + strSuffix; txtOrderNo.Text = strInvoiceNo; txtOrderNo.ReadOnly = true; } else { txtOrderNo.ReadOnly = false; txtOrderNo.Text = string.Empty; strInvoiceNo = txtOrderNo.Text.Trim(); } } } catch (Exception ex) { MessageBox.Show("SO40:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information); } }