/// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="decVoucherTypeId"></param>
        /// <param name="strVoucherTypeName"></param>
        public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
        {
            string strSuffix = string.Empty;
            string strPrefix = string.Empty;
            try
            {
                decRejectionInVoucherTypeId = decVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decRejectionInVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                SuffixPrefixInfo InfoSuffixPrefix = new SuffixPrefixInfo();
                InfoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decRejectionInVoucherTypeId, dtpDate.Value);
                decRejectionInSuffixPrefixId = InfoSuffixPrefix.SuffixprefixId;
                strSuffix = InfoSuffixPrefix.Suffix;
                strPrefix = InfoSuffixPrefix.Prefix;
                this.Text = strVoucherTypeName;
                base.Show();

                if (isAutomatic)
                {
                    ClearRejectionIn();
                    VoucherNoGeneration();
                    txtDate.Focus();
                    txtRejectionInNo.ReadOnly = true;
                }
                else
                {
                    txtRejectionInNo.Focus();
                    txtRejectionInNo.ReadOnly = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("RI:30" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// To fill the details according to the DeliveryNote master Id from frmDeliveryNoteRegister and frmDeliveryNoteReport
        /// </summary>
        public void FillRegisterOrReport()
        {
            try
            {
                DeliveryNoteMasterInfo infoDeliveryNoteMaster = new DeliveryNoteMasterInfo();
                VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                //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 bllSalesQuotatin = new SalesQuotationBll();
                dgvProduct.Rows.Clear();
                isRegisterReportFill = true;
                btnSave.Text = "Update";
                int inRowIndex = 0;
                btnDelete.Enabled = true;
                txtDeliveryNoteNo.ReadOnly = true;
                if (txtDeliveryNoteNo.ReadOnly == true)
                {
                    txtDate.Focus();
                }
                else
                {
                    txtDeliveryNoteNo.Focus();
                }

                infoDeliveryNoteMaster = bllDeliveryNote.DeliveryNoteMasterViewAllByMasterId(decDelivryNoteIdToEdit);
                txtDeliveryNoteNo.Text = infoDeliveryNoteMaster.InvoiceNo;
                strVoucherNo = infoDeliveryNoteMaster.VoucherNo.ToString();
                decDeliveryNoteSuffixPrefixId = Convert.ToDecimal(infoDeliveryNoteMaster.SuffixPrefixId);
                decDeliveryNoteVoucherTypeId = Convert.ToDecimal(infoDeliveryNoteMaster.VoucherTypeId);
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDeliveryNoteVoucherTypeId);
                decDeliveryNoteTypeId = decDeliveryNoteVoucherTypeId;
                cmbCashOrParty.SelectedValue = infoDeliveryNoteMaster.LedgerId;
                txtDate.Text = infoDeliveryNoteMaster.Date.ToString("dd-MMM-yyyy");
                cmbPricingLevel.SelectedValue = infoDeliveryNoteMaster.PricinglevelId;
                infoVoucherType = BllVoucherType.VoucherTypeView(decDeliveryNoteVoucherTypeId);
                this.Text = infoVoucherType.VoucherTypeName;
                if (infoDeliveryNoteMaster.OrderMasterId != 0)
                {
                    cmbDeliveryMode.Text = "Against Order";
                    infoSalesOrderMaster = bllSalesOrder.SalesOrderMasterView(infoDeliveryNoteMaster.OrderMasterId);
                    cmbType.SelectedValue = infoSalesOrderMaster.VoucherTypeId;
                    AgainstOrderComboFill();
                    cmbOrderNo.SelectedValue = infoDeliveryNoteMaster.OrderMasterId;
                }
                else if (infoDeliveryNoteMaster.QuotationMasterId != 0)
                {
                    cmbDeliveryMode.Text = "Against Quotation";
                    infoSalesQuotationMaster = bllSalesQuotatin.SalesQuotationMasterView(infoDeliveryNoteMaster.QuotationMasterId);
                    cmbType.SelectedValue = infoSalesQuotationMaster.VoucherTypeId;
                    AgainstQuotationComboFill();
                    cmbOrderNo.SelectedValue = infoDeliveryNoteMaster.QuotationMasterId;
                }
                CurrencyComboFill();
                cmbSalesMan.SelectedValue = infoDeliveryNoteMaster.EmployeeId;
                cmbCurrency.SelectedValue = infoDeliveryNoteMaster.ExchangeRateId;
                txtTraspotationCompany.Text = infoDeliveryNoteMaster.TransportationCompany;
                txtNarration.Text = infoDeliveryNoteMaster.Narration;
                txtLRNo.Text = infoDeliveryNoteMaster.LrNo;
                txtTotalAmnt.Text = infoDeliveryNoteMaster.TotalAmount.ToString("00.00");
                List<DataTable> listObjDetails = bllDeliveryNote.DeliveryNoteDetailsViewByDeliveryNoteMasterId(decDelivryNoteIdToEdit);
                foreach (DataRow drowDetails in listObjDetails[0].Rows)
                {
                    dgvProduct.Rows.Add();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true;
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].Value = drowDetails["barcode"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtDetailsId"].Value = drowDetails["deliveryNoteDetailsId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherNo"].Value = drowDetails["VoucherNo"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtInvoiceNo"].Value = drowDetails["OrderNoOrQuotationNo"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtVoucherTypeId"].Value = drowDetails["VoucherTypeId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductId"].Value = drowDetails["productId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].Value = drowDetails["productCode"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].Value = drowDetails["productName"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["Col"].Value = drowDetails["slNo"].ToString();
                    if (Convert.ToDecimal(drowDetails["orderDetails1Id"].ToString()) == 0)
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = 0;
                    }
                    else
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = Convert.ToDecimal(drowDetails["orderDetails1Id"].ToString());
                    }
                    if (Convert.ToDecimal(drowDetails["quotationDetails1Id"].ToString()) != 0)
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtOrderDetailsId"].Value = Convert.ToDecimal(drowDetails["quotationDetails1Id"].ToString());
                    }
                    BatchComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ColumnIndex);
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drowDetails["batchId"].ToString());
                    UnitComboFill1(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ColumnIndex);
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drowDetails["unitId"].ToString());
                    GridGodownComboFill(Convert.ToDecimal(drowDetails["productId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].ColumnIndex);
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(drowDetails["godownId"].ToString());
                    RackComboFill1(Convert.ToDecimal(drowDetails["godownId"].ToString()), dgvProduct.Rows.Count - 2, dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].ColumnIndex);
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].Value = Convert.ToDecimal(drowDetails["rackId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtQty"].Value = drowDetails["qty"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].Value = drowDetails["rate"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtUnitConversionId"].Value = drowDetails["unitConversionId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtConversionRate"].Value = drowDetails["conversionRate"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtAmount"].Value = drowDetails["amount"].ToString();
                    if (cmbOrderNo.Visible == true)
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true;
                    }
                    if (bllDeliveryNote.DeliveryNoteMasterReferenceCheckRejectionIn(decDelivryNoteIdToEdit))
                    {
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtBarcode"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductCode"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtProductName"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbBatch"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbGodown"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbRack"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvtxtRate"].ReadOnly = true;
                        dgvProduct.Rows[dgvProduct.Rows.Count - 2].Cells["dgvcmbUnit"].ReadOnly = true;
                    }
                    dgvProduct.Rows[dgvProduct.Rows.Count - 2].HeaderCell.Value = "";
                    AmountCalculation("dgvtxtQty", inRowIndex);
                    TotalAmountCalculation();
                }
                if (!isAutomatic)
                {
                    txtDeliveryNoteNo.ReadOnly = false;
                    txtDeliveryNoteNo.Focus();
                }
                isRegisterReportFill = false;
                isDoAfterGridFill = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("DN19: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 //  Invoked from frmVoucherTypeSelection form
 /// <summary>
 /// Function to call this form from VoucherType Selection form
 /// </summary>
 /// <param name="decServiceVoucherTypeId"></param>
 /// <param name="strServiceVoucherTypeName"></param>
 public void CallFromVoucherTypeSelection(decimal decServiceVoucherTypeId, string strServiceVoucherTypeName)
 {
     try
     {
         DecServicetVoucherTypeId = decServiceVoucherTypeId;
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(DecServicetVoucherTypeId);    //  Checking voucher number is automatic or not
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecServicetVoucherTypeId, dtpVoucherDate.Value);
         decServiceSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
         strPrefix = infoSuffixPrefix.Prefix;
         strSuffix = infoSuffixPrefix.Suffix;
         this.Text = strServiceVoucherTypeName;
         base.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 13 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// its a function for vouchertype selection form to select purticular voucher and open the form under the vouchertype
        /// </summary>
        /// <param name="decDailyContraVoucherTypeId"></param>
        /// <param name="strVoucherTypeNames1"></param>
        public void CallFromVoucherTypeSelection(decimal decDailyContraVoucherTypeId, string strVoucherTypeNames1)
        {
            try
            {
                DecContraVoucherTypeId = decDailyContraVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(DecContraVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(DecContraVoucherTypeId, dtpContraVoucherDate.Value);
                decContraSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;
                this.Text = strVoucherTypeNames1;
                base.Show();
                Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:10" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to call this form from VoucherType Selection form
 /// </summary>
 /// <param name="decVoucherTypeId"></param>
 /// <param name="strVoucherTypeName"></param>
 public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
 {
     try
     {
         decPDCReceivableVoucherTypeId = decVoucherTypeId;
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPDCReceivableVoucherTypeId);
         SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPDCReceivableVoucherTypeId, dtpVoucherDate.Value);
         decSufixprefixPdcReceivableID = infoSuffixPrefix.SuffixprefixId;
         this.Text = strVoucherTypeName;
         base.Show();
         if (isAutomatic)
         {
             txtVoucherDate.Focus();
         }
         else
         {
             txtVoucherNo.Focus();
         }
         ClearFunction();
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR15:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="decDailySalaryVoucherTypeId"></param>
        /// <param name="strVoucherTypeNames1"></param>
        public void CallFromVoucherTypeSelection(decimal decDailySalaryVoucherTypeId, string strVoucherTypeNames1)
        {
            try
            {
                decDailyVoucherTypeId = decDailySalaryVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDailyVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
               // SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decDailyVoucherTypeId, dtpDate.Value);
                decDailySuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;

                this.Text = strVoucherTypeNames1;
                base.Show();
                if (isAutomatic)
                {
                    txtDate.Focus();
                }
                else
                {
                    txtVoucherNo.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from frmVoucherSearch form to view voucher details
        /// </summary>
        /// <param name="frm"></param>
        /// <param name="decId"></param>
        public void CallFromVoucherSerach(frmVoucherSearch frm, decimal decId)
        {
            try
            {

                isEditMode = true;
                decIsEditModeMasterId = decId;
                base.Show();
                SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();

                SalaryVoucherMasterInfo InfoMaster = new SalaryVoucherMasterInfo();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                btnDelete.Enabled = true;
                btnSave.Text = "Update";
                InfoMaster = BllSalaryVoucher.SalaryVoucherMasterView(decIsEditModeMasterId);
                strVoucherNoforEdit = InfoMaster.VoucherNo;
                strVoucherNo = InfoMaster.VoucherNo;
                txtVoucherNo.Text = InfoMaster.InvoiceNo;
                strInvoiceNo = InfoMaster.InvoiceNo;
                txtVoucherDate.Text = InfoMaster.Date.ToString("dd-MMMM-yyyy");
                string stra = Convert.ToDateTime(InfoMaster.Month.ToString()).ToString("MMM yyyy");
                dtpMonth.Value = Convert.ToDateTime(InfoMaster.Month.ToString("MMM yyyy"));
                txtNarration.Text = InfoMaster.Narration;
                lblTotalAmount.Text = InfoMaster.TotalAmount.ToString();
                decMonthlySuffixPrefixId = InfoMaster.SuffixPrefixId;
                decMonthlyVoucherTypeId = InfoMaster.VoucherTypeId;
                this.objVoucherSearch = frm;
                cmbCashOrBankAcc.SelectedValue = InfoMaster.LedgerId;
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decMonthlyVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.Enabled = false;
                }
                else
                {
                    txtVoucherNo.Enabled = true;
                }
                dtpMonth.Enabled = false;
                GridFill(isEditMode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("MSV2: " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function for fill details in Purchase Return when coming from Register or Report
 /// </summary>
 public void FillRegisterOrReport()
 {
     try
     {
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtReturnNo.ReadOnly = true;
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         List<DataTable> ListObjPurchaseReturnMaster = new List<DataTable>();
         List<DataTable> ListObjPurchaseMasterViewById = new List<DataTable>();
         UnitConvertionBll BllUnitConvertion = new UnitConvertionBll();
         PurchaseReturnBll BllPurchaseReturn = new PurchaseReturnBll();
         BatchBll BllBatch = new BatchBll();
         List<DataTable> ListObj = new List<DataTable>();
         decimal decPurchaseReturnDetailsId = 0;
         decimal decTotalValue = 0;
         decimal decRegisterTotalAmount = 0;
         decimal decInvoiceNo = 0;
         ListObjPurchaseReturnMaster = BllPurchaseReturn.PurchaseReturnViewByPurchaseReturnMasterId(decPurchaseReturnMasterId);
         if (ListObjPurchaseReturnMaster[0].Rows.Count > 0)
         {
             txtReturnNo.Text = ListObjPurchaseReturnMaster[0].Rows[0]["invoiceNo"].ToString();
             strReturnNo = ListObjPurchaseReturnMaster[0].Rows[0]["invoiceNo"].ToString();
             strVoucherNo = ListObjPurchaseReturnMaster[0].Rows[0]["voucherNo"].ToString();
             decPurchaseReturnSuffixPrefixId = Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["suffixPrefixId"].ToString());
             decPurchaseReturnVoucherTypeId = Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId"].ToString());
             VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
             infoVoucherType = BllVoucherType.VoucherTypeView(decPurchaseReturnVoucherTypeId);
             this.Text = infoVoucherType.VoucherTypeName;
             isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPurchaseReturnVoucherTypeId);
             txtReturnNo.ReadOnly = (isAutomatic) ? true : false;
             decPurchaseReturnTypeId = decPurchaseReturnVoucherTypeId;
             dtpDate.Text = ListObjPurchaseReturnMaster[0].Rows[0]["date"].ToString();
             cmbCashOrParty.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["ledgerId"].ToString();
             cmbPurchaseAccount.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["purchaseAccount"].ToString();
             txtTransportationCompany.Text = ListObjPurchaseReturnMaster[0].Rows[0]["transportationCompany"].ToString();
             txtNarration.Text = ListObjPurchaseReturnMaster[0].Rows[0]["narration"].ToString();
             txtLrlNo.Text = ListObjPurchaseReturnMaster[0].Rows[0]["lrNo"].ToString();
             cmbCurrency.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["exchangeRateId"].ToString();
             if (ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId1"].ToString() != string.Empty)
             {
                 cmbVoucherType.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId1"].ToString();
             }
             else
             {
                 cmbVoucherType.SelectedValue = 0;
             }
             cmbInvoiceNo.Text = ListObjPurchaseReturnMaster[0].Rows[0]["invoiceNo1"].ToString();
             if (ListObjPurchaseReturnMaster[0].Rows[0]["totalAmount1"].ToString() != string.Empty)
             {
                 decRegisterTotalAmount = Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["totalAmount"].ToString());
             }
             txtTotalAmount.Text = ListObjPurchaseReturnMaster[0].Rows[0]["totalAmount"].ToString();
             if (ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"].ToString() != string.Empty && Convert.ToInt32(ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"]) != 0)
             {
                 InvoiceNoComboFillInRegister();
                 cmbInvoiceNo.SelectedValue = Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"].ToString());
                 decInvoiceNo = Convert.ToDecimal(cmbInvoiceNo.SelectedValue.ToString());
                 ListObjPurchaseMasterViewById = BllPurchaseReturn.PurchaseReturnMasterViewByPurchaseMasterId(Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"].ToString()));
             }
             else
             {
                 cmbInvoiceNo.SelectedValue = ListObjPurchaseReturnMaster[0].Rows[0]["PurchaseMasterId"];
             }
             strInvoiceNo = ListObjPurchaseReturnMaster[0].Rows[0]["invoiceNo1"].ToString();
             decimal decDiscnt = Math.Round(Convert.ToDecimal(ListObjPurchaseReturnMaster[0].Rows[0]["discount"].ToString()), PublicVariables._inNoOfDecimalPlaces);
             ListObj = BllPurchaseReturn.PurchaseReturnDetailsViewByMasterId(decPurchaseReturnMasterId);
             dgvPurchaseReturn.Rows.Clear();
             for (int i = 0; i < ListObj[0].Rows.Count; i++)
             {
                 isAmountcalc = false;
                 dgvPurchaseReturn.Rows.Add();
                 int ini = dgvPurchaseReturn.Rows.Count;
                 decPurchaseReturnDetailsId = Convert.ToDecimal(ListObj[0].Rows[i]["purchaseReturnDetailsId"].ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtSlNo"].Value = ListObj[0].Rows[i]["slno"].ToString();
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString();
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductName"].Value = ListObj[0].Rows[i]["productName"].ToString();
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductId"].Value = ListObj[0].Rows[i]["productId"].ToString();
                 decimal decProductId = Convert.ToDecimal(dgvPurchaseReturn.Rows[i].Cells["dgvtxtproductId"].Value.ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtConversionRate"].Value = BllUnitConvertion.UnitConversionRateByUnitConversionId(decimal.Parse(ListObj[0].Rows[i]["unitConversionId"].ToString()));
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtUnitConversionId"].Value = decimal.Parse(ListObj[0].Rows[i]["unitConversionId"].ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtqty"].Value = (ListObj[0].Rows[i]["qty"].ToString() != string.Empty) ? Convert.ToDecimal(ListObj[0].Rows[i]["qty"].ToString()) : 0;
                 if (ListObj[0].Rows[i]["unitName"].ToString() != string.Empty)
                 {
                     UnitComboFill(decProductId, dgvPurchaseReturn.Rows[i].Index, dgvPurchaseReturn.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbUnit"].Value = ListObj[0].Rows[i]["unitName"].ToString();
                 }
                 else
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbUnit"].Value = "NA";
                 }
                 dgvPurchaseReturn.Rows[i].Cells["dgvcmbUnit"].ReadOnly = (ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId1"].ToString() != string.Empty) ? true : false;
                 if (ListObj[0].Rows[i]["godownId"].ToString() != string.Empty)
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["godownId"].ToString());
                 }
                 else
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbGodown"].Value = "NA";
                 }
                 if (ListObj[0].Rows[i]["rackId"].ToString() != string.Empty)
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvCmbRack"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["rackId"].ToString());
                 }
                 else
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvCmbRack"].Value = "NA";
                 }
                 if (ListObj[0].Rows[i]["batchId"].ToString() != string.Empty)
                 {
                     BatchComboFill(decProductId, dgvPurchaseReturn.Rows[i].Index, dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].ColumnIndex);
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString());
                 }
                 else
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].Value = "NA";
                 }
                 if (ListObj[0].Rows[i]["taxId"].ToString() != string.Empty && ListObj[0].Rows[i]["taxId"].ToString() != "NA")
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbTax"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["taxId"].ToString());
                 }
                 else
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbTax"].Value = "NA";
                 }
                 if (ListObjPurchaseReturnMaster[0].Rows[0]["voucherTypeId1"].ToString() != string.Empty)
                 {
                     dgvPurchaseReturn.Rows[i].Cells["dgvcmbBatch"].ReadOnly = true;
                 }
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtPurchaseDetailsId"].Value = ListObj[0].Rows[i]["purchaseDetailsId"].ToString();
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtbarcode"].Value = ListObj[0].Rows[i]["barcode"].ToString();
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtPurchaseReturnDetailsId"].Value = decPurchaseReturnDetailsId;
                 decimal decRate = Convert.ToDecimal(ListObj[0].Rows[i]["rate"].ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtrate"].Value = Math.Round(decRate, PublicVariables._inNoOfDecimalPlaces);
                 decimal decGross = Convert.ToDecimal(ListObj[0].Rows[i]["grossAmount"].ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtgrossValue"].Value = Math.Round(decGross, PublicVariables._inNoOfDecimalPlaces);
                 decimal decDis = Convert.ToDecimal(ListObj[0].Rows[i]["discount"].ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtdiscount"].Value = Math.Round(decDis, PublicVariables._inNoOfDecimalPlaces);
                 decimal decNet = Convert.ToDecimal(ListObj[0].Rows[i]["netAmount"].ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtNetAmount"].Value = Math.Round(decNet, PublicVariables._inNoOfDecimalPlaces);
                 decimal decTax = Convert.ToDecimal(ListObj[0].Rows[i]["taxAmount"].ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxttaxAmount"].Value = Math.Round(decTax, PublicVariables._inNoOfDecimalPlaces);
                 decimal decTotal = Convert.ToDecimal(ListObj[0].Rows[i]["amount"].ToString());
                 dgvPurchaseReturn.Rows[i].Cells["dgvtxtAmount"].Value = Math.Round(decTotal, PublicVariables._inNoOfDecimalPlaces);
                 decTotalValue = decTotalValue + Convert.ToDecimal(ListObj[0].Rows[i]["amount"].ToString());
                 if (cmbInvoiceNo.Visible == true)
                 {
                     dgvPurchaseReturn.Rows[dgvPurchaseReturn.Rows.Count - 1].ReadOnly = true;
                 }
             }
             lblTaxAmount.Text = Math.Round(decimal.Parse(ListObjPurchaseReturnMaster[0].Rows[0]["totalTax"].ToString()), 2).ToString(); ;
             txtTotalAmount.Text = decTotalValue.ToString();
             txtBillDiscount.Text = decDiscnt.ToString();
             DGVPurchaseReturnTaxFill();
             DGVTaxCombofill();
             Calculate();
             isAmountcalc = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PR:55" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill the fields for edit or delete
        /// </summary>
        public void FillFunction()
        {
            try
            {
                JournalMasterInfo infoJournalMaster = new JournalMasterInfo();
                JournalVoucherBll bllJournalMaster = new JournalVoucherBll();
                infoJournalMaster = bllJournalMaster.JournalMasterView(decJournalMasterIdForEdit);

                VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                infoVoucherType = BllVoucherType.VoucherTypeView(infoJournalMaster.VoucherTypeId);
                this.Text = infoVoucherType.VoucherTypeName;

                txtVoucherNo.ReadOnly = false;
                strVoucherNo = infoJournalMaster.VoucherNo;
                strInvoiceNo = infoJournalMaster.InvoiceNo;
                txtVoucherNo.Text = strInvoiceNo;
                decJournalSuffixPrefixId = infoJournalMaster.SuffixPrefixId;
                decJournalVoucherTypeId = infoJournalMaster.VoucherTypeId;
                dtpVoucherDate.Value = infoJournalMaster.Date;
                txtNarration.Text = infoJournalMaster.Narration;

                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decJournalVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.ReadOnly = false;
                }

                //GridFill
                List<DataTable> ListObj = new List<DataTable>();
                JournalVoucherBll bllJournalDetailsSp = new JournalVoucherBll();
                ListObj = bllJournalDetailsSp.JournalDetailsViewByMasterId(decJournalMasterIdForEdit);
                AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                for (int inI = 0; inI < ListObj[0].Rows.Count; inI++)
                {
                    dgvJournalVoucher.Rows.Add();
                    dgvJournalVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(ListObj[0].Rows[inI]["ledgerId"].ToString());

                    if (Convert.ToDecimal(ListObj[0].Rows[inI]["debit"].ToString()) == 0)
                    {
                        dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Cr";
                        dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(ListObj[0].Rows[inI]["credit"].ToString());
                    }
                    else
                    {
                        dgvJournalVoucher.Rows[inI].Cells["dgvcmbDrOrCr"].Value = "Dr";
                        dgvJournalVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(ListObj[0].Rows[inI]["debit"].ToString());
                    }
                    dgvJournalVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(ListObj[0].Rows[inI]["exchangeRateId"].ToString());
                    if (ListObj[0].Rows[inI]["chequeNo"].ToString() != string.Empty)
                    {
                        dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = ListObj[0].Rows[inI]["chequeNo"].ToString();
                        dgvJournalVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = (Convert.ToDateTime(ListObj[0].Rows[inI]["chequeDate"].ToString())).ToString("dd-MMM-yyyy");
                    }
                    dgvJournalVoucher.Rows[inI].Cells["dgvtxtDetailsId"].Value = ListObj[0].Rows[inI]["journalDetailsId"].ToString();

                    decimal decDetailsId1 = Convert.ToDecimal(ListObj[0].Rows[inI]["journalDetailsId"].ToString());
                    decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decJournalVoucherTypeId);
                    dgvJournalVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
                    btnSave.Text = "Update";

                }

                PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
                List<DataTable> listObj = new List<DataTable>();
                listObj = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decJournalVoucherTypeId, strVoucherNo, infoJournalMaster.Date);

                dtblPartyBalance = listObj[0];
                dgvJournalVoucher.ClearSelection();
                txtDate.Focus();
            }
            catch (Exception ex)
            {
                MessageBox.Show("JV37:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to fill controls for update
 /// </summary>
 public void fillFunction()
 {
     try
     {
         AdvancePaymentBll bllAdvancePayment = new AdvancePaymentBll();
         AdvancePaymentInfo infoadvance = new AdvancePaymentInfo();
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         infoadvance = bllAdvancePayment.AdvancePaymentView(decAdvancePaymentEditId);
         strVoucherNo = infoadvance.VoucherNo;
         txtAdvanceVoucherNo.Text = infoadvance.InvoiceNo;
         strInvoiceNo = infoadvance.InvoiceNo;
         cmbEmployee.SelectedValue = infoadvance.EmployeeId.ToString();
         dtpSalaryMonth.Value = Convert.ToDateTime(infoadvance.SalaryMonth.ToString());
         txtDate.Text = infoadvance.Date.ToString("dd-MMM-yyyy");
         txtChequeDate.Text = infoadvance.Date.ToString("dd-MMM-yyyy");
         cmbCashOrBank.SelectedValue = infoadvance.LedgerId.ToString();
         txtCheckNo.Text = infoadvance.Chequenumber;
         txtAmount.Text = infoadvance.Amount.ToString();
         txtNarration.Text = infoadvance.Narration;
         btnAdvancePaymentSave.Text = "Update";
         btnAdvancePaymentDelete.Enabled = true;
         decAdvancePaymentsId = decAdvancePaymentId;
         decPaymentVoucherTypeId = infoadvance.VoucherTypeId;
         decPaymentSuffixPrefixId = infoadvance.SuffixPrefixId;
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPaymentVoucherTypeId);
         if (isAutomatic)
         {
             txtAdvanceVoucherNo.Enabled = false;
         }
         else
         {
             txtAdvanceVoucherNo.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("AP8:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill the details while calling from register or report 
        /// </summary>
        public void FillRegisterOrReport()
        {
            StockJournalBll BllStockJournal = new StockJournalBll();
            StockJournalMasterInfo infoStockJournalMaster = new StockJournalMasterInfo();
            StockJournalDetailsInfo infoStockJournalDetails = new StockJournalDetailsInfo();
            AditionalCostBll bllAdditionalCost = new AditionalCostBll();
            VoucherTypeBll BllVoucherType = new VoucherTypeBll();
            try
            {

                isFillMode = true;
                btnSave.Text = "Update";
                cmbFinishedGoods.Enabled = false;
                txtQty.Enabled = false;
                btnAdd.Enabled = false;
                dgvConsumption.Rows.Clear();
                dgvProduction.Rows.Clear();
                dgvAdditionalCost.Rows.Clear();
                List<DataTable> listObjMaster = BllStockJournal.StockJournalMasterFillForRegisterOrReport(decStockJournalMasterIdForEdit);
                StockJournalVoucherTypeId = Convert.ToDecimal(listObjMaster[0].Rows[0]["voucherTypeId"].ToString());
                VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
                infoVoucherType = BllVoucherType.VoucherTypeView(StockJournalVoucherTypeId);
                this.Text = infoVoucherType.VoucherTypeName;
                txtDate.Text = listObjMaster[0].Rows[0]["date"].ToString();
                strVoucherNo = listObjMaster[0].Rows[0]["voucherNo"].ToString();
                decSuffixPrefixId = Convert.ToDecimal(listObjMaster[0].Rows[0]["suffixPrefixId"].ToString());
                decVoucherTypeId = Convert.ToDecimal(listObjMaster[0].Rows[0]["voucherTypeId"].ToString());
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(StockJournalVoucherTypeId);
                dtpDate.Value = Convert.ToDateTime(txtDate.Text);
                txtNarration.Text = listObjMaster[0].Rows[0]["narration"].ToString();
                cmbCurrency.SelectedValue = Convert.ToDecimal(listObjMaster[0].Rows[0]["exchangeRateId"].ToString());

                if (listObjMaster[0].Rows[0]["extra1"].ToString() == "Manufacturing")
                {
                    rbtnManufacturing.Checked = true;
                }
                if (listObjMaster[0].Rows[0]["extra1"].ToString() == "Transfer")
                {
                    rbtnTransfer.Checked = true;
                }
                if (listObjMaster[0].Rows[0]["extra1"].ToString() == "Stock Out")
                {
                    rbtnStockOut.Checked = true;
                }
                txtVoucherNo.Text = listObjMaster[0].Rows[0]["invoiceNo"].ToString();

                DataSet dsDetails = BllStockJournal.StockJournalDetailsForRegisterOrReport(decStockJournalMasterIdForEdit);

                DataTable dtblConsumption = dsDetails.Tables[0];
                if (dsDetails.Tables[0].Rows.Count > 0)
                {
                    for (int i = 0; i < dtblConsumption.Rows.Count; i++)
                    {
                        dgvConsumption.Rows.Add();
                        dgvConsumption.Rows[i].HeaderCell.Value = string.Empty;
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionStockJournalDetailsId"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["stockJournalDetailsId"].ToString());
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionSlNo"].Value = dtblConsumption.Rows[i]["slno"].ToString();
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionBarcode"].Value = dtblConsumption.Rows[i]["barcode"].ToString();
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductCode"].Value = dtblConsumption.Rows[i]["productCode"].ToString();
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductName"].Value = dtblConsumption.Rows[i]["productName"].ToString();
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductId"].Value = dtblConsumption.Rows[i]["productId"].ToString();
                        IsSetGridValueChange = true;
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionQty"].Value = dtblConsumption.Rows[i]["qty"].ToString();
                        IsSetGridValueChange = false;
                        dgvConsumption.Rows[i].Cells["dgvcmbConsumptionGodown"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["godownId"].ToString());
                        dgvConsumption.Rows[i].Cells["dgvcmbConsumptionRack"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["rackId"].ToString());
                        if (dtblConsumption.Rows[i]["batchId"] != null && dtblConsumption.Rows[i]["batchId"].ToString() != "0")
                        {
                            dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["batchId"].ToString());
                        }
                        else
                        {
                            dgvConsumption.Rows[i].Cells["dgvcmbConsumptionBatch"].Value = string.Empty;
                        }
                        IsSetGridValueChange = true;
                        dgvConsumption.Rows[i].Cells["dgvcmbConsumptionunitId"].Value = Convert.ToDecimal(dtblConsumption.Rows[i]["unitId"].ToString());
                        IsSetGridValueChange = false;
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionUnitConversionId"].Value = dtblConsumption.Rows[i]["unitConversionId"].ToString();
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionBarcode"].ReadOnly = true;
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductCode"].ReadOnly = true;
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionProductName"].ReadOnly = true;
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionRate"].Value = dtblConsumption.Rows[i]["rate"].ToString();
                        dgvConsumption.Rows[i].Cells["dgvtxtConsumptionAmount"].Value = dtblConsumption.Rows[i]["amount"].ToString();
                        dgvConsumption.Rows[i].HeaderCell.Value = "";
                    }
                }
                DataTable dtblProduction = dsDetails.Tables[1];
                for (int i = 0; i < dtblProduction.Rows.Count; i++)
                {
                    dgvProduction.Rows.Add();
                    dgvProduction.Rows[i].HeaderCell.Value = string.Empty;
                    dgvProduction.Rows[i].Cells["dgvtxtProductionStockJournalDetailsId"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["stockJournalDetailsId"].ToString());
                    dgvProduction.Rows[i].Cells["dgvtxtProductionSlNo"].Value = dtblProduction.Rows[i]["slno"].ToString();
                    dgvProduction.Rows[i].Cells["dgvtxtProductionBarcode"].Value = dtblProduction.Rows[i]["barcode"].ToString();
                    dgvProduction.Rows[i].Cells["dgvtxtProductionProductCode"].Value = dtblProduction.Rows[i]["productCode"].ToString();
                    dgvProduction.Rows[i].Cells["dgvtxtProductionProductName"].Value = dtblProduction.Rows[i]["productName"].ToString();
                    dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value = dtblProduction.Rows[i]["productId"].ToString();
                    IsSetGridValueChange = true;
                    dgvProduction.Rows[i].Cells["dgvtxtProductionQty"].Value = dtblProduction.Rows[i]["qty"].ToString();
                    IsSetGridValueChange = false;
                    if (rbtnManufacturing.Checked)
                    {
                        cmbFinishedGoods.SelectedValue = dgvProduction.Rows[i].Cells["dgvtxtProductionProductId"].Value;
                        if (cmbFinishedGoods.SelectedValue != null)
                        {
                            cmbFinishedGoods.Enabled = true;
                            txtQty.Enabled = true;
                            btnAdd.Enabled = true;
                            txtQty.Text = dtblProduction.Rows[i]["qty"].ToString();
                        }

                    }
                    dgvProduction.Rows[i].Cells["dgvcmbProductionGodown"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["godownId"].ToString());
                    dgvProduction.Rows[i].Cells["dgvcmbProductionRack"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["rackId"].ToString());
                    if (dtblProduction.Rows[i]["batchId"] != null && dtblProduction.Rows[i]["batchId"].ToString() != string.Empty)
                    {
                        dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["batchId"].ToString());
                    }
                    else
                    {
                        dgvProduction.Rows[i].Cells["dgvcmbProductionBatch"].Value = string.Empty;
                    }
                    IsSetGridValueChange = true;
                    dgvProduction.Rows[i].Cells["dgvcmbProductionunitId"].Value = Convert.ToDecimal(dtblProduction.Rows[i]["unitId"].ToString());
                    IsSetGridValueChange = false;
                    dgvProduction.Rows[i].Cells["dgvtxtProductionUnitConversionId"].Value = dtblProduction.Rows[i]["unitConversionId"].ToString();
                    dgvProduction.Rows[i].Cells["dgvtxtProductionBarcode"].ReadOnly = true;
                    dgvProduction.Rows[i].Cells["dgvtxtProductionProductCode"].ReadOnly = true;
                    dgvProduction.Rows[i].Cells["dgvtxtProductionProductName"].ReadOnly = true;
                    dgvProduction.Rows[i].Cells["dgvtxtProductionRate"].Value = dtblProduction.Rows[i]["rate"].ToString();
                    dgvProduction.Rows[i].Cells["dgvtxtProductionAmount"].Value = dtblProduction.Rows[i]["amount"].ToString();

                }
                DataSet dsAdditionalCost = bllAdditionalCost.StockJournalAdditionalCostForRegisteOrReport(strVoucherNo, decVoucherTypeId);
                if (dsAdditionalCost.Tables[0].Rows.Count > 0)
                {
                    DataTable dtblCashOrBank = dsAdditionalCost.Tables[0];
                    cmbCashOrBank.SelectedValue = Convert.ToDecimal(dtblCashOrBank.Rows[0]["ledgerId"]);
                }
                if (dsAdditionalCost.Tables[1].Rows.Count > 0)
                {
                    DataTable dtblIndirectExpenses = dsAdditionalCost.Tables[1];

                    int inRowIndexAdditional = 0;
                    for (int i = 0; i < dtblIndirectExpenses.Rows.Count; i++)
                    {
                        dgvAdditionalCost.Rows.Add();
                        dgvAdditionalCost.Rows[i].HeaderCell.Value = string.Empty;
                        dgvAdditionalCost.Rows[i].Cells["dgvtxtAdditionalCostSlNo"].Value = ++inRowIndexAdditional;

                        dgvAdditionalCost.Rows[i].Cells["dgvcmbAdditionalCostLedger"].Value = Convert.ToDecimal(dtblIndirectExpenses.Rows[i]["ledgerId"].ToString());
                        dgvAdditionalCost.Rows[i].Cells["dgvtxtAdditionalCostAmount"].Value = dtblIndirectExpenses.Rows[i]["debit"].ToString();
                    }
                }
                grandTotalAmountCalculationConsumption();
                grandTotalAmountCalculationProduction();
                TotalAdditionalCostAmount();
                btnDelete.Enabled = true;
                if (isAutomatic)
                {
                    txtVoucherNo.ReadOnly = true;
                }
                else
                {
                    txtVoucherNo.ReadOnly = false;
                }
                gbxTransactionType.Enabled = false;
                isFillMode = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("SJ:50" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="strVoucherTypeId"></param>
        /// <param name="strVoucherTypeName"></param>
        public void CallFromVoucherTypeSelection(decimal strVoucherTypeId, string strVoucherTypeName)
        {
            try
            {
                strPaymentVoucherTypeId = strVoucherTypeId.ToString();
                decPaymentVoucherTypeId = strVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(Convert.ToDecimal(strVoucherTypeId.ToString()));
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(Convert.ToDecimal(strPaymentVoucherTypeId), dtpDate.Value);
                decPaymentSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                this.Text = strVoucherTypeName;
                base.Show();
                if (isAutomatic)
                {
                    txtDate.Focus();
                }
                else
                {
                    txtAdvanceVoucherNo.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("AP11:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Its the fill function to update or delete
 /// </summary>
 public void FillFunction()
 {
     try
     {
         PDCClearanceMasterInfo infoPDCClearance = new PDCClearanceMasterInfo();
         PDCClearanceBll BllPdcClearance = new PDCClearanceBll();
         infoPDCClearance = BllPdcClearance.PDCClearanceMasterView(decPDCClearanceEditId);
         VoucherTypeComboFill();
         strVoucherNo = infoPDCClearance.VoucherNo;
         strInvoiceNo = infoPDCClearance.InvoiceNo;
         txtvoucherNo.Text = strInvoiceNo;
         decSufixprefixPdcpayableID = infoPDCClearance.SuffixPrefixId;
         decPDCclearanceVoucherTypeId = infoPDCClearance.VoucherTypeId;
         VoucherTypeBll BllVOucherType = new VoucherTypeBll();
         isAutomatic = BllVOucherType.CheckMethodOfVoucherNumbering(decPDCclearanceVoucherTypeId);
         if (isAutomatic)
         {
             txtvoucherNo.ReadOnly = true;
         }
         else
         {
             txtvoucherNo.ReadOnly = false;
         }
         if (infoPDCClearance.PDCClearanceMasterId != 0)
         {
             txtvoucherNo.Text = infoPDCClearance.VoucherNo;
             dtpVoucherDate.Value = infoPDCClearance.Date;
             txtVoucherDate.Text = dtpVoucherDate.Value.ToString("dd-MMM-yyyy");
             txtNarration.Text = infoPDCClearance.Narration;
             cmbvouchertype.Text = infoPDCClearance.Type;
             InvoiceNumberCombofill(cmbvouchertype.Text.ToString(), decMasterIdEdit);
             cmbStatus.Text = infoPDCClearance.Status;
             cmbInvoiceNo.SelectedValue = decMasterIdEdit;
             btnSave.Text = "Update";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PC14:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// function to Rejection In updation
        /// </summary>
        public void RejectionInview()
        {
            decimal decRejectioInMasterId = 0;
            try
            {
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                isFromRejectionInRegister = true;
                // RejectionInMasterSP SpRejectionInMaster = new RejectionInMasterSP();
                RejectionInBll bllRejectionIn = new RejectionInBll();
                RejectionInMasterInfo InfoRejectionInMaster = new RejectionInMasterInfo();
                InfoRejectionInMaster = bllRejectionIn.RejectionInMasterView(decRejectionInIdToEdit);
                //DeliveryNoteMasterSP SpDeliveryNoteMaster = new DeliveryNoteMasterSP();
                DeliveryNoteBll bllDeliveryNote = new DeliveryNoteBll();
                DeliveryNoteMasterInfo InfoDeliveryNoteMaster = new DeliveryNoteMasterInfo();
                InfoDeliveryNoteMaster = bllDeliveryNote.DeliveryNoteMasterView(InfoRejectionInMaster.DeliveryNoteMasterId);
                strRejectionInVoucherNo = bllRejectionIn.GetRejectionInVoucherNo(InfoRejectionInMaster.RejectionInMasterId);
                decRejectionInVoucherTypeId = InfoRejectionInMaster.VoucherTypeId;
                decRejectionInSuffixPrefixId = InfoRejectionInMaster.SuffixPrefixId;
                strVoucherNo = InfoRejectionInMaster.VoucherNo;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decRejectionInVoucherTypeId);

                if (!isAutomatic)
                {
                    txtRejectionInNo.ReadOnly = false;
                    txtRejectionInNo.Focus();
                }
                else
                {
                    txtRejectionInNo.ReadOnly = true;
                    txtDate.Focus();
                }
                txtRejectionInNo.Text = InfoRejectionInMaster.InvoiceNo;
                txtDate.Text = InfoRejectionInMaster.Date.ToString("dd-MMM-yyyy");
                dtpDate.Value = Convert.ToDateTime(txtDate.Text);
                cmbCashorParty.SelectedValue = InfoRejectionInMaster.LedgerId;
                cmbVoucherType.SelectedValue = InfoDeliveryNoteMaster.VoucherTypeId;
                cmbPricingLevel.SelectedValue = InfoRejectionInMaster.PricinglevelId;
                cmbDeliveryNoteNo.SelectedValue = InfoRejectionInMaster.DeliveryNoteMasterId;
                cmbSalesMan.SelectedValue = InfoRejectionInMaster.EmployeeId;
                cmbCurrency.SelectedValue = InfoRejectionInMaster.ExchangeRateId;
                txtTransportationCompany.Text = InfoRejectionInMaster.TransportationCompany;
                txtNarration.Text = InfoRejectionInMaster.Narration;
                txtLRNo.Text = InfoRejectionInMaster.LrNo;
                txtTotalAmount.Text = Convert.ToString(InfoRejectionInMaster.TotalAmount);
                RejectionInBll bllRejectionInBll = new RejectionInBll();
                List<DataTable> listRejectionInDetails = bllRejectionInBll.RejectionInDetailsViewByRejectionInMasterId(decRejectionInIdToEdit);
                decRejectioInMasterId = Convert.ToDecimal(listRejectionInDetails[0].Rows[0]["voucherTypeId"].ToString());
                VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
                infoVoucherType = BllVoucherType.VoucherTypeView(decRejectioInMasterId);
                this.Text = infoVoucherType.VoucherTypeName;
                foreach (DataRow drRejectionInDetails in listRejectionInDetails[0].Rows)
                {
                    isDoCellValueChange = false;
                    DGVGodownComboFill();
                    dgvProduct.Rows.Add();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtProductId"].Value = drRejectionInDetails["productId"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxDeliveryNoteDetailsId"].Value = drRejectionInDetails.ItemArray[2].ToString();
                    AssignProductDefaultValues(dgvProduct.Rows.Count - 1, Convert.ToDecimal(drRejectionInDetails.ItemArray[3].ToString()));
                    DGVBatchComboFill(dgvProduct.Rows.Count - 1, Convert.ToDecimal(drRejectionInDetails.ItemArray[3].ToString()));
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtQuantity"].Value = drRejectionInDetails["qty"].ToString();
                    isDoCellValueChange = true;
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(drRejectionInDetails["unitId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtUnitConversionId"].Value = Convert.ToDecimal(drRejectionInDetails["unitconversionId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(drRejectionInDetails["godownId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvcmbRack"].Value = Convert.ToDecimal(drRejectionInDetails["rackId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(drRejectionInDetails["batchId"].ToString());
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtRate"].Value = drRejectionInDetails["rate"].ToString();
                    dgvProduct.Rows[dgvProduct.Rows.Count - 1].Cells["dgvtxtAmount"].Value = drRejectionInDetails["amount"].ToString();
                    dgvProduct.CurrentCell = null;
                }
                SerialNo();
                CalcTotalAmt();
                isDoCellValueChange = true;
                isDoAfterGridFill = true;
                isFromRejectionInRegister = false;

            }
            catch (Exception ex)
            {
                MessageBox.Show("RI:35" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Function to fill the details here for updation
        /// </summary>
        public void DetailsFillForEdit()
        {
            try
            {
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isFormIdtoEdit = true;
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                txtVoucherNo.ReadOnly = true;
                txtPaidAmount.Text = "0";
                txtBalance.Text = "0";
                txtDate.Focus();
                List<DataTable> listMaster = BllSalesInvoice.POSSalesMasterViewBySalesMasterId(decSalesMasterId);
                txtVoucherNo.Text = listMaster[0].Rows[0]["invoiceNo"].ToString();
                strVoucherNo = listMaster[0].Rows[0]["voucherNo"].ToString();
                decPOSSuffixPrefixId = Convert.ToDecimal(listMaster[0].Rows[0]["suffixPrefixId"].ToString());
                DecPOSVoucherTypeId = Convert.ToDecimal(listMaster[0].Rows[0]["voucherTypeId"].ToString());
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(DecPOSVoucherTypeId);
                txtDate.Text = listMaster[0].Rows[0]["date"].ToString();
                dtpDate.Value = Convert.ToDateTime(txtDate.Text);
                cmbCashOrParty.SelectedValue = listMaster[0].Rows[0]["ledgerId"].ToString();
                txtNarration.Text = listMaster[0].Rows[0]["narration"].ToString();
                txtTotalAmount.Text = listMaster[0].Rows[0]["totalAmount"].ToString();
                txtBillDiscount.Text = listMaster[0].Rows[0]["billDiscount"].ToString();
                txtGrandTotal.Text = listMaster[0].Rows[0]["grandTotal"].ToString();
                cmbSalesAccount.SelectedValue = listMaster[0].Rows[0]["salesAccount"].ToString();
                cmbCounter.SelectedValue = listMaster[0].Rows[0]["counterId"].ToString();
                cmbPricingLevel.SelectedValue = listMaster[0].Rows[0]["pricingLevelId"].ToString();
                cmbSalesMan.SelectedValue = listMaster[0].Rows[0]["employeeId"].ToString();
                txtBalance.Text = listMaster[0].Rows[0]["grandTotal"].ToString();
                List<DataTable> listObj = new List<DataTable>();
                listObj = BllSalesInvoice.SalesDetailsViewBySalesMasterId(decSalesMasterId);
                for (int i = 0; i < listObj[0].Rows.Count; i++)
                {
                    dgvPointOfSales.Rows.Add();
                    decSalesDetailsId = Convert.ToDecimal(listObj[0].Rows[i]["salesDetailsId"].ToString());
                    dgvPointOfSales.Rows[i].Cells["dgvtxtSalesDetailsId"].Value = decSalesDetailsId;
                    dgvPointOfSales.Rows[i].Cells["dgvtxtSlNo"].Value = listObj[0].Rows[i]["slNo"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtProductCode"].Value = listObj[0].Rows[i]["productCode"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtProductName"].Value = listObj[0].Rows[i]["productName"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtQuantity"].Value = listObj[0].Rows[i]["qty"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtUnit"].Value = listObj[0].Rows[i]["unitName"].ToString();
                    decimal dcrate = Convert.ToDecimal(listObj[0].Rows[i]["rate"].ToString());
                    dgvPointOfSales.Rows[i].Cells["dgvtxtRate"].Value = Math.Round(dcrate, PublicVariables._inNoOfDecimalPlaces);
                    dgvPointOfSales.Rows[i].Cells["dgvtxtGrossValue"].Value = listObj[0].Rows[i]["grossAmount"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtDiscount"].Value = listObj[0].Rows[i]["discount"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtNetAmount"].Value = listObj[0].Rows[i]["netAmount"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtTaxPercentage"].Value = listObj[0].Rows[i]["taxName"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtTaxAmount"].Value = listObj[0].Rows[i]["taxAmount"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtTotalAmount"].Value = listObj[0].Rows[i]["amount"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtBarcode"].Value = listObj[0].Rows[i]["barcode"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtunitconversionId"].Value = listObj[0].Rows[i]["unitConversionId"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtBatchId"].Value = listObj[0].Rows[i]["batchId"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtRackId"].Value = listObj[0].Rows[i]["rackId"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtGodownId"].Value = listObj[0].Rows[i]["godownId"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtBatchno"].Value = listObj[0].Rows[i]["batchNo"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtGodownName"].Value = listObj[0].Rows[i]["godownName"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtRackName"].Value = listObj[0].Rows[i]["rackName"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxttaxid"].Value = listObj[0].Rows[i]["taxId"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtProductId"].Value = listObj[0].Rows[i]["productId"].ToString();
                    dgvPointOfSales.Rows[i].Cells["dgvtxtUnitId"].Value = listObj[0].Rows[i]["unitId"].ToString();
                }

                taxGridFill();
                listObj = BllSalesInvoice.SalesInvoiceSalesBillTaxViewAllBySalesMasterId(decSalesMasterId);
                foreach (DataGridViewRow dgvrowTax in dgvPOSTax.Rows)
                {
                    for (int i = 0; i < listObj[0].Rows.Count; i++)
                    {
                        if (dgvPOSTax.Rows[i].Cells["dgvtxttax"].Value != null && dgvPOSTax.Rows[i].Cells["dgvtxttax"].Value.ToString() != string.Empty)
                        {
                            dgvPOSTax.Rows[i].Cells["dgvtxttax"].Value = listObj[0].Rows[i]["taxId"].ToString();
                            dgvPOSTax.Rows[i].Cells["dgvtxtTaxAmt"].Value = listObj[0].Rows[i]["taxAmount"].ToString();
                        }
                    }
                }
                TaxTotal();
            }
            catch (Exception ex)
            {
                MessageBox.Show("POS:56" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// It is a function for vouchertypeselection form to select perticular voucher and open the form under the vouchertype
        /// </summary>
        /// <param name="decVoucherTypeId"></param>
        /// <param name="strVoucherTypeName"></param>
        public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
        {
            try
            {
                decJournalVoucherTypeId = decVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decJournalVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();
                //SuffixPrefixSP spSuffisprefix = new SuffixPrefixSP();
                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();

                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decJournalVoucherTypeId, dtpVoucherDate.Value);
                decJournalSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;
                this.Text = strVoucherTypeName;
                base.Show();
                clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show("JV1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Fill function to updation
        /// </summary>
        /// <param name="isPending"></param>
        public void FillRegisterOrReport(bool isPending)
        {
            try
            {
                PurchaseOrderMasterInfo infoPurchaseOrderMaster = new PurchaseOrderMasterInfo();

                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                PurchaseOrderBll BllPurchaseOrder = new PurchaseOrderBll();
                btnSave.Text = "Update";
                btnDelete.Enabled = true;
                txtOrderNo.ReadOnly = true;
                infoPurchaseOrderMaster = BllPurchaseOrder.PurchaseOrderMasterView(decPurchaseOrderMasterId);
                txtOrderNo.Text = infoPurchaseOrderMaster.InvoiceNo;
                strVoucherNo = infoPurchaseOrderMaster.VoucherNo.ToString();
                decPurchaseSuffixPrefixId = Convert.ToDecimal(infoPurchaseOrderMaster.SuffixPrefixId);
                decPurchaseVoucherId = Convert.ToDecimal(infoPurchaseOrderMaster.VoucherTypeId);
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPurchaseVoucherId);
                decPurchaseOrderTypeId = decPurchaseVoucherId;
                txtDate.Text = infoPurchaseOrderMaster.Date.ToString("dd-MMM-yyyy");
                cmbCashOrParty.SelectedValue = infoPurchaseOrderMaster.LedgerId;
                txtDueDate.Text = infoPurchaseOrderMaster.DueDate.ToString("dd-MMM-yyyy");
                TimeSpan objTs = Convert.ToDateTime(txtDueDate.Text).Subtract(Convert.ToDateTime(txtDate.Text));
                txtDueDays.Text = objTs.Days.ToString();
                txtNarration.Text = infoPurchaseOrderMaster.Narration;
                cmbCurrency.SelectedValue = infoPurchaseOrderMaster.exchangeRateId;
                txtTotalAmount.Text = infoPurchaseOrderMaster.TotalAmount.ToString();
                List<DataTable> ListObj = new List<DataTable>();
                if (isPending)
                {
                    ListObj = BllPurchaseOrder.PurchaseOrderDetailsViewWithRemaining(decPurchaseOrderMasterId);
                }
                else
                {
                    ListObj = BllPurchaseOrder.PurchaseOrderDetailsViewByMasterId(decPurchaseOrderMasterId);
                }
                if (CheckCancelStatus(decPurchaseOrderMasterId))
                {
                    isCheck = true;
                    cbxCancel.Checked = true;
                    cbxCancel.Enabled = false;
                    isCheck = false;
                }
                else
                {
                    isCheck = true;
                    cbxCancel.Enabled = true;
                    //  cbxCancel.Checked = false;
                    isCheck = false;
                }
                dgvPurchaseOrder.Rows.Clear();
                for (int i = 0; i < ListObj[0].Rows.Count; i++)
                {
                    isAmountcalc = false;
                    dgvPurchaseOrder.Rows.Add();
                    dgvPurchaseOrder.Rows[i].HeaderCell.Value = string.Empty;
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtPurchaseOrderDetailsId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["purchaseOrderDetailsId"].ToString());
                    decPurchaseOrderDetailId = Convert.ToDecimal(ListObj[0].Rows[i]["purchaseOrderDetailsId"].ToString());
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductId"].Value = ListObj[0].Rows[i]["productId"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[i]["productName"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtQty"].Value = ListObj[0].Rows[i]["qty"].ToString();
                    UnitComboFill(Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString()), i, dgvPurchaseOrder.Rows[i].Cells["dgvcmbUnit"].ColumnIndex);
                    dgvPurchaseOrder.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitId"].ToString());
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtUnitConversionId"].Value = ListObj[0].Rows[i]["unitConversionId"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtUnitConversionRate"].Value = ListObj[0].Rows[i]["conversionRate"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtRate"].Value = ListObj[0].Rows[i]["rate"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[i]["amount"].ToString();
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductName"].ReadOnly = true;
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtProductCode"].ReadOnly = true;
                    dgvPurchaseOrder.Rows[i].Cells["dgvtxtBarcode"].ReadOnly = true;
                }
                SerialNo();
                isAmountcalc = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("PO25:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Grid Fill function while coming from other form to update or delete
 /// </summary>
 public void FillFunction()
 {
     try
     {
         //PaymentMasterSP SpPaymentMaster = new PaymentMasterSP();
         PaymentMasterInfo InfoPaymentMaster = new PaymentMasterInfo();
         //PaymentDetailsSP SpPaymentDetails = new PaymentDetailsSP();
         PaymentVoucherBll BllPaymentVoucher = new PaymentVoucherBll();
         PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
         LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         AccountGroupBll bllAccountGroup = new AccountGroupBll();
         AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
         InfoPaymentMaster = BllPaymentVoucher.PaymentMasterViewByMasterId(decPaymentmasterId);//view master details
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(InfoPaymentMaster.VoucherTypeId);
         if (isAutomatic)
         {
             txtVoucherNo.ReadOnly = true;
             txtVoucherNo.Text = InfoPaymentMaster.InvoiceNo;
             txtDate.Focus();
         }
         else
         {
             txtVoucherNo.ReadOnly = false;
             txtVoucherNo.Text = InfoPaymentMaster.InvoiceNo;
             txtVoucherNo.Focus();
         }
         dtpDate.Text = InfoPaymentMaster.Date.ToString();
         cmbBankorCash.SelectedValue = InfoPaymentMaster.LedgerId;
         txtNarration.Text = InfoPaymentMaster.Narration;
         txtTotal.Text = InfoPaymentMaster.TotalAmount.ToString();
         decDailySuffixPrefixId = InfoPaymentMaster.SuffixPrefixId;
         decPaymentVoucherTypeId = InfoPaymentMaster.VoucherTypeId;
         strVoucherNo = InfoPaymentMaster.VoucherNo;
         strInvoiceNo = InfoPaymentMaster.InvoiceNo;
         //DataTable dtbl = new DataTable();
         List<DataTable> listObj1 = new List<DataTable>();
         listObj1 = BllPaymentVoucher.PaymentDetailsViewByMasterId(decPaymentmasterId);//view details details
         for (int inI = 0; inI < listObj1[0].Rows.Count; inI++)
         {
             dgvPaymentVoucher.Rows.Add();
             dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].Value = Convert.ToDecimal(listObj1[0].Rows[inI]["ledgerId"].ToString());
             dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentMasterId"].Value = listObj1[0].Rows[inI]["paymentMasterId"].ToString();
             dgvPaymentVoucher.Rows[inI].Cells["dgvtxtpaymentDetailsId"].Value = listObj1[0].Rows[inI]["paymentDetailsId"].ToString();
             dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].Value = listObj1[0].Rows[inI]["amount"].ToString();
             dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(listObj1[0].Rows[inI]["exchangeRateId"].ToString());
             decimal decDetailsId1 = Convert.ToDecimal(listObj1[0].Rows[inI]["paymentDetailsId"].ToString());
             decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, decPaymentVoucherTypeId);
             dgvPaymentVoucher.Rows[inI].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
             decimal decLedgerId = Convert.ToDecimal(listObj1[0].Rows[inI]["ledgerId"].ToString());
             bool IsBankAccount = bllAccountGroup.AccountGroupwithLedgerId(decLedgerId);
             decimal decI = Convert.ToDecimal(bllAccountLedger.AccountGroupIdCheck(dgvPaymentVoucher.Rows[inI].Cells["dgvcmbAccountLedger"].FormattedValue.ToString()));
             if (decI > 0)//to make amount and currency read only when party is choosen as ledger
             {
                 dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = true;
                 dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = true;
             }
             else
             {
                 dgvPaymentVoucher.Rows[inI].Cells["dgvtxtAmount"].ReadOnly = false;
                 dgvPaymentVoucher.Rows[inI].Cells["dgvcmbCurrency"].ReadOnly = false;
             }
             dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value = listObj1[0].Rows[inI]["ChequeNo"].ToString();
             if (dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value != null && dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeNo"].Value.ToString() != string.Empty)
             {
                 dgvPaymentVoucher.Rows[inI].Cells["dgvtxtChequeDate"].Value = Convert.ToDateTime(listObj1[0].Rows[inI]["ChequeDate"].ToString()).ToString("dd-MMM-yyyy");
             }
             dgvPaymentVoucher.Rows[inI].HeaderCell.Value = string.Empty;
         }
         List<DataTable> listObj = new List<DataTable>();
         listObj = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decPaymentVoucherTypeId, strVoucherNo, InfoPaymentMaster.Date);
         dtblPartyBalance = listObj[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("PV36:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Function to fill controls for updation
        /// </summary>
        public void fillFunction()
        {
            try
            {
                DailySalaryVoucherBll BllDailySalaryVoucherMaster = new DailySalaryVoucherBll();
                DailySalaryVoucherMasterInfo InfoMaster = new DailySalaryVoucherMasterInfo();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                InfoMaster = BllDailySalaryVoucherMaster.DailySalaryVoucherViewFromRegister(decMasterIdforEdit);

                strVoucherNoforEdit = InfoMaster.VoucherNo;
                strVoucherNo = InfoMaster.VoucherNo;
                txtVoucherNo.Text = InfoMaster.InvoiceNo;
                strInvoiceNo = InfoMaster.InvoiceNo;
                dtpDate.Text = InfoMaster.Date.ToString();
                dtpSalaryDate.Text = InfoMaster.SalaryDate.ToString();
                lblShowTotelamount.Text = Math.Round(Convert.ToDecimal(InfoMaster.TotalAmount.ToString("0.00000")), PublicVariables._inNoOfDecimalPlaces).ToString();
                txtNarration.Text = InfoMaster.Narration;
                decDailySuffixPrefixId = InfoMaster.SuffixPrefixId;
                decDailyVoucherTypeId = InfoMaster.VoucherTypeId;
                cmbCashorBankAccount.SelectedValue = InfoMaster.LedgerId.ToString();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDailyVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.Enabled = false;
                }
                else
                {
                    txtVoucherNo.Enabled = true;
                }

                dtpSalaryDate.Enabled = false;
                txtSalaryDate.Enabled = false;
                DailySalaryVoucherDetailsGridfill(isEditmode);
            }
            catch (Exception ex)
            {
                MessageBox.Show("DSV6:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="decVoucherTypeId"></param>
        /// <param name="strVoucherTypeName"></param>
        public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
        {
            try
            {
                decsalesQuotationTypeId = decVoucherTypeId;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decsalesQuotationTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo InfoSuffixPrefix = new SuffixPrefixInfo();
                InfoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decsalesQuotationTypeId, dtpSalesQuotationDate.Value);
                decSalesQuotationPreffixSuffixId = InfoSuffixPrefix.SuffixprefixId;
                this.Text = strVoucherTypeName;
                base.Show();
                if (isAutomatic)
                {
                    txtSalesQuotationDate.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("SQ:14" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to fill controls for updation
        /// </summary>
        public void FillFunction()
        {
            try
            {
                SalaryVoucherBll BllSalaryVoucher = new SalaryVoucherBll();

                SalaryVoucherMasterInfo InfoMaster = new SalaryVoucherMasterInfo();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();

                InfoMaster = BllSalaryVoucher.SalaryVoucherMasterView(decIsEditModeMasterId);

                strVoucherNoforEdit = InfoMaster.VoucherNo;
                strVoucherNo = InfoMaster.VoucherNo;
                txtVoucherNo.Text = InfoMaster.InvoiceNo;
                strInvoiceNo = InfoMaster.InvoiceNo;

                txtVoucherDate.Text = InfoMaster.Date.ToString("dd-MMMM-yyyy");
                string stra = Convert.ToDateTime(InfoMaster.Month.ToString()).ToString("MMM yyyy");
                dtpMonth.Value = Convert.ToDateTime(InfoMaster.Month.ToString("MMM yyyy"));
                txtNarration.Text = InfoMaster.Narration;

                decimal decTotalAmont = Math.Round(Convert.ToDecimal(InfoMaster.TotalAmount.ToString()), PublicVariables._inNoOfDecimalPlaces);
                lblTotalAmount.Text = decTotalAmont.ToString();
                decMonthlySuffixPrefixId = InfoMaster.SuffixPrefixId;
                decMonthlyVoucherTypeId = InfoMaster.VoucherTypeId;

                cmbCashOrBankAcc.SelectedValue = InfoMaster.LedgerId;
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decMonthlyVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.Enabled = false;
                }
                else
                {
                    txtVoucherNo.Enabled = true;
                }
                dtpMonth.Enabled = false;

                GridFill(isEditMode);
            }
            catch (Exception ex)
            {

                MessageBox.Show("MSV10:" + 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>
        /// Fill all the controlls while coming from other forms for update or delete
        /// </summary>
        public void FillFunction()
        {
            try
            {
                ContraVoucherDetailsBll bllContraVoucherDetails = new ContraVoucherDetailsBll();
                ContraMasterInfo infoContraMaster = new ContraMasterInfo();
                LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
                VoucherTypeBll BllVOucherType = new VoucherTypeBll();
                infoContraMaster = bllContraVoucherDetails.ContraMasterView(decMasterId);
                txtVoucherNo.ReadOnly = false;
                strVoucherNo = infoContraMaster.VoucherNo;
                txtVoucherNo.Text = infoContraMaster.InvoiceNo;
                strInvoiceNo = infoContraMaster.InvoiceNo;
                strInvoiceNo = infoContraMaster.InvoiceNo;
                decContraSuffixPrefixId = Convert.ToDecimal(infoContraMaster.SuffixPrefixId.ToString());
                DecContraVoucherTypeId = Convert.ToDecimal(infoContraMaster.VoucherTypeId.ToString());
                int inDecimalPlace = PublicVariables._inNoOfDecimalPlaces;
                txtNarration.Text = infoContraMaster.Narration;
                txtContraVoucherDate.Text = Convert.ToString(infoContraMaster.date);
                cmbBankAccount.SelectedValue = infoContraMaster.LedgerId;
                strVoucherNo = infoContraMaster.VoucherNo;
                if (infoContraMaster.Type == "Deposit")
                {
                    rbtnDeposit.Checked = true;
                }
                else
                {
                    rbtnWithdrawal.Checked = true;
                }
                isAutomatic = BllVOucherType.CheckMethodOfVoucherNumbering(DecContraVoucherTypeId);
                if (isAutomatic)
                {
                    txtVoucherNo.Enabled = false;
                }
                else
                {
                    txtVoucherNo.Enabled = true;
                }

                List<DataTable> listObj = new List<DataTable>();
                listObj = bllContraVoucherDetails.ContraDetailsViewWithMasterId(decMasterId);
                for (int i = 0; i < listObj[0].Rows.Count; i++)
                {
                    dgvContraVoucher.Rows.Add();
                    dgvContraVoucher.Rows[i].Cells["dgvcmbBankorCashAccount"].Value = Convert.ToDecimal(listObj[0].Rows[i]["ledgerId"].ToString());
                    dgvContraVoucher.Rows[i].Cells["dgvcmbCurrency"].Value = Convert.ToDecimal(listObj[0].Rows[i]["exchangeRateId"].ToString());
                    dgvContraVoucher.Rows[i].Cells["dgvtxtAmount"].Value = Convert.ToDecimal(listObj[0].Rows[i]["amount"].ToString());

                    if (listObj[0].Rows[i]["chequeNo"].ToString() != string.Empty)
                    {
                        dgvContraVoucher.Rows[i].Cells["dgvtxtChequeNo"].Value = listObj[0].Rows[i]["chequeNo"].ToString();
                        if (listObj[0].Rows[i]["chequeDate"].ToString() == "01 Jan 1753")
                        {
                            dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value = null;
                        }
                        else
                        {
                            dgvContraVoucher.Rows[i].Cells["dgvtxtChequeDate"].Value = listObj[0].Rows[i]["chequeDate"].ToString();
                        }
                    }
                    dgvContraVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value = listObj[0].Rows[i]["contraDetailsId"].ToString();
                    decimal decDetailsId1 = Convert.ToDecimal(listObj[0].Rows[i]["contraDetailsId"].ToString());
                    decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, DecContraVoucherTypeId);
                    dgvContraVoucher.Rows[i].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("CV:31" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        /// <summary>
        /// Function to call this form from VoucherType Selection form
        /// </summary>
        /// <param name="DecPhysicalStockVoucherType"></param>
        /// <param name="strPhysicalStockVouchertypeName"></param>
        public void CallFromVoucherTypeSelection(decimal DecPhysicalStockVoucherType, string strPhysicalStockVouchertypeName)
        {
            try
            {
                decPhysicalStockVoucherTypeId = DecPhysicalStockVoucherType;
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPhysicalStockVoucherTypeId);
                SuffixPrefixSettingsBll BllSuffixPrefixSettings = new SuffixPrefixSettingsBll();

                SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
                infoSuffixPrefix = BllSuffixPrefixSettings.GetSuffixPrefixDetails(decPhysicalStockVoucherTypeId, dtpDate.Value);
                decDailySuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
                strPrefix = infoSuffixPrefix.Prefix;
                strSuffix = infoSuffixPrefix.Suffix;
                this.Text = strPhysicalStockVouchertypeName;
                base.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("PS:9" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Fill function to updation
 /// </summary>
 public void FillFunction()
 {
     try
     {
         PDCRecivebleBll BllPdcRecieveble = new PDCRecivebleBll();
         PDCReceivableMasterInfo infopdcrecivable = new PDCReceivableMasterInfo();
         infopdcrecivable = BllPdcRecieveble.PDCReceivableMasterView(decPDCReceivableEditId);
         txtVoucherNo.ReadOnly = false;
         strVoucherNo = infopdcrecivable.VoucherNo;
         strInvoiceNo = infopdcrecivable.InvoiceNo;
         txtVoucherNo.Text = strInvoiceNo;
         decSufixprefixPdcReceivableID = infopdcrecivable.SuffixPrefixId;
         decPDCReceivableVoucherTypeId = infopdcrecivable.VoucherTypeId;
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPDCReceivableVoucherTypeId);
         if (isAutomatic)
         {
             txtVoucherNo.ReadOnly = true;
         }
         else
         {
             txtVoucherNo.ReadOnly = false;
             lblVoucherNoManualValidator.Visible = false;
         }
         if (infopdcrecivable.PdcReceivableMasterId != 0)
         {
             txtVoucherNo.Text = infopdcrecivable.InvoiceNo;
             dtpVoucherDate.Value = infopdcrecivable.Date;
             txtVoucherDate.Text = dtpVoucherDate.Value.ToString("dd-MMM-yyyy");
             txtNarration.Text = infopdcrecivable.Narration;
             cmbAccountLedger.SelectedValue = infopdcrecivable.LedgerId;
             txtAmount.Text = infopdcrecivable.Amount.ToString();
             if (infopdcrecivable.BankId != 0)
                 cmbBank.SelectedValue = infopdcrecivable.BankId;
             else
                 cmbBank.SelectedValue = string.Empty;
             txtcheckNo.Text = infopdcrecivable.ChequeNo;
             txtCheckDate.Text = infopdcrecivable.ChequeDate.ToString("dd-MMM-yyyy");
             btnSave.Text = "Update";
             PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
             List<DataTable> listObj = new List<DataTable>();
             listObj = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherType(decPDCReceivableVoucherTypeId, strVoucherNo, infopdcrecivable.Date);
             dtblPartyBalance = listObj[0];
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PP24:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        /// Fill function for updation
        /// </summary>
        public void FillFunction()
        {
            try
            {
                PhysicalStockMasterInfo infoPhysicalStockMaster = new PhysicalStockMasterInfo();
                //PhysicalStockMasterSP spPhysicalStockMaster = new PhysicalStockMasterSP();
                PhysicalStockBll BllPhysicalStock = new PhysicalStockBll();
                VoucherTypeBll BllVoucherType = new VoucherTypeBll();
                infoPhysicalStockMaster = BllPhysicalStock.PhysicalStockMasterView(decMasterId);
                txtVoucherNo.Text = infoPhysicalStockMaster.InvoiceNo;
                strVoucherNo = infoPhysicalStockMaster.VoucherNo.ToString();
                decPhysicalStockSuffixPrefixId = Convert.ToDecimal(infoPhysicalStockMaster.SuffixPrefixId);
                decPhysicalStockVoucherTypeId = Convert.ToDecimal(infoPhysicalStockMaster.VoucherTypeId);
                isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decPhysicalStockVoucherTypeId);
                txtDate.Text = infoPhysicalStockMaster.Date.ToString("dd-MMM-yyyy");
                txtNarration.Text = infoPhysicalStockMaster.Narration;
                txtTotalAmount.Text = infoPhysicalStockMaster.TotalAmount.ToString();
                List<DataTable> ListObj = new List<DataTable>();
                ListObj = BllPhysicalStock.PhysicalStockViewbyMasterId(decMasterId);
                isFromEditMode = true;
                for (int i = 0; i < ListObj[0].Rows.Count; i++)
                {

                    dgvPhysicalStock.Rows.Add();
                    dgvPhysicalStock.Rows[i].HeaderCell.Value = string.Empty;
                    dgvPhysicalStock.Rows[i].Cells["dgvtxtPhysicalStockDetailId"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["physicalStockDetailsId"].ToString());
                    dgvPhysicalStock.Rows[i].Cells["dgvtxtSlNo"].Value = ListObj[0].Rows[i]["slno"].ToString();
                    dgvPhysicalStock.Rows[i].Cells["dgvtxtProductCode"].Value = ListObj[0].Rows[i]["productCode"].ToString();
                    dgvPhysicalStock.Rows[i].Cells["dgvtxtProductName"].Value = ListObj[0].Rows[i]["productName"].ToString();
                    dgvPhysicalStock.Rows[i].Cells["dgvtxtQty"].Value = ListObj[0].Rows[i]["qty"].ToString();
                    BatchComboFill(Convert.ToDecimal(ListObj[0].Rows[i]["productId"].ToString()), i, dgvPhysicalStock.Rows[i].Cells["dgvcmbBatch"].ColumnIndex);
                    dgvPhysicalStock.Rows[i].Cells["dgvcmbBatch"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["batchId"].ToString());
                    dgvPhysicalStock.Rows[i].Cells["dgvcmbUnit"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["unitId"].ToString());
                    dgvPhysicalStock.Rows[i].Cells["dgvcmbGodown"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["godownId"].ToString());
                    dgvPhysicalStock.Rows[i].Cells["dgvcmbRack"].Value = Convert.ToDecimal(ListObj[0].Rows[i]["rackId"].ToString());
                    dgvPhysicalStock.Rows[i].Cells["dgvtxtRate"].Value = ListObj[0].Rows[i]["rate"].ToString();
                    dgvPhysicalStock.Rows[i].Cells["dgvtxtAmount"].Value = ListObj[0].Rows[i]["amount"].ToString();
                    dgvPhysicalStock.Rows[i].Cells["dgvtxtBarcode"].Value = ListObj[0].Rows[i]["barcode"].ToString();
                    if (dgvPhysicalStock.Columns.Count > 0)
                    {
                        dgvPhysicalStock.Columns["dgvtxtRate"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                        dgvPhysicalStock.Columns["dgvtxtAmount"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
                    }
                }
                isFromEditMode = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show("PS:8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
 /// <summary>
 /// Function to call These form from vouchertype Selection form
 /// </summary>
 /// <param name="decVoucherTypeId"></param>
 /// <param name="strVoucherTypeName"></param>
 public void CallFromVoucherTypeSelection(decimal decVoucherTypeId, string strVoucherTypeName)
 {
     try
     {
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         SuffixPrefixInfo infoSuffixPrefix = new SuffixPrefixInfo();
         decDeliveryNoteVoucherTypeId = decVoucherTypeId;
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decDeliveryNoteVoucherTypeId);
         infoSuffixPrefix = new SuffixPrefixSettingsBll().GetSuffixPrefixDetails(decDeliveryNoteVoucherTypeId, dtpDate.Value);
         decDeliveryNoteSuffixPrefixId = infoSuffixPrefix.SuffixprefixId;
         this.Text = strVoucherTypeName;
         base.Show();
         if (isAutomatic)
         {
             txtDate.Focus();
         }
         else
         {
             txtDeliveryNoteNo.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("DN07:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Fill function from coming from register or report or other forms
 /// </summary>
 public void FillRegisterOrReport()
 {
     //SalesMasterSP spSalesMaster = new SalesMasterSP();
     //SalesDetailsSP spSalesDetails = new SalesDetailsSP();
     VoucherTypeBll BllVoucherType = new VoucherTypeBll();
     //SalesBillTaxSP spSalesBillTax = new SalesBillTaxSP();
     SalesInvoiceBll BllSalesInvoice = new SalesInvoiceBll();
     try
     {
         isFromEditMode = true;
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         txtInvoiceNo.ReadOnly = true;
         List<DataTable> listMaster = BllSalesInvoice.SalesInvoiceSalesMasterViewBySalesMasterId(decSalesInvoiceIdToEdit);
         DecSalesInvoiceVoucherTypeId = Convert.ToDecimal(listMaster[0].Rows[0]["voucherTypeId"].ToString());
         VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
         infoVoucherType = BllVoucherType.VoucherTypeView(DecSalesInvoiceVoucherTypeId);
         this.Text = infoVoucherType.VoucherTypeName;
         txtDate.Text = listMaster[0].Rows[0]["date"].ToString();
         dtpDate.Value = DateTime.Parse(txtDate.Text);
         CurrencyComboFill();
         txtInvoiceNo.Text = listMaster[0].Rows[0]["invoiceNo"].ToString();
         txtCreditPeriod.Text = listMaster[0].Rows[0]["creditPeriod"].ToString();
         strVoucherNo = listMaster[0].Rows[0]["voucherNo"].ToString();
         decSalseInvoiceSuffixPrefixId = Convert.ToDecimal(listMaster[0].Rows[0]["suffixPrefixId"].ToString());
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(DecSalesInvoiceVoucherTypeId);
         cmbCashOrParty.SelectedValue = listMaster[0].Rows[0]["ledgerId"].ToString();
         cmbSalesAccount.SelectedValue = listMaster[0].Rows[0]["salesAccount"].ToString();
         cmbSalesMan.SelectedValue = listMaster[0].Rows[0]["employeeId"].ToString();
         txtCustomer.Text = listMaster[0].Rows[0]["customerName"].ToString();
         txtTransportCompany.Text = listMaster[0].Rows[0]["transportationCompany"].ToString();
         txtVehicleNo.Text = listMaster[0].Rows[0]["lrNo"].ToString();
         txtNarration.Text = listMaster[0].Rows[0]["narration"].ToString();
         cmbCurrency.SelectedValue = Convert.ToDecimal(listMaster[0].Rows[0]["exchangeRateId"].ToString());
         txtTotalAmount.Text = listMaster[0].Rows[0]["totalAmount"].ToString();
         lblTaxTotalAmount.Text = listMaster[0].Rows[0]["taxAmount"].ToString();
         cmbPricingLevel.SelectedValue = Convert.ToDecimal(listMaster[0].Rows[0]["pricingLevelId"].ToString());
         if (listMaster[0].Rows[0]["quotationMasterId"].ToString() != "0")
         {
             cmbSalesMode.Text = "Against Quotation";
             againstOrderComboFill();
             cmbSalesModeOrderNo.SelectedValue = listMaster[0].Rows[0]["quotationMasterId"].ToString();
             lblSalesModeOrderNo.Text = "Quotation No";
             cmbCurrency.Enabled = false;
             cmbPricingLevel.Enabled = false;
         }
         else if (listMaster[0].Rows[0]["orderMasterId"].ToString() != "0")
         {
             cmbSalesMode.Text = "Against SalesOrder";
             againstOrderComboFill();
             cmbSalesModeOrderNo.SelectedValue = listMaster[0].Rows[0]["orderMasterId"].ToString();
             lblSalesModeOrderNo.Text = "Order No";
             cmbCurrency.Enabled = false;
             cmbPricingLevel.Enabled = false;
         }
         else if (listMaster[0].Rows[0]["deliveryNoteMasterId"].ToString() != "0")
         {
             cmbSalesMode.Text = "Against Delivery Note";
             againstOrderComboFill();
             cmbSalesModeOrderNo.SelectedValue = listMaster[0].Rows[0]["deliveryNoteMasterId"].ToString();
             lblSalesModeOrderNo.Text = "Delivery Note No";
             cmbCurrency.Enabled = false;
             cmbPricingLevel.Enabled = false;
         }
         else
         {
             cmbSalesMode.SelectedText = "NA";
         }
         if (txtInvoiceNo.Enabled)
         {
             txtDate.Focus();
         }
         else
         {
             txtInvoiceNo.Focus();
         }
         //DataTable dtblDetails = new DataTable();
         List<DataTable> listObj = new List<DataTable>();
         listObj = BllSalesInvoice.SalesInvoiceSalesDetailsViewBySalesMasterId(decSalesInvoiceIdToEdit);
         dgvSalesInvoiceTaxComboFill();
         dgvSalesInvoice.Rows.Clear();
         for (int i = 0; i < listObj[0].Rows.Count; i++)
         {
             dgvSalesInvoice.Rows.Add();
             IsSetGridValueChange = false;
             dgvSalesInvoice.Rows[i].HeaderCell.Value = string.Empty;
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesDetailsId"].Value = Convert.ToDecimal(listObj[0].Rows[i]["salesDetailsId"].ToString());
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSlno"].Value = listObj[0].Rows[i]["slNo"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBarcode"].Value = listObj[0].Rows[i]["barcode"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductCode"].Value = listObj[0].Rows[i]["productCode"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductName"].Value = listObj[0].Rows[i]["productName"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductId"].Value = listObj[0].Rows[i]["productId"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBrand"].Value = listObj[0].Rows[i]["brandName"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQty"].Value = listObj[0].Rows[i]["qty"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicePurchaseRate"].Value = listObj[0].Rows[i]["purchaseRate"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceAmount"].Value = listObj[0].Rows[i]["amount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceGrossValue"].Value = listObj[0].Rows[i]["grossAmount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicembUnitName"].Value = Convert.ToDecimal(listObj[0].Rows[i]["unitId"].ToString());
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceRate"].Value = listObj[0].Rows[i]["rate"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceGodown"].Value = Convert.ToDecimal(listObj[0].Rows[i]["godownId"].ToString());
             RackComboFill(Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceGodown"].Value.ToString()), i, dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceRack"].ColumnIndex);
             dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceRack"].Value = Convert.ToDecimal(listObj[0].Rows[i]["rackId"].ToString());
             if (listObj[0].Rows[i]["batchId"] != null && listObj[0].Rows[i]["batchId"].ToString() != string.Empty)
             {
                 dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value = Convert.ToDecimal(listObj[0].Rows[i]["batchId"].ToString());
             }
             else
             {
                 dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].Value = string.Empty;
             }
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceMrp"].Value = listObj[0].Rows[i]["mrp"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceSalesRate"].Value = listObj[0].Rows[i]["salesRate"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDiscountAmount"].Value = listObj[0].Rows[i]["discount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceNetAmount"].Value = listObj[0].Rows[i]["netAmount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceTaxName"].Value = Convert.ToDecimal(listObj[0].Rows[i]["taxId"].ToString());
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceTaxAmount"].Value = listObj[0].Rows[i]["taxAmount"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceUnitConversionId"].Value = listObj[0].Rows[i]["unitConversionId"].ToString();
             lblTotalQuantitydisplay.Text = listObj[0].Rows[i]["qty"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSISalesOrderDetailsId"].Value = Convert.ToDecimal(listObj[0].Rows[i]["orderDetailsId"].ToString());  // here get fill the grid colum for the editing prps
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDeliveryNoteDetailsId"].Value = listObj[0].Rows[i]["deliveryNoteDetailsId"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceQuotationDetailsId"].Value = listObj[0].Rows[i]["quotationDetailsId"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value = Convert.ToDecimal(listObj[0].Rows[i]["voucherTypeRefNo"].ToString());  // here get fill the grid colum for the editing prps
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherNo"].Value = listObj[0].Rows[i]["voucherRefNo"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value = listObj[0].Rows[i]["invoiceRefNo"].ToString();
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBarcode"].ReadOnly = true;
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductCode"].ReadOnly = true;
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceProductName"].ReadOnly = true;
             dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceBrand"].ReadOnly = true;
             dgvSalesInvoice.Rows[i].Cells["dgvcmbSalesInvoiceBatch"].ReadOnly = true;
             if (cmbSalesMode.SelectedIndex != 0)
             {
                 strVoucherNoTostockPost = dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherNo"].Value.ToString();
                 strInvoiceNoTostockPost = dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceInvoiceNo"].Value.ToString();
                 decVouchertypeIdTostockPost = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceVoucherTypeId"].Value);
             }
             GrossValueCalculation(i);
             DiscountCalculation(i, dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceDiscountAmount"].ColumnIndex);
             taxAndGridTotalAmountCalculation(i);
             decCurrentRate = Convert.ToDecimal(dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoiceRate"].Value.ToString());
             decCurrentConversionRate = Convert.ToDecimal(listObj[0].Rows[i]["conversionRate"].ToString());
             UnitConversionCalc(i);
             if (cmbSalesModeOrderNo.Visible == true)
             {
                 dgvSalesInvoice.Rows[i].Cells["dgvtxtSalesInvoicembUnitName"].ReadOnly = true;
             }
         }
         List<DataTable> listAdditionalCost = new List<DataTable>();
         listAdditionalCost = BllSalesInvoice.SalesInvoiceAdditionalCostViewByVoucherNoUnderVoucherType(DecSalesInvoiceVoucherTypeId, strVoucherNo);
         for (int i = 0; i < listAdditionalCost[0].Rows.Count; i++)
         {
             dgvSalesInvoiceLedger.Rows.Add();
             dgvSalesInvoiceLedger.Rows[i].Cells["dgvtxtAdditionalCostId"].Value = listAdditionalCost[0].Rows[i]["additionalCostId"].ToString();
             dgvSalesInvoiceLedger.Rows[i].Cells["dgvCmbAdditionalCostledgerName"].Value = Convert.ToDecimal(listAdditionalCost[0].Rows[i]["ledgerId"].ToString());
             dgvSalesInvoiceLedger.Rows[i].Cells["dgvtxtAdditionalCoastledgerAmount"].Value = listAdditionalCost[0].Rows[i]["amount"].ToString();
             List<DataTable> ListObj = new List<DataTable>();
             AccountLedgerBll bllAccountLedger = new AccountLedgerBll();
             ListObj = bllAccountLedger.AccountLedgerViewForAdditionalCost();
             DataGridViewComboBoxCell dgvccVoucherType = (DataGridViewComboBoxCell)dgvSalesInvoiceLedger[dgvSalesInvoiceLedger.Columns["dgvCmbAdditionalCostledgerName"].Index, i];
             dgvccVoucherType.DataSource = ListObj[0];
             dgvccVoucherType.ValueMember = "ledgerId";
             dgvccVoucherType.DisplayMember = "ledgerName";
         }
         List<DataTable> ListDrOrCr = BllSalesInvoice.salesinvoiceAdditionalCostCheckdrOrCrforSiEdit(DecSalesInvoiceVoucherTypeId, strVoucherNo);
         if (ListDrOrCr[0].Rows.Count > 0)
         {
             if (Convert.ToDecimal(ListDrOrCr[0].Rows[0]["credit"].ToString()) != 0)
             {
                 cmbCashOrbank.SelectedValue = Convert.ToDecimal(ListDrOrCr[0].Rows[0]["ledgerId"].ToString());
                 cmbCashOrbank.Visible = true;
                 lblcashOrBank.Visible = true;
                 cmbDrorCr.SelectedIndex = 0;
                 decBankOrCashIdForEdit = Convert.ToDecimal(cmbCashOrbank.SelectedValue.ToString());
             }
             else
             {
                 cmbDrorCr.SelectedIndex = 1;
             }
         }
         taxGridFill();
         List<DataTable> listTax = new List<DataTable>();
         listTax = BllSalesInvoice.SalesInvoiceSalesBillTaxViewAllBySalesMasterId(decSalesInvoiceIdToEdit);
         foreach (DataGridViewRow dgvrowTax in dgvSalesInvoiceTax.Rows)
         {
             for (int ini = 0; ini < listTax[0].Rows.Count; ini++)
             {
                 if (dgvrowTax.Cells["dgvtxtTtaxId"].Value != null && dgvrowTax.Cells["dgvtxtTtaxId"].Value.ToString() != string.Empty)
                 {
                     decimal decId = Convert.ToDecimal(listTax[0].Rows[ini]["taxId"].ToString());
                     if (dgvrowTax.Cells["dgvtxtTtaxId"].Value.ToString() == decId.ToString())
                     {
                         dgvrowTax.Cells["dgvtxtTtaxAmount"].Value = listTax[0].Rows[ini]["taxAmount"].ToString();
                         break;
                     }
                     else
                     {
                         dgvrowTax.Cells["dgvtxtTtaxAmount"].Value = "0.00";
                     }
                 }
             }
         }
         LedgerGridTotalAmountCalculation();
         SiGridTotalAmountCalculation();
         txtGrandTotal.Text = listMaster[0].Rows[0]["grandTotal"].ToString();
         txtBillDiscount.Text = listMaster[0].Rows[0]["billDiscount"].ToString();
         bool isPartyBalanceRef = false;
         AccountLedgerBll bllAccountLedger1 = new AccountLedgerBll();
         PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
         isPartyBalanceRef = bllAccountLedger1.PartyBalanceAgainstReferenceCheck(strVoucherNo, DecSalesInvoiceVoucherTypeId);
         if (isPartyBalanceRef)
         {
             cmbCashOrParty.Enabled = false;
         }
         else
         {
             cmbCashOrParty.Enabled = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SI: 77" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the fields for edit or delete
 /// </summary>
 public void FillFunction()
 {
     try
     {
         ServicesBll BllService = new ServicesBll();
         //ServiceMasterSP spServiceMaster = new ServiceMasterSP();
         ServiceMasterInfo infoServiceMaster = new ServiceMasterInfo();
         LedgerPostingBll BllLedgerPosting = new LedgerPostingBll();
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         VoucherTypeInfo infoVoucherType = new VoucherTypeInfo();
         PartyBalanceBll BllPartyBalance = new PartyBalanceBll();
         PartyBalanceInfo infoPartyBalance = new PartyBalanceInfo();
         decServiceMasterId = decMasterId;
         infoServiceMaster = BllService.ServiceMasterView(decServiceMasterId);
         infoVoucherType = BllVoucherType.VoucherTypeView(infoServiceMaster.VoucherTypeId);
         this.Text = infoVoucherType.VoucherTypeName;
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(infoServiceMaster.VoucherTypeId);
         txtInvoiceNumber.ReadOnly = true;
         strVoucherNo = infoServiceMaster.VoucherNo.ToString();
         txtInvoiceNumber.Text = infoServiceMaster.InvoiceNo;
         txtCreditPeriod.Text = infoServiceMaster.CreditPeriod.ToString();
         strInvoiceNo = infoServiceMaster.InvoiceNo.ToString();
         decServiceSuffixPrefixId = Convert.ToDecimal(infoServiceMaster.SuffixPrefixId.ToString());
         DecServicetVoucherTypeId = Convert.ToDecimal(infoServiceMaster.VoucherTypeId.ToString());
         int inDecimalPlace = PublicVariables._inNoOfDecimalPlaces;
         txtVoucherDate.Text = infoServiceMaster.Date.ToString("dd-MMM-yyyy");
         dtpVoucherDate.Value = Convert.ToDateTime(infoServiceMaster.Date);
         cmbCashParty.SelectedValue = infoServiceMaster.LedgerId;
         cmbServiceAC.SelectedValue = infoServiceMaster.ServiceAccount;
         cmbSalesman.SelectedValue = infoServiceMaster.EmployeeId;
         txtCustomer.Text = infoServiceMaster.Customer;
         txtNarration.Text = infoServiceMaster.Narration;
         List<DataTable> listObjServiceDetails = new List<DataTable>();
         listObjServiceDetails = BllService.ServiceDetailsViewWithMasterId(decServiceMasterId);
         for (int i = 0; i < listObjServiceDetails[0].Rows.Count; i++)
         {
             dgvServiceVoucher.Rows.Add();
             dgvServiceVoucher.Rows[i].Cells["dgvtxtDetailsId"].Value = Convert.ToDecimal(listObjServiceDetails[0].Rows[i]["serviceDetailsId"].ToString());
             dgvServiceVoucher.Rows[i].Cells["dgvtxtServiceMasterId"].Value = Convert.ToDecimal(listObjServiceDetails[0].Rows[i]["serviceMasterId"].ToString());
             dgvServiceVoucher.Rows[i].Cells["dgvcmbParticulars"].Value = Convert.ToDecimal(listObjServiceDetails[0].Rows[i]["serviceId"].ToString());
             dgvServiceVoucher.Rows[i].Cells["dgvtxtMeasure"].Value = listObjServiceDetails[0].Rows[i]["measure"].ToString();
             dgvServiceVoucher.Rows[i].Cells["dgvtxtAmount"].Value = listObjServiceDetails[0].Rows[i]["amount"].ToString();
             decimal decDetailsId1 = Convert.ToDecimal(listObjServiceDetails[0].Rows[i]["serviceDetailsId"].ToString());
             decimal decLedgerPostingId = BllLedgerPosting.LedgerPostingIdFromDetailsId(decDetailsId1, strVoucherNo, DecServicetVoucherTypeId);
             dgvServiceVoucher.Rows[i].Cells["dgvtxtLedgerPostingId"].Value = decLedgerPostingId.ToString();
         }
         cmbCurrency.SelectedValue = infoServiceMaster.ExchangeRateId;
         txtTotalAmount.Text = infoServiceMaster.TotalAmount.ToString();
         txtDiscount.Text = infoServiceMaster.Discount.ToString();
         txtGrandTotal.Text = infoServiceMaster.GrandTotal.ToString();
         infoPartyBalance = BllPartyBalance.PartyBalanceViewByVoucherNoAndVoucherTypeId(DecServicetVoucherTypeId, strVoucherNo, infoServiceMaster.Date);
         decPartyBalanceId = infoPartyBalance.PartyBalanceId;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SV 32 : " + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to call this form from frmSalesReturnReport to view details and for updation
 /// </summary>
 /// <param name="objSalesReturnReport"></param>
 /// <param name="decSalesReturnMasterId"></param>
 /// <param name="isFromReport"></param>
 /// <param name="isSalesReturnActive"></param>
 public void CallFromSalesReturnReport(frmSalesReturnReport objSalesReturnReport, decimal decSalesReturnMasterId, bool isFromReport, bool isSalesReturnActive)
 {
     try
     {
         VoucherTypeBll BllVoucherType = new VoucherTypeBll();
         isSalesReturnFormActive = isSalesReturnActive;
         objFromSalesReturnReport = objSalesReturnReport;
         objFromSalesReturnRegister = null;
         salesReturnMasterId = decSalesReturnMasterId;
         isFromSalesReturnReport = isFromReport;
         isInvoiceFill = true;
         decTotalAmountForEditCheck = 0;
         FillRegisterOrReport();
         isAutomatic = BllVoucherType.CheckMethodOfVoucherNumbering(decSalesReturnVoucherTypeId);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SR26:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }