/// <summary>
 /// Function to save service category
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         ServiceCategoryInfo infoServiceCategory = new ServiceCategoryInfo();
         ServiceCategoryBll  BllServiceCatogory  = new ServiceCategoryBll();
         infoServiceCategory.CategoryName = txtServiceCategory.Text.Trim();
         infoServiceCategory.Narration    = txtNarration.Text.Trim();
         infoServiceCategory.Extra1       = string.Empty;
         infoServiceCategory.Extra2       = string.Empty;
         if (BllServiceCatogory.ServiceCategoryCheckIfExist(txtServiceCategory.Text.Trim().ToString(), 0) == false)
         {
             decId = BllServiceCatogory.ServiceCategoryAddSpecificFields1(infoServiceCategory);
             Messages.SavedMessage();
             Clear();
         }
         else
         {
             Messages.InformationMessage("Service category name already exist");
             txtServiceCategory.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SC3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill saved servicecategories in the grid
 /// </summary>
 public void Gridfill()
 {
     try
     {
         List <DataTable>   listObjServiceCategory = new List <DataTable>();
         ServiceCategoryBll BllServiceCatogory     = new ServiceCategoryBll();
         listObjServiceCategory        = BllServiceCatogory.ServiceCategoryParticularFieldsViewAll();
         dgvServiceCategory.DataSource = listObjServiceCategory[0];
     }
     catch (Exception ex)
     {
         MessageBox.Show("SC2" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Category ComboFill Function
 /// </summary>
 public void CategoryComboFill()
 {
     try
     {
         ServiceCategoryBll BllServiceCatogory     = new ServiceCategoryBll();
         List <DataTable>   listObjServiceCatogery = new List <DataTable>();
         listObjServiceCatogery    = BllServiceCatogory.ServiceCategoryViewAll();
         cmbCategory.DataSource    = listObjServiceCatogery[0];
         cmbCategory.ValueMember   = "serviceCategoryId";
         cmbCategory.DisplayMember = "categoryName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ser1:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to fill controlls to edit or delete
 /// </summary>
 public void FillControls()
 {
     try
     {
         ServiceCategoryInfo infoServiceCategory = new ServiceCategoryInfo();
         ServiceCategoryBll  BllServiceCatogory  = new ServiceCategoryBll();
         infoServiceCategory     = BllServiceCatogory.ServiceCategoryWithNarrationView(Convert.ToDecimal(dgvServiceCategory.CurrentRow.Cells[1].Value.ToString()));
         txtServiceCategory.Text = infoServiceCategory.CategoryName;
         txtNarration.Text       = infoServiceCategory.Narration;
         btnSave.Text            = "Update";
         btnDelete.Enabled       = true;
         strCategoryName         = infoServiceCategory.CategoryName;
         decCategoryName         = infoServiceCategory.ServicecategoryId;
     }
     catch (Exception ex)
     {
         MessageBox.Show("SC8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Category Search combo fill
 /// </summary>
 public void CategorySearchFill()
 {
     try
     {
         ServiceCategoryBll BllServiceCatogory     = new ServiceCategoryBll();
         List <DataTable>   listObjServiceCatogery = new List <DataTable>();
         listObjServiceCatogery = BllServiceCatogory.ServiceCategoryViewAll();
         DataRow dr = listObjServiceCatogery[0].NewRow();
         dr[1] = "All";
         listObjServiceCatogery[0].Rows.InsertAt(dr, 0);
         cmbCategorySearch.DataSource    = listObjServiceCatogery[0];
         cmbCategorySearch.ValueMember   = "serviceCategoryId";
         cmbCategorySearch.DisplayMember = "categoryName";
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ser3:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to delete a servicecategory
 /// </summary>
 public void DeleteFunction()
 {
     try
     {
         ServiceCategoryBll BllServiceCatogory = new ServiceCategoryBll();
         if (BllServiceCatogory.ServiceCategoryCheckReferenceAndDelete(decCategoryName) == -1)
         {
             Messages.ReferenceExistsMessage();
         }
         else
         {
             BllServiceCatogory.ServiceCategoryDelete(Convert.ToDecimal(dgvServiceCategory.CurrentRow.Cells[1].Value.ToString()));
             Messages.DeletedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SC6" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to edit a service category
 /// </summary>
 public void EditFunction()
 {
     try
     {
         ServiceCategoryInfo infoServiceCategory = new ServiceCategoryInfo();
         ServiceCategoryBll  BllServiceCatogry   = new ServiceCategoryBll();
         infoServiceCategory.CategoryName      = txtServiceCategory.Text.Trim();
         infoServiceCategory.Narration         = txtNarration.Text.Trim();
         infoServiceCategory.Extra1            = string.Empty;
         infoServiceCategory.Extra2            = string.Empty;
         infoServiceCategory.ServicecategoryId = Convert.ToDecimal(dgvServiceCategory.CurrentRow.Cells["dgvtxtservicecategoryId"].Value.ToString());
         if (txtServiceCategory.Text.ToString() != strCategoryName)
         {
             if (BllServiceCatogry.ServiceCategoryCheckIfExist(txtServiceCategory.Text.Trim().ToString(), 0) == false)
             {
                 if (BllServiceCatogry.ServiceCategoryEditParticularFeilds(infoServiceCategory))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
             }
             else
             {
                 Messages.InformationMessage("Service category name already exist");
                 txtServiceCategory.Focus();
             }
         }
         else
         {
             BllServiceCatogry.ServiceCategoryEditParticularFeilds(infoServiceCategory);
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("SC4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }