Exemplo n.º 1
0
        public bool DeleteGroup(Product item)
        {
            bool result = false;
            using (StoredProcedure sp = new StoredProcedure("Products_DeleteGroup"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;

                result = sp.ExecuteNonQuery() > 0;
            }
            return result;
        }
Exemplo n.º 2
0
 public int AddUpdate(Product item)
 {
     int newID = 0;
     using (StoredProcedure sp = new StoredProcedure("Products_AddUpdateItem"))
     {
         sp.Params.Add("LangCode", System.Data.SqlDbType.NChar).Value = item.LangCode;
         sp.Params.Add("Name", System.Data.SqlDbType.NVarChar).Value = item.Name;
         sp.Params.Add("GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;
         sp.Params.Add("OrderNumber", System.Data.SqlDbType.Int).Value = item.OrderNumber;
         sp.Params.Add("CategoryID", System.Data.SqlDbType.Int).Value = item.CategoryID;
         sp.Params.Add("Url", System.Data.SqlDbType.NVarChar).Value = Tools.FixUrl(item.Url);
         newID = Convert.ToInt32(sp.ExecuteScalar());
         item.ID = newID;
     }
     return newID;
 }
Exemplo n.º 3
0
 private void Save()
 {
     foreach (RepeaterItem item in RepeaterLang.Items)
     {
         if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
         {
             ProductEditor editor = (ProductEditor)item.FindControl("editor");
             editor.CategoryID = Int32.Parse(ddlCategory.SelectedValue);
             editor.SaveItem();
         }
     }
     if(fuImage.HasFile)
     {
         Products ps = new Products();
         Product p = new Product();
         p.Image = fuImage.FileBytes;
         p.ImageName = Path.GetFileName(fuImage.FileName);
         p.ImageType = fuImage.PostedFile.ContentType;
         p.GroupID = this.GroupID;
         if(ps.UpdateImageByGroupID(p))
             btnDeleteImage.Visible = true;
     }
     GridViewItemsList.DataBind();
     //add new after saving
     //if (Convert.ToInt32(GridViewItemsList.SelectedValue) == 0)
     //    GroupID = Categories.GetNextCategoryGroupID();
     //RepeaterLang.DataBind();
 }
Exemplo n.º 4
0
 public List<Product> GetAllByLanguage(string language)
 {
     List<Product> all = new List<Product>();
     using (StoredProcedure sp = new StoredProcedure("Products_GetAllByLanguage"))
     {
         sp.Params.Add("@LangCode", SqlDbType.NChar).Value = language;
         using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
         {
             if (r != null)
             {
                 while (r.Read())
                 {
                     Product item = new Product();
                     item.ID = Convert.ToInt32(r["ID"]);
                     item.LangCode = Convert.ToString(r["LangCode"]);
                     item.Name = Convert.ToString(r["Name"]);
                     item.GroupID = Convert.ToInt32(r["GroupID"]);
                     item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                     item.CategoryID = Convert.ToInt32(r["CategoryID"]);
                     item.Url = Convert.ToString(r["Url"]);
                     item.ImageLenght = Convert.ToInt32(r["ImageLenght"]);
                     all.Add(item);
                 }
             }
         }
     }
     return all;
 }
Exemplo n.º 5
0
 public bool UpdateImageByGroupID(Product item)
 {
     bool result = false;
     using (StoredProcedure sp = new StoredProcedure("Products_UpdateImage"))
     {
         sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = item.GroupID;
         sp.Params.Add("@Image", System.Data.SqlDbType.Image).Value = item.Image;
         sp.Params.Add("@ImageName", System.Data.SqlDbType.NVarChar).Value = item.ImageName;
         sp.Params.Add("@ImageType", System.Data.SqlDbType.NVarChar).Value = item.ImageType;
         result = sp.ExecuteNonQuery() > 0;
     }
     return result;
 }
Exemplo n.º 6
0
        public Product GetProductImageByGroupID(string langCode, int groupId)
        {
            Product item = null;
            using (StoredProcedure sp = new StoredProcedure("Products_GetProductImageByGroupID"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = groupId;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NVarChar).Value = langCode;
                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    DataTable table = new DataTable();
                    table.Load(r);
                    if (table.Rows.Count > 0)
                    {
                        DataRow row = table.Rows[0];
                        item = new Product();
                        item.ID = Convert.ToInt32(row["ID"]);
                        item.LangCode = Convert.ToString(row["LangCode"]);
                        item.Name = Convert.ToString(row["Name"]);
                        item.GroupID = Convert.ToInt32(row["GroupID"]);
                        item.OrderNumber = Convert.ToInt32(row["OrderNumber"]);
                        item.CategoryID = Convert.ToInt32(row["CategoryID"]);
                        item.Url = Convert.ToString(row["Url"]);
                        item.ImageLenght = Convert.ToInt32(row["ImageLenght"]);
                        try
                        {
                            item.Image = (byte[])row["Image"];
                            item.ImageName = Convert.ToString(row["ImageName"]);
                            item.ImageType = Convert.ToString(row["ImageType"]);
                        }
                        catch (Exception)
                        {

                        }

                    }
                }
            }
            return item;
        }
Exemplo n.º 7
0
        public Product GetByLangGroup(string language, int groupId)
        {
            Product item = null;
            using (StoredProcedure sp = new StoredProcedure("Products_GetByLangGroup"))
            {
                sp.Params.Add("@GroupID", System.Data.SqlDbType.Int).Value = groupId;
                sp.Params.Add("@LangCode", System.Data.SqlDbType.NChar).Value = language;
                using (SqlDataReader r = (SqlDataReader)sp.ExecuteReader())
                {
                    if (r != null && r.Read())
                    {
                        item = new Product();
                        item.ID = Convert.ToInt32(r["ID"]);
                        item.LangCode = Convert.ToString(r["LangCode"]);
                        item.Name = Convert.ToString(r["Name"]);
                        item.GroupID = Convert.ToInt32(r["GroupID"]);
                        item.OrderNumber = Convert.ToInt32(r["OrderNumber"]);
                        item.CategoryID = Convert.ToInt32(r["CategoryID"]);
                        item.Url = Convert.ToString(r["Url"]);
                        item.ImageLenght = Convert.ToInt32(r["ImageLenght"]);

                    }
                }
            }
            return item;
        }