Beispiel #1
0
 public int SaveCategoryBanner(CategoryBanner categoryBanner)
 {
     if (categoryBanner.CategoryBannerID <= 0)
         return new CategoryBannerDL().SaveCategoryBanner(categoryBanner);
     else
         return new CategoryBannerDL().UpdateCategoryBanner(categoryBanner);
 }
Beispiel #2
0
 public CategoryBanner GetCategoryBanner(int categoryBannerID)
 {
     CategoryBanner categoryBanner = null;
     using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
     {
         using (SqlCommand objComm = new SqlCommand("categoryBanner_select", objConn))
         {
             objConn.Open();
             objComm.CommandType = CommandType.StoredProcedure;
             objComm.Parameters.Add("@categoryBannerID", SqlDbType.Int).Value = categoryBannerID;
             using (SqlDataReader reader = objComm.ExecuteReader())
             {
                 while (reader.Read())
                 {
                     categoryBanner = new CategoryBanner();
                     categoryBanner.CategoryBannerID = categoryBannerID;
                     categoryBanner.Name = reader.GetString(0);
                     categoryBanner.ImageUrl = reader.GetString(1);
                     categoryBanner.Url = reader.GetString(2);
                 }
             }
         }
     }
     return categoryBanner;
 }
Beispiel #3
0
        public int SaveCategoryBanner(CategoryBanner categoryBanner)
        {
            int status = 0;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("categoryBanner_insert", objConn))
                {
                    objConn.Open();
                    objComm.CommandType = CommandType.StoredProcedure;
                    objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = categoryBanner.Name;
                    objComm.Parameters.Add("@imageUrl", SqlDbType.NVarChar, 50).Value = categoryBanner.ImageUrl;
                    objComm.Parameters.Add("@url", SqlDbType.NVarChar, 100).Value = categoryBanner.Url;

                    status = int.Parse(objComm.ExecuteScalar().ToString());
                }
            }
            return status;
        }
Beispiel #4
0
        public int UpdateCategoryBanner(CategoryBanner categoryBanner)
        {
            int status = 0;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("categoryBanner_update", objConn))
                {
                    objConn.Open();
                    objComm.CommandType = CommandType.StoredProcedure;
                    objComm.Parameters.Add("@name", SqlDbType.NVarChar, 50).Value = categoryBanner.Name;
                    objComm.Parameters.Add("@imageUrl", SqlDbType.NVarChar, 50).Value = categoryBanner.ImageUrl;
                    objComm.Parameters.Add("@url", SqlDbType.NVarChar).Value = categoryBanner.Url;
                    objComm.Parameters.Add("@categoryBannerID", SqlDbType.Int).Value = categoryBanner.CategoryBannerID;

                    status = objComm.ExecuteNonQuery();
                }
            }
            return status;
        }
Beispiel #5
0
        private void saveCategoryBanner()
        {
            try
            {
                CategoryBanner categoryBanner = new CategoryBanner();
                categoryBanner.Name = txtCategoryBannerName.Text;
                categoryBanner.ImageUrl = imgCategoryBanner.ImageUrl.Substring(imgCategoryBanner.ImageUrl.LastIndexOf("/") + 1);
                categoryBanner.Url = txtUrl.Text;
                if (lblCategoryBannerID.Value != string.Empty)
                    categoryBanner.CategoryBannerID = int.Parse(lblCategoryBannerID.Value);

                categoryBanner.CategoryBannerID = new CategoryBannerBL().SaveCategoryBanner(categoryBanner);
                lblCategoryBannerID.Value = categoryBanner.CategoryBannerID.ToString();
            }
            catch (Exception ex)
            {
                setStatus(ex.Message, System.Drawing.Color.Red, true);
            }
        }