Exemple #1
0
 /// <summary>
 /// Function to Update values in ServiceCategory Table
 /// </summary>
 /// <param name="servicecategoryinfo"></param>
 public void ServiceCategoryEdit(ServiceCategoryInfo servicecategoryinfo)
 {
     try
     {
         if (sqlcon.State == ConnectionState.Closed)
         {
             sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("ServiceCategoryEdit", sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam = new SqlParameter();
         sprmparam       = sccmd.Parameters.Add("@servicecategoryId", SqlDbType.Decimal);
         sprmparam.Value = servicecategoryinfo.ServicecategoryId;
         sprmparam       = sccmd.Parameters.Add("@categoryName", SqlDbType.VarChar);
         sprmparam.Value = servicecategoryinfo.CategoryName;
         sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam.Value = servicecategoryinfo.Narration;
         sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam.Value = servicecategoryinfo.Extra1;
         sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam.Value = servicecategoryinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         sqlcon.Close();
     }
 }
Exemple #2
0
        /// <summary>
        /// Function to add values to ServiceCategory Table
        /// </summary>
        /// <param name="servicecategoryinfo"></param>
        /// <returns></returns>
        public decimal ServiceCategoryAddSpecificFields1(ServiceCategoryInfo servicecategoryinfo)
        {
            int decId = 0;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceCategoryAddSpecificFields", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@categoryName", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.CategoryName;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.Extra2;
                decId           = Convert.ToInt32(sccmd.ExecuteScalar());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(decId);
        }
Exemple #3
0
        /// <summary>
        /// Function to view details based on parameter
        /// </summary>
        /// <param name="decServiceCategoryId"></param>
        /// <returns></returns>
        public ServiceCategoryInfo ServiceCategoryWithNarrationView(decimal decServiceCategoryId)
        {
            ServiceCategoryInfo ServiceCategoryinfo = new ServiceCategoryInfo();
            SqlDataReader       sdrreader           = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceCategoryWithNarrationView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@serviceCategoryId", SqlDbType.Decimal);
                sprmparam.Value = decServiceCategoryId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    ServiceCategoryinfo.ServicecategoryId = Convert.ToDecimal(sdrreader[0].ToString());
                    ServiceCategoryinfo.CategoryName      = sdrreader[1].ToString();
                    ServiceCategoryinfo.Narration         = sdrreader[2].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(ServiceCategoryinfo);
        }
Exemple #4
0
 /// <summary>
 /// Function to save service category
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         ServiceCategoryInfo infoServiceCategory = new ServiceCategoryInfo();
         ServiceCategorySP   spServiceCategory   = new ServiceCategorySP();
         infoServiceCategory.CategoryName = txtServiceCategory.Text.Trim();
         infoServiceCategory.Narration    = txtNarration.Text.Trim();
         infoServiceCategory.Extra1       = string.Empty;
         infoServiceCategory.Extra2       = string.Empty;
         if (spServiceCategory.ServiceCategoryCheckIfExist(txtServiceCategory.Text.Trim().ToString(), 0) == false)
         {
             decId = spServiceCategory.ServiceCategoryAddSpecificFields1(infoServiceCategory);
             Messages.SavedMessage();
             Clear();
         }
         else
         {
             Messages.InformationMessage("Service category name already exist");
             txtServiceCategory.Focus();
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SC3" + ex.Message;
     }
 }
Exemple #5
0
 /// <summary>
 /// Function to fill controlls to edit or delete
 /// </summary>
 public void FillControls()
 {
     try
     {
         ServiceCategoryInfo infoServiceCategory = new ServiceCategoryInfo();
         ServiceCategorySP   spServiceCategory   = new ServiceCategorySP();
         infoServiceCategory     = spServiceCategory.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)
     {
         formMDI.infoError.ErrorString = "SC8" + ex.Message;
     }
 }
Exemple #6
0
        /// <summary>
        /// Function to add values and return corresponding row's id
        /// </summary>
        /// <param name="servicecategoryinfo"></param>
        /// <returns></returns>
        public bool ServiceCategoryAddSpecificFields(ServiceCategoryInfo servicecategoryinfo)
        {
            bool isSave = false;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceCategoryAddSpecificFields", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@categoryName", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.CategoryName;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.Narration;
                sprmparam       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.Extra1;
                sprmparam       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.Extra2;
                int inWork = sccmd.ExecuteNonQuery();
                if (inWork > 0)
                {
                    isSave = true;
                }
                else
                {
                    isSave = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(isSave);
        }
Exemple #7
0
        /// <summary>
        /// Function to check status for Update
        /// </summary>
        /// <param name="servicecategoryinfo"></param>
        /// <returns></returns>
        public bool ServiceCategoryEditParticularFeilds(ServiceCategoryInfo servicecategoryinfo)
        {
            bool isEdit = false;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("ServiceCategoryEditParticularFeilds", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@serviceCategoryId", SqlDbType.Decimal);
                sprmparam.Value = servicecategoryinfo.ServicecategoryId;
                sprmparam       = sccmd.Parameters.Add("@categoryName", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.CategoryName;
                sprmparam       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
                sprmparam.Value = servicecategoryinfo.Narration;
                int inAffectedRows = sccmd.ExecuteNonQuery();
                if (inAffectedRows > 0)
                {
                    isEdit = true;
                }
                else
                {
                    isEdit = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sqlcon.Close();
            }
            return(isEdit);
        }
Exemple #8
0
 /// <summary>
 /// Function to edit a service category
 /// </summary>
 public void EditFunction()
 {
     try
     {
         ServiceCategoryInfo infoServiceCategory = new ServiceCategoryInfo();
         ServiceCategorySP   spServiceCategory   = new ServiceCategorySP();
         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 (spServiceCategory.ServiceCategoryCheckIfExist(txtServiceCategory.Text.Trim().ToString(), 0) == false)
             {
                 if (spServiceCategory.ServiceCategoryEditParticularFeilds(infoServiceCategory))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
             }
             else
             {
                 Messages.InformationMessage("Service category name already exist");
                 txtServiceCategory.Focus();
             }
         }
         else
         {
             spServiceCategory.ServiceCategoryEditParticularFeilds(infoServiceCategory);
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         formMDI.infoError.ErrorString = "SC4" + ex.Message;
     }
 }