Ejemplo n.º 1
0
        public static void UpdateThing(Models.addKitchenModels model)
        {
            var p1 = (int)model.Category;
            var p2 = model.Article;
            var p3 = model.Name;
            var p4 = model.Description;
            var p5 = (int)model.Brand;
            var p6 = model.Id;

            GetData(String.Format(@"Update Album set category = {0}, article = N'{1}', name = N'{2}', description = N'{3}', brand = {4} where id = {5}", p1, p2, p3, p4, p5, p6));
        }
Ejemplo n.º 2
0
        public virtual ActionResult Edit(Models.addKitchenModels model)
        {
            //var aa = ModelState.Where(n => n.Value.Errors.Count > 0).ToList();
            if (ModelState.IsValid)
            {
                if (model.Id == null || model.Id == 0)
                {
                    model.Id = db.SetThing(model);
                }
                else
                {
                    db.UpdateThing(model);
                }
            }



            //if (model.AddImage != null && model.AddImage.ContentLength > 0)
            //{
            //    //получаем фотку
            //    byte[] buffer = null;
            //    using (var binaryReader = new BinaryReader(model.AddImage.InputStream))
            //    {
            //        buffer = binaryReader.ReadBytes(model.AddImage.ContentLength);
            //    }

            //    //сохраняем в базу
            //    string myConnString = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();
            //    if (string.IsNullOrEmpty(myConnString)) return View();

            //    //string queryString = String.Format(@"Insert into Images (ImageId, Image) VALUES(1,'{0}')", buffer);
            //    string queryString = String.Format(@"Insert into Images (Image) VALUES(@img)");
            //    SqlConnection conn = new SqlConnection(myConnString);
            //    SqlCommand command = new SqlCommand(queryString, conn);

            //    command.Parameters.Add("@img", SqlDbType.Binary);
            //    command.Parameters["@img"].Value = buffer;

            //    conn.Open();
            //    command.ExecuteNonQuery();
            //    conn.Close();
            //}


            return(View(model));
        }
Ejemplo n.º 3
0
        public static int SetThing(Models.addKitchenModels model)
        {
            return(int.Parse(GetData(String.Format(@"Insert into Album (category, article, name, description, brand) VALUES({0},N'{1}',N'{2}',N'{3}',{4}) SELECT SCOPE_IDENTITY() AS [SCOPE_IDENTITY]", (int)model.Category, model.Article, model.Name, model.Description, (int)model.Brand)).Rows[0]["SCOPE_IDENTITY"].ToString()));

            //return SetData(String.Format(@"Insert into Things (CategoryId, Article, Description, Features) VALUES({0},'{1}','{2}','{3}')",(int)model.Category,model.Article,model.Description,model.Features));
        }