/// <summary>
 /// Function to fill Accountledger combobox
 /// </summary>
 private void AccountLedgerComboFill()
 {
     try
     {
         TransactionsGeneralFillBll TransactionsGeneralFillObj = new TransactionsGeneralFillBll();
         TransactionsGeneralFillObj.CashOrPartyComboFill(cmbAccountLedger, true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("ODPO:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Cash/Party combobox
 /// </summary>
 public void CashOrPartyComboFill()
 {
     try
     {
         TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll();
         TransactionGeneralFillObj.CashOrPartyUnderSundryDrComboFill(cmbCashOrParty, true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("DNREG01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 ///  Function to fill Cash Or Party combobox
 /// </summary>
 public void CashOrPartyComboFill()
 {
     try
     {
         TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll();
         isDontExecuteCashorParty = true;
         TransactionGeneralFillObj.CashOrPartyComboFill(cmbCashOrParty, true);
         isDontExecuteCashorParty = false;
     }
     catch (Exception ex)
     {
         MessageBox.Show("MRR3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 //PopUp
 /// <summary>
 /// Function to call frmLedgerPopup form to select and view ledgers
 /// </summary>
 /// <param name="frmLedgerPopup"></param>
 /// <param name="decId"></param>
 public void CallFromLedgerPopup(frmLedgerPopup frmLedgerPopup, decimal decId)
 {
     try
     {
         base.Show();
         this.frmLedgerPopupObj = frmLedgerPopup;
         TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
         obj.CashOrBankComboFill(cmbCashBankAC, false);
         cmbCashBankAC.SelectedValue = decId;
         cmbCashBankAC.Focus();
         frmLedgerPopupObj.Close();
         frmLedgerPopupObj = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSR4:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// BankAccount Combobox fill function
        /// </summary>
        public void bankAccountComboFill()
        {
            try
            {
                List<DataTable> listObj = new List<DataTable>();
                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                listObj = obj.BankComboFill();
                cmbBankAccount.DataSource = listObj[0];
                cmbBankAccount.ValueMember = "ledgerId";
                cmbBankAccount.DisplayMember = "ledgerName";
                cmbBankAccount.SelectedIndex = -1;
            }
            catch (Exception ex)
            {

                MessageBox.Show("BR:2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill AccountLedger combobox
 /// </summary>
 public void AccountLedgerComboFill()
 {
     try
     {
         List<DataTable> ListObj = new List<DataTable>();
         TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
         ListObj = obj.AccountLedgerComboFill();
         DataRow dr = ListObj[0].NewRow();
         dr[0] = 0;
         dr[2] = "All";
         ListObj[0].Rows.InsertAt(dr, 0);
         cmbLedger.DataSource = ListObj[0];
         cmbLedger.ValueMember = "ledgerId";
         cmbLedger.DisplayMember = "ledgerName";
         cmbLedger.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show("RRP3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill Bank/Cash combobox
 /// </summary>
 public void BankOrCashComboFill()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         TransactionsGeneralFillBll Obj = new TransactionsGeneralFillBll();
         listObj = Obj.BankOrCashComboFill(false);
         DataRow dr = listObj[0].NewRow();
         dr[1] = 0;
         dr[0] = "All";
         listObj[0].Rows.InsertAt(dr, 0);
         cmbBankOrCash.DataSource = listObj[0];
         cmbBankOrCash.ValueMember = "ledgerId";
         cmbBankOrCash.DisplayMember = "ledgerName";
         cmbBankOrCash.SelectedIndex = 0;
     }
     catch (Exception ex)
     {
         MessageBox.Show("CR:1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Here fill the currency combobox in the grid
 /// </summary>
 public void GridCurrencyComboFill()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll();
         listObj = TransactionGeneralFillObj.CurrencyComboByDate(Convert.ToDateTime(dtpContraVoucherDate.Value));
         dgvcmbCurrency.DataSource = listObj[0];
         DataRow drow = listObj[0].NewRow();
         drow["currencyName"] = string.Empty;
         drow["exchangeRateId"] = 0;
         listObj[0].Rows.InsertAt(drow, 0);
         dgvcmbCurrency.DisplayMember = "currencyName";
         dgvcmbCurrency.ValueMember = "exchangeRateId";
     }
     catch (Exception ex)
     {
         MessageBox.Show("CV:03" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 //PopUp
 /// <summary>
 /// Its the function for find and select purticular cash or bank ledger in a popup window
 /// </summary>
 /// <param name="frmLedgerPopup"></param>
 /// <param name="decId"></param>
 /// <param name="strComboTypes"></param>
 public void CallFromLedgerPopup(frmLedgerPopup frmLedgerPopup, decimal decId, string strComboTypes)
 {
     try
     {
         base.Show();
         this.frmLedgerPopupObj = frmLedgerPopup;
         if (strComboTypes == "CashOrBank")
         {
             TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
             obj.CashOrBankComboFill(cmbBankAccount, false);
             cmbBankAccount.SelectedValue = decId;
         }
         else
         {
             dgvContraVoucher.CurrentRow.Cells["dgvcmbBankorCashAccount"].Value = decId;
         }
         frmLedgerPopupObj.Close();
         frmLedgerPopupObj = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show("CV:11" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// These function for generating the voucher no automatically if its automatic with preffix and sufix
        /// </summary>
        public void VoucherNumberGeneration()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                //ContraMasterSP spContraMaster = new ContraMasterSP();
                ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll();
                if (strVoucherNo == string.Empty)
                {
                    strVoucherNo = "0";
                }
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecContraVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpContraVoucherDate.Value, tableName);
                if (Convert.ToDecimal(strVoucherNo) != bllContraVoucherDetails.ContraVoucherMasterGetMaxPlusOne(DecContraVoucherTypeId))
                {
                    strVoucherNo = bllContraVoucherDetails.ContraVoucherMasterGetMax(DecContraVoucherTypeId).ToString();
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecContraVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpContraVoucherDate.Value, tableName);
                    if (bllContraVoucherDetails.ContraVoucherMasterGetMax(DecContraVoucherTypeId) == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecContraVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpContraVoucherDate.Value, tableName);
                    }
                }
                if (isAutomatic)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecContraVoucherTypeId, dtpContraVoucherDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decContraSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:08" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to fill cash/Bank combobox while return from AccountLedger when creating new ledger 
        /// </summary>
        /// <param name="decId"></param>
        public void ReturnFromAccountLedgerForm(decimal decId)
        {
            try
            {
                TransactionsGeneralFillBll Obj = new TransactionsGeneralFillBll();
                Obj.CashOrBankComboFill(cmbCashOrBankAcc, false);
                cmbCashOrBankAcc.SelectedValue = decId.ToString();
                this.Enabled = true;
                cmbCashOrBankAcc.Focus();

            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to reset the form to make new service voucher
        /// </summary>
        public void Clear()
        {
            try
            {
                /*Automatic invoice number generation*/
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                VoucherDate();
                if (isAutomatic)    //  Checking voucher number generation is automatic or not
                {
                    ServicesBll BllService = new ServicesBll();
                    ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll();
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecServicetVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    if (Convert.ToDecimal(strVoucherNo) != (BllService.ServiceMasterGetMax(DecServicetVoucherTypeId)) + 1)
                    {
                        strVoucherNo = BllService.ServiceMasterGetMax(DecServicetVoucherTypeId).ToString();
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecServicetVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                        if (BllService.ServiceMasterGetMax(DecServicetVoucherTypeId) == 0)
                        {
                            strVoucherNo = "0";
                            strVoucherNo = obj.VoucherNumberAutomaicGeneration(DecServicetVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                        }
                    }
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecServicetVoucherTypeId, dtpVoucherDate.Value);   //  Getting suffix-prefix settings
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    decServiceSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;    // Generating invoice number with suffix and prefix
                    txtInvoiceNumber.Text = strInvoiceNo;
                    txtInvoiceNumber.ReadOnly = true;
                    txtVoucherDate.Select();
                }
                else
                {
                    txtInvoiceNumber.Text = string.Empty;
                    txtInvoiceNumber.ReadOnly = false;
                }
                ServiceAcoountComboFill();
                GridParticularComboFill();
                SalesmanComboFill();
                CashOrPartyComboFill();
                isEditMode = false;
                txtDiscount.Text = "0";
                txtTotalAmount.Text = "0";
                txtGrandTotal.Text = "0";
                txtCreditPeriod.Text = "0";
                txtCustomer.Text = string.Empty;
                txtNarration.Text = string.Empty;
                PrintCheck();
                int inCount = dgvServiceVoucher.RowCount;
                for (int i = 0; i < inCount; i++)
                {
                    dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value = null;
                    dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value = null;
                    dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value = null;
                }
                dgvServiceVoucher.ClearSelection();
                btnDelete.Enabled = false;
                btnSave.Text = "Save";
                dgvServiceVoucher.Rows.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("SV 04 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// salesman fill
 /// </summary>
 public void ComboSalesManFill()
 {
     TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll();
     try
     {
        transactionGeneralFillObj.SalesmanViewAllForComboFill(cmbSalesman, false);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:03" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to generate Voucher number as per settings
 /// </summary>
 public void VoucherNumberGeneration()
 {
     SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
     TransactionsGeneralFillBll TransactionGenerateFillObj = new TransactionsGeneralFillBll();
     DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll();
     string tableName = "DeliveryNoteMaster";
     string strPrefix = string.Empty;
     string strSuffix = string.Empty;
     try
     {
         strVoucherNo = "0";
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = TransactionGenerateFillObj.VoucherNumberAutomaicGeneration(decDeliveryNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
         if (Convert.ToDecimal(strVoucherNo) != bllDeliveryNote.DeliveryNoteMasterGetMaxPlusOne(decDeliveryNoteVoucherTypeId))
         {
             strVoucherNo = bllDeliveryNote.DeliveryNoteMasterMax1(decDeliveryNoteVoucherTypeId).ToString();
             strVoucherNo = TransactionGenerateFillObj.VoucherNumberAutomaicGeneration(decDeliveryNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             if (bllDeliveryNote.DeliveryNoteMasterMax1(decDeliveryNoteVoucherTypeId) == "0")
             {
                 strVoucherNo = "0";
                 strVoucherNo = TransactionGenerateFillObj.VoucherNumberAutomaicGeneration(decDeliveryNoteVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, tableName);
             }
         }
         if (isAutomatic)
         {
             infoSuffixPrefix = new SuffixPrefixSettingsBll().GetSuffixPrefixDetails(decDeliveryNoteVoucherTypeId, dtpDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             decDeliveryNoteSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
             strDeliveryNoteNo = strPrefix + strVoucherNo + strSuffix;
             txtDeliveryNoteNo.Text = strDeliveryNoteNo;
             txtDeliveryNoteNo.ReadOnly = true;
         }
         else
         {
             txtDeliveryNoteNo.Text = string.Empty;
             strDeliveryNoteNo = txtDeliveryNoteNo.Text.Trim();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN09:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Pricing Level Combo Fill
 /// </summary>
 public void PricingLevelComboFill()
 {
     TransactionsGeneralFillBll TransactionGenerateFillObj = new TransactionsGeneralFillBll();
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         listObj = TransactionGenerateFillObj.PricingLevelViewAll(cmbPricingLevel, true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN06: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Currency combo fill
 /// </summary>
 public void ComboCurrencyFill()
 {
     TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll();
     SettingsBll BllSettings = new SettingsBll();
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         listObj = transactionGeneralFillObj.CurrencyComboByDate(Convert.ToDateTime(txtSalesQuotationDate.Text));
         cmbCurrency.DataSource = listObj[0];
         cmbCurrency.DisplayMember = "currencyName";
         cmbCurrency.ValueMember = "exchangeRateId";
         cmbCurrency.SelectedValue = 1m;
         DataRow dr = listObj[0].NewRow();
         if (BllSettings.SettingsStatusCheck("MultiCurrency") == "Yes")
         {
             cmbCurrency.Enabled = true;
         }
         else
         {
             cmbCurrency.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:13" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Cleare function and Generate the voucher no based on settings
        /// </summary>
        public void Clear()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                //SalesMasterSP spSalesMaster = new SalesMasterSP();
                SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll();
                if (isAutomatic)
                {
                    if (strVoucherNo == string.Empty)
                    {
                        strVoucherNo = "0";
                    }
                    strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                    if (Convert.ToDecimal(strVoucherNo) != (BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId)))
                    {
                        strVoucherNo = BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId).ToString();
                        strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                        if (BllSalesInvoice.SalesMasterVoucherMax(DecSalesInvoiceVoucherTypeId) == 0)
                        {
                            strVoucherNo = "0";
                            strVoucherNo = TransactionGeneralFillObj.VoucherNumberAutomaicGeneration(DecSalesInvoiceVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpDate.Value, "SalesMaster");
                        }
                    }
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                   // SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecSalesInvoiceVoucherTypeId, dtpDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtInvoiceNo.Text = strInvoiceNo;
                    txtInvoiceNo.ReadOnly = true;
                    decSalseInvoiceSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                }
                else
                {
                    txtInvoiceNo.ReadOnly = false;
                    txtInvoiceNo.Text = string.Empty;
                    strVoucherNo = string.Empty;
                    strInvoiceNo = strVoucherNo;
                }
                if (PrintAfetrSave())
                {
                    cbxPrintAfterSave.Checked = true;
                }
                else
                {
                    cbxPrintAfterSave.Checked = false;
                }
                cmbPricingLevel.SelectedIndex = 0;
                cmbSalesAccount.SelectedIndex = 0;
                cmbCashOrParty.SelectedIndex = 0;
                cmbSalesMan.SelectedIndex = 0;
                cmbSalesMode.SelectedIndex = 0;
                cmbDrorCr.SelectedIndex = 0;
                cmbCashOrbank.SelectedIndex = 0;
                cmbCurrency.Enabled = true;
                txtCustomer.Text = cmbCashOrParty.Text;
                txtTransportCompany.Text = string.Empty;
                txtVehicleNo.Text = string.Empty;
                txtNarration.Text = string.Empty;
                txtCreditPeriod.Text = "0";
                txtTotalAmount.Text = "0.00";
                txtBillDiscount.Text = "0";
                txtGrandTotal.Text = "0.00";
                lblTaxTotalAmount.Text = "0.00";
                lblLedgerTotalAmount.Text = "0.00";
                btnSave.Text = "Save";
                btnDelete.Enabled = false;
                dtpDate.MinDate = PublicVariables._dtFromDate;
                dtpDate.MaxDate = PublicVariables._dtToDate;
                dtpDate.Value = PublicVariables._dtCurrentDate;
                txtDate.Text = dtpDate.Value.ToString("dd-MMM-yyyy");
                dgvSalesInvoiceLedger.Rows.Clear();
                isFromEditMode = false;
                if (dgvSalesInvoice.DataSource != null)
                {
                    ((DataTable)dgvSalesInvoice.DataSource).Rows.Clear();
                }
                else
                {
                    dgvSalesInvoice.Rows.Clear();
                }
                gridCombofill();
                if (dgvSalesInvoiceTax.DataSource != null)
                {
                    ((DataTable)dgvSalesInvoiceTax.DataSource).Rows.Clear();
                }
                else
                {
                    dgvSalesInvoiceTax.Rows.Clear();
                }
                taxGridFill();
                if (!txtInvoiceNo.ReadOnly)
                {
                    txtInvoiceNo.Focus();
                }
                else
                {
                    txtDate.Select();
                }

                txtTotalAmount.Text = "0.00";
                txtGrandTotal.Text = "0.00";
                lblTotalQuantitydisplay.Text = "0";
            }
            catch (Exception ex)
            {
                MessageBox.Show("SI : 01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to fill the details for edit or delete
        /// </summary>
        public void FillRegisterOrReport()
        {
            SalesQuotationBll bllSalesQuotation = new SalesQuotationBll();
            TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll();
            SalesQuotationMasterInfo infoSalesQuotationMaster = new SalesQuotationMasterInfo();
            ProductCreationBll BllProductCreation = new ProductCreationBll();
            try
            {
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                IsDoAfterFill = false;
                IsCellValue = false;
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                infoSalesQuotationMaster =bllSalesQuotation.SalesQuotationMasterView(decSalesquotationMasterId);
                txtQuotationNo.Text = infoSalesQuotationMaster.InvoiceNo;
                strVoucherNo = infoSalesQuotationMaster.VoucherNo.ToString();
                decSalesQuotationPreffixSuffixId = Convert.ToDecimal(infoSalesQuotationMaster.SuffixPrefixId);
                decSalesQuotationVoucherId = Convert.ToDecimal(infoSalesQuotationMaster.VoucherTypeId);
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decSalesQuotationVoucherId);
                decsalesQuotationTypeId = decSalesQuotationVoucherId;
                txtSalesQuotationDate.Text = infoSalesQuotationMaster.Date.ToString("dd-MMM-yyyy");
                cmbCashOrParty.SelectedValue = infoSalesQuotationMaster.LedgerId;
                ComboSalesManFill();
                cmbSalesman.SelectedValue = infoSalesQuotationMaster.EmployeeId;
                txtNarration.Text = infoSalesQuotationMaster.Narration;
                cmbCurrency.SelectedValue = infoSalesQuotationMaster.ExchangeRateId;
                decimal decsalesregisterTotal = Convert.ToDecimal(infoSalesQuotationMaster.TotalAmount.ToString());
                decsalesregisterTotal = Math.Round(decsalesregisterTotal, PublicVariables._inNoOfDecimalPlaces);
                txtTotal.Text = Convert.ToString(decsalesregisterTotal);
                cmbPricinglevel.SelectedValue = infoSalesQuotationMaster.PricinglevelId;
                List<DataTable> ListObj = new List<DataTable>();
                ListObj = bllSalesQuotation.SalesQuotationDetailsViewByMasterId(decSalesquotationMasterId);
                if (isAutomatic)
                {
                    txtQuotationNo.ReadOnly = true;
                    txtSalesQuotationDate.Focus();
                }
                else
                {
                    txtQuotationNo.ReadOnly = false;
                    txtQuotationNo.Focus();
                }
                string strApproved = Convert.ToString(infoSalesQuotationMaster.Approved);
                if (strApproved == "False")
                {
                    cbxApproved.Checked = false;
                }
                else
                {
                    cbxApproved.Checked = true;
                }

                decimal decCount = bllSalesQuotation.CheckingStastusForSalesQuotation(decSalesquotationMasterId);
                if (decCount > 0)
                {
                    cbxApproved.Enabled = false;
                }
                else
                {
                    cbxApproved.Enabled = true;
                }
                for (int i = 0; i < ListObj[0].Rows.Count; i++)
                {
                    isAmountcalc = false;

                    dgvProduct.Rows.Add();

                    dgvProduct.Rows[i].HeaderCell.Value = string.Empty;
                    dgvProduct.Rows[i].Cells["dgvtxtQuotationDetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["quotationDetailsId"].ToString());
                    dgvProduct.Rows[i].Cells["ProductId"].Value = ListObj[0].Rows[i]["productId"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtBarcode"].Value = ListObj[0].Rows[i]["Barcode"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString();
                    transactionGeneralFillObj.UnitViewAllByProductId(dgvProduct, ListObj[0].Rows[i]["productId"].ToString(), i);
                    bllSalesQuotation.SalesQuotationMasterBatchFill(dgvProduct, Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString()), i);
                    dgvProduct.Rows[i].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[i]["productName"].ToString();
                    dgvProduct.Rows[i].Cells["dgvtxtQty"].Value = ListObj[0].Rows[i]["qty"].ToString();
                    IsCellValue = true;
                    dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitId"].ToString());
                    IsCellValue = false;
                    dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = ListObj[0].Rows[i]["rate"].ToString();
                    IsCellValue = true;
                    dgvProduct.Rows[i].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[i]["amount"].ToString();
                    IsCellValue = false;
                    dgvProduct.Rows[i].Cells["dgvcmbbatch"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString());

                    UnitConvertionBll bllUnitConvertion = new UnitConvertionBll();
                    List<DataTable> listUnitByProduct = bllUnitConvertion.UnitConversionIdAndConRateViewallByProductId(dgvProduct.Rows[i].Cells["ProductId"].Value.ToString());
                    if (listUnitByProduct[0].Rows.Count > 0)
                    {
                        foreach (DataRow drUnitByProduct in listUnitByProduct[0].Rows)
                        {
                            if (dgvProduct.Rows[i].Cells["dgvcmbUnit"].Value.ToString() == drUnitByProduct.ItemArray[0].ToString())
                            {
                                dgvProduct.Rows[i].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[2].ToString());
                                dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value = Convert.ToDecimal(drUnitByProduct.ItemArray[3].ToString());

                            }
                        }
                    }

                    decimal decStandardRate = BllProductCreation.SalesInvoiceProductRateForSales(Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString()), PublicVariables._dtCurrentDate, Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString()), Convert.ToDecimal(cmbPricinglevel.SelectedValue), PublicVariables._inNoOfDecimalPlaces);
                    if (dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value != null && dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value.ToString() != string.Empty)
                    {
                        if (decStandardRate != 0 && Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value) != 0)
                        {
                            dgvProduct.Rows[i].Cells["dgvtxtRate"].Value = Math.Round(decStandardRate / Convert.ToDecimal(dgvProduct.Rows[i].Cells["dgvtxtConversionRate"].Value), PublicVariables._inNoOfDecimalPlaces);
                        }
                    }

                }
                isAmountcalc = true;
                IsCellValue = true;
                IsDoAfterFill = true;

            }
            catch (Exception ex)
            {
                MessageBox.Show("SQ:39" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Combofill function of Cash or Bank
 /// </summary>
 /// <param name="cmbBankOrcash"></param>
 public void BankOrCashComboFill(ComboBox cmbBankOrcash)
 {
     try
     {
         TransactionsGeneralFillBll Obj = new TransactionsGeneralFillBll();
         Obj.CashOrBankComboFill(cmbBankOrcash, false);
     }
     catch (Exception ex)
     {
         MessageBox.Show("CV:01" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the salesman combobox
 /// </summary>
 public void SalesmanComboFill()
 {
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         EmployeeCreationBll BllEmployeeCreation = new EmployeeCreationBll();
         TransactionsGeneralFillBll TransactiongeneralFillObj = new TransactionsGeneralFillBll();
         listObj = TransactiongeneralFillObj.SalesmanViewAllForComboFill(cmbSalesman, false);
         cmbSalesman.DataSource = listObj[0];
         cmbSalesman.DisplayMember = "employeeName";
         cmbSalesman.ValueMember = "employeeId";
         cmbSalesman.SelectedValue = -1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 06 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Voucher no generation function based on the settings
 /// </summary>
 public void VoucherNumberGeneration()
 {
     try
     {
         TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
         PDCRecivebleBll BllPdcRecieveble = new PDCRecivebleBll();
         if (strVoucherNo == string.Empty)
         {
             strVoucherNo = "0";
         }
         strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCReceivableVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
         if (Convert.ToDecimal(strVoucherNo) != BllPdcRecieveble.PDCReceivableMaxUnderVoucherTypePlusOne(decPDCReceivableVoucherTypeId))
         {
             strVoucherNo = BllPdcRecieveble.PDCReceivableMaxUnderVoucherType(decPDCReceivableVoucherTypeId).ToString();
             strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCReceivableVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
             if (BllPdcRecieveble.PDCReceivableMaxUnderVoucherType(decPDCReceivableVoucherTypeId).ToString() == "0")
             {
                 strVoucherNo = "0";
                 strVoucherNo = obj.VoucherNumberAutomaicGeneration(decPDCReceivableVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, strtableName);
             }
         }
         if (isAutomatic)
         {
             SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
             SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
             infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPDCReceivableVoucherTypeId, dtpVoucherDate.Value);
             strPrefix = infoSuffixPrefix.Prefix;
             strSuffix = infoSuffixPrefix.Suffix;
             decSufixprefixPdcReceivableID = infoSuffixPrefix.SuffixprefixId;
             strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
             txtVoucherNo.Text = strInvoiceNo;
             txtVoucherNo.ReadOnly = true;
             txtVoucherNo.Enabled = false;
             lblVoucherNoManualValidator.Visible = false;
         }
         else
         {
             txtVoucherNo.ReadOnly = false;
             txtVoucherNo.Text = string.Empty;
             lblVoucherNoManualValidator.Visible = true;
             strInvoiceNo = txtVoucherNo.Text.Trim();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR17:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// PricingLevel combo fill
 /// </summary>
 public void ComboPricingLevelFill()
 {
     TransactionsGeneralFillBll transactionGeneralFillObj = new TransactionsGeneralFillBll();
     try
     {
         transactionGeneralFillObj.PricingLevelViewAll(cmbPricinglevel, false);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SQ:04" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// SalesMan Combofill Function
 /// </summary>
 public void SalesManComboFill()
 {
     TransactionsGeneralFillBll TransactionGenerateFillObj = new TransactionsGeneralFillBll();
     try
     {
         List<DataTable> listObj = new List<DataTable>();
         listObj = TransactionGenerateFillObj.SalesmanViewAllForComboFill(cmbSalesMan, false);
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN05: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to reset form
 /// </summary>
 public void Clear()
 {
     try
     {
         txtVoucherDateFrom.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         txtVoucherDateTo.Text = PublicVariables._dtCurrentDate.ToString("dd-MMM-yyyy");
         dtpVoucherDateFrom.Value = PublicVariables._dtCurrentDate;
         dtpVoucherDateFrom.MinDate = PublicVariables._dtFromDate;
         dtpVoucherDateFrom.MaxDate = PublicVariables._dtToDate;
         dtpVoucherDateTo.Value = PublicVariables._dtCurrentDate;
         dtpVoucherDateTo.MinDate = PublicVariables._dtFromDate;
         dtpVoucherDateTo.MaxDate = PublicVariables._dtToDate;
         dtpSalaryMonth.Value = PublicVariables._dtCurrentDate;
         dtpSalaryMonth.MinDate = PublicVariables._dtFromDate;
         dtpSalaryMonth.MaxDate = PublicVariables._dtToDate;
         txtVoucherNo.Clear();
         cmbVoucherTypeName.SelectedIndex = -1;
         VoucherTypeNameComboFill();
         TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
         obj.CashOrBankComboFill(cmbCashBankAC, false);
         cmbCashBankAC.SelectedIndex = -1;
         GridFill();
     }
     catch (Exception ex)
     {
         MessageBox.Show("MSR3:" + 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>
        /// Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmDailySalaryVoucher_Load(object sender, EventArgs e)
        {
            try
            {

                txtVoucherNo.Select();
                dtpDate.Value = PublicVariables._dtCurrentDate;
                dtpDate.MinDate = PublicVariables._dtFromDate;
                dtpDate.MaxDate = PublicVariables._dtToDate;
                dtpDate.CustomFormat = "dd-MMMM-yyyy";

                dtpSalaryDate.Value = PublicVariables._dtCurrentDate;
                dtpSalaryDate.MinDate = PublicVariables._dtFromDate;
                dtpSalaryDate.MaxDate = PublicVariables._dtToDate;

                TransactionsGeneralFillBll Obj = new TransactionsGeneralFillBll();
                Obj.CashOrBankComboFill(cmbCashorBankAccount, false);
                if (isEditmode == false)
                {
                    Clear();
                }

                DailySalaryVoucherDetailsGridfill(isEditmode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV18:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill the CashOrParty combo box
 /// </summary>
 public void CashOrPartyComboFill()
 {
     try
     {
         TransactionsGeneralFillBll TransactionGeneralFillObj = new TransactionsGeneralFillBll();
         TransactionGeneralFillObj.CashOrPartyUnderSundryDrComboFill(cmbCashParty, false);
         cmbCashParty.SelectedValue = 1;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 08 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to generate the voucher number as per settings
        /// </summary>
        public void voucherNumberGeneration()
        {
            try
            {
                TransactionsGeneralFillBll obj = new TransactionsGeneralFillBll();
                SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();
                //-----------------------------------------Voucher number Automatic generation ------------------------------------------------//
                if (strVoucherNo == string.Empty)
                {

                   strVoucherNo = "0";
                }
                strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                if (Convert.ToDecimal(strVoucherNo) != BllSalaryVoucher.SalaryVoucherMasterGetMaxPlusOne(decMonthlyVoucherTypeId))
                {
                    strVoucherNo = BllSalaryVoucher.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId).ToString();
                    strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    if (BllSalaryVoucher.SalaryVoucherMasterGetMax(decMonthlyVoucherTypeId) == "0")
                    {
                        strVoucherNo = "0";
                        strVoucherNo = obj.VoucherNumberAutomaicGeneration(decMonthlyVoucherTypeId, Convert.ToDecimal(strVoucherNo), dtpVoucherDate.Value, tableName);
                    }
                }
                if (isAutomatic)
                {
                    SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                    SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                    infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decMonthlyVoucherTypeId, dtpVoucherDate.Value);
                    strPrefix = infoSuffixPrefix.Prefix;
                    strSuffix = infoSuffixPrefix.Suffix;
                    strInvoiceNo = strPrefix + strVoucherNo + strSuffix;
                    txtVoucherNo.Text = strInvoiceNo;
                    txtVoucherNo.ReadOnly = true;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV14:" + 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>
        /// Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmMonthlySalaryVoucher_Load(object sender, EventArgs e)
        {
            try
            {
                lblCashOrBankIndicator.Visible = true;
                lblVoucherDateIndicator.Visible = true;
                lblVoucherNoIndicator.Visible = true;
                TransactionsGeneralFillBll Obj = new TransactionsGeneralFillBll();
                Obj.CashOrBankComboFill(cmbCashOrBankAcc, false);
                dtpMonth.Value = PublicVariables._dtCurrentDate;
                dtpMonth.MinDate = PublicVariables._dtFromDate;
                dtpMonth.MaxDate = PublicVariables._dtToDate;
                dtpVoucherDate.Value = PublicVariables._dtCurrentDate;
                dtpVoucherDate.MinDate = PublicVariables._dtFromDate;
                dtpVoucherDate.MaxDate = PublicVariables._dtToDate;
                dtpVoucherDate.CustomFormat = "dd-MMMM-yyyy";

                if (isEditMode == false)
                {
                    Clear();
                }
                GridFill(isEditMode);

            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV19:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }