/// <summary>
 /// Function to save the Pricinglevel
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         infoPricingLevel.PricinglevelName = txtPricingLevelName.Text.Trim();
         infoPricingLevel.Narration = txtNarration.Text.Trim();
         infoPricingLevel.Extra1 = string.Empty;
         infoPricingLevel.Extra2 = string.Empty;
         if (BllPricingLevel.PricingLevelCheckIfExist(txtPricingLevelName.Text.Trim().ToString(), 0) == false)
         {
             decPricingLevelId = BllPricingLevel.PricingLevelAddWithoutSamePricingLevel(infoPricingLevel);
             Messages.SavedMessage();
             Clear();
             decIdforOtherForms = decPricingLevelId;
             if (frmCustomerObj != null)
             {
                 this.Close();
             }
             if (frmSalesReturnObj != null)
             {
                 this.Close();
             }
             if (frmSalesInvoiceObj != null)
             {
                 this.Close();
             }
         }
         else
         {
             Messages.InformationMessage("Pricing level name already exist");
             txtPricingLevelName.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PL1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the fields for Edit or Delete 
 /// </summary>
 public void FillControls()
 {
     try
     {
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         infoPricingLevel = BllPricingLevel.PricingLevelWithNarrationView(Convert.ToDecimal(dgvPricingLevel.CurrentRow.Cells[1].Value.ToString()));
         txtPricingLevelName.Text = infoPricingLevel.PricinglevelName;
         txtNarration.Text = infoPricingLevel.Narration;
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         decPricingLevel = infoPricingLevel.PricinglevelId;
         strPricingLevel = infoPricingLevel.PricinglevelName;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PL8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// function to fill all pricing level on the datagridview
 /// </summary>
 public void Gridfill()
 {
     try
     {
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         List<DataTable> listObjPricingLevel = new List<DataTable>();
         listObjPricingLevel = BllPricingLevel.PricingLevelOnlyViewAll();
         dgvPricingLevel.DataSource = listObjPricingLevel[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("PL4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to edit the Pricing level
 /// </summary>
 public void EditFunction()
 {
     try
     {
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         infoPricingLevel.PricinglevelName = txtPricingLevelName.Text.Trim();
         infoPricingLevel.Narration = txtNarration.Text.Trim();
         infoPricingLevel.Extra1 = string.Empty;
         infoPricingLevel.Extra2 = string.Empty;
         infoPricingLevel.PricinglevelId = Convert.ToDecimal(dgvPricingLevel.CurrentRow.Cells[1].Value.ToString());
         if (txtPricingLevelName.Text.ToString() != strPricingLevel)
         {
             if (BllPricingLevel.PricingLevelCheckIfExist(txtPricingLevelName.Text.Trim().ToString(), decPricingLevel) == false)
             {
                 if (BllPricingLevel.PricingLevelEditParticularFields(infoPricingLevel))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
                 else if (infoPricingLevel.PricinglevelId == 1)
                 {
                     Messages.InformationMessage("Cannot update");
                     Clear();
                     txtPricingLevelName.Focus();
                 }
             }
             else
             {
                 Messages.InformationMessage("Pricing level name already exist");
                 txtPricingLevelName.Focus();
             }
         }
         else
         {
             BllPricingLevel.PricingLevelEditParticularFields(infoPricingLevel);
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PL2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to delete selected pricing level
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         if (BllPricingLevel.PricingLevelCheckReferenceAndDelete(decPricingLevel) <= 0)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             BllPricingLevel.PricingLevelDelete(Convert.ToDecimal(dgvPricingLevel.CurrentRow.Cells[1].Value.ToString()));
             Messages.DeletedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("PL6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill the fields while user double click on the datagridview
 /// </summary>
 public void FillControls()
 {
     try
     {
         PriceListInfo infoPricelist = new PriceListInfo();
         PriceListBll BllPriceList = new PriceListBll();
         infoPricelist.PricelistId = decpriceListId;
         infoPricelist = BllPriceList.PriceListView(decpriceListId);
         txtRate.Text = infoPricelist.Rate.ToString();
         ProductInfo infoProduct = new ProductInfo();
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         infoProduct = BllProductCreation.PriceListPopUpView(decProductId);
         txtProductCode.Text = infoProduct.ProductCode;
         txtProductName.Text = infoProduct.ProductName;
         BatchInfo infobatch = new BatchInfo();
        // BatchSP spBatch = new BatchSP();
         BatchBll BllBatch = new BatchBll();
         infobatch = BllBatch.BatchView(decBatchId);
         cmbBatch.SelectedValue = infobatch.BatchId;
         UnitInfo infoUnit = new UnitInfo();
         UnitBll bllUnit = new UnitBll();
         infoUnit = bllUnit.UnitView(decUnitId);
         txtUnitName.Text = infoUnit.UnitName;
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         infoPricingLevel = BllPricingLevel.PricingLevelView(decPriceLevelId);
         txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         txtProductName.ReadOnly = true;
         txtProductCode.ReadOnly = true;
         txtUnitName.ReadOnly = true;
         txtPricingLevel.ReadOnly = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PLP9:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to execute while calling from frmPriceList form to add new pricelist for the product
 /// </summary>
 /// <param name="decPricingLevel"></param>
 /// <param name="decProduct"></param>
 /// <param name="decPriceListId"></param>
 /// <param name="frmPriceList"></param>
 public void CallFromPriceListForPricingLevel(decimal decPricingLevel, decimal decProduct, decimal decPriceListId, frmPriceList frmPriceList)
 {
     try
     {
         ProductInfo infoProduct = new ProductInfo();
         ProductCreationBll BllProductCreation = new ProductCreationBll();
         UnitBll bllUnit = new UnitBll();
         UnitInfo infoUnit = new UnitInfo();
         PriceListBll BllPriceList = new PriceListBll();
         PriceListInfo infoPriceList = new PriceListInfo();
         PricingLevelBll BllPricingLevel = new PricingLevelBll();
         PricingLevelInfo infoPricingLevel = new PricingLevelInfo();
         infoProduct = BllProductCreation.PriceListPopUpView(decProduct);
         txtProductCode.Text = infoProduct.ProductCode;
         txtProductName.Text = infoProduct.ProductName;
         decProduct = infoProduct.ProductId;
         decProductMain = infoProduct.ProductId;
         infoUnit = bllUnit.UnitViewForPriceListPopUp(decProduct);
         decUnitId = infoUnit.UnitId;
         txtUnitName.Text = infoUnit.UnitName;
         decPriceLevelId = infoPriceList.PricinglevelId;
         infoPricingLevel = BllPricingLevel.PricingLevelNameViewForPriceListPopUp(decPricingLevel, decProduct, decUnitId);
         decPriceLevelId = infoPricingLevel.PricinglevelId;
         txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         if (txtPricingLevel.Text == string.Empty)
         {
             infoPricingLevel = BllPricingLevel.PricingLevelView(decPricingLevel);
             txtPricingLevel.Text = infoPricingLevel.PricinglevelName;
         }
         decPricingLevelMain = infoPricingLevel.PricinglevelId;
         txtPricingLevel.ReadOnly = true;
         txtProductCode.ReadOnly = true;
         txtProductName.ReadOnly = true;
         txtUnitName.ReadOnly = true;
         txtRate.Focus();
         BatchUnderProductComboFill(decProduct);
         PriceListPopupGridFill();
         deca = decPriceListId;
         this.frmPriceListobj = frmPriceList;
     }
     catch (Exception ex)
     {
         MessageBox.Show("PLP1" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        /// <summary>
        ///Function to fill pricing level combobox
        /// </summary> 
        public void PrlicingLevelComboFill()
        {
            try
            {
                PricingLevelBll BllPricingLevel = new PricingLevelBll();
                List<DataTable> listObjPrlicingLevel = new List<DataTable>();
                listObjPrlicingLevel = BllPricingLevel.PricelistPricingLevelViewAllForComboBox();
                cmbPricingLevel.DataSource = listObjPrlicingLevel[0];
                //DataRow dr = listObjPrlicingLevel[0].NewRow();
                //dr[1] = 0;
                //dr[0] = 0;
                //listObjPrlicingLevel[0].Rows.InsertAt(dr, 0);
                cmbPricingLevel.ValueMember = "pricinglevelId";
                cmbPricingLevel.DisplayMember = "pricinglevelName";

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