protected void LoadGridViewCategoriesOverview() { CategoriesOverviewCS cat = new CategoriesOverviewCS(); GridViewCategories.DataSource = cat.GetCategoriesOverview(); GridViewCategories.DataBind(); }
protected void ImageButtonCategoryAdd_Click(object sender, ImageClickEventArgs e) { DataTable dt = new DataTable(); DataSet ds = new DataSet(); SqlConnection sqlConn = new SqlConnection(ConfigurationManager.ConnectionStrings["ShopConnectionString"].ConnectionString); SqlDataAdapter sda = new SqlDataAdapter("sp_couponsCategoryAddCheckExists", sqlConn); sda.SelectCommand.CommandType = CommandType.StoredProcedure; sda.SelectCommand.Parameters.Add("@CategoryId", SqlDbType.VarChar).Value = TextBoxCategoryId.Text; sda.SelectCommand.Parameters.Add("@CategoryName", SqlDbType.NVarChar).Value = TextBoxCategoryName.Text; sda.Fill(ds); dt = ds.Tables[0]; if (dt.Rows.Count == 0) //user doesn't exist { SqlCommand sqlCmd = new SqlCommand("sp_couponsCategoryAdd", sqlConn); sqlCmd.CommandType = CommandType.StoredProcedure; sqlCmd.Parameters.Add("@CategoryId", SqlDbType.VarChar).Value = TextBoxCategoryId.Text; sqlCmd.Parameters.Add("@CategoryName", SqlDbType.NVarChar).Value = TextBoxCategoryName.Text; sqlConn.Open(); sqlCmd.ExecuteNonQuery(); GridViewCategories.DataBind(); sqlCmd.Dispose(); sqlConn.Dispose(); sda.Dispose(); LabelAddCategoryMessage.Visible = true; LabelAddCategoryMessage.Text = "زمینه با مشخصات وارد شده اضافه گردید."; LabelAddCategoryMessage.CssClass = "SuccessMessage"; } else //user exists as an admin { LabelAddCategoryMessage.Visible = true; LabelAddCategoryMessage.Text = "زمینه با مشخصات وارد شده موجود می باشد."; LabelAddCategoryMessage.CssClass = "ErrorMessage"; sda.Dispose(); sqlConn.Close(); } }