Пример #1
0
        public static bool EditKovka(KovkaDTO order)
        {
            //List<ProductDTO> ProductsList = new List<ProductDTO>();
            using (SqlConnection conn = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("sp_update_kraska", conn);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id", order.Id);
                cmd.Parameters.AddWithValue("@name", order.Name);
                cmd.Parameters.AddWithValue("@desc", order.Description);
                cmd.Parameters.AddWithValue("@price", order.Price);
                cmd.Parameters.AddWithValue("@type", order.Type);
                cmd.Parameters.AddWithValue("@discount", order.Discount);



                conn.Open();
                //dt.Load(cmd.ExecuteReader());
                cmd.ExecuteNonQuery();


                return(true);
            }
        }
Пример #2
0
        public bool CreateКovka([FromForm] KovkaDTO str)
        {
            bool isAdded = false;

            isAdded = DataProvider.AddKovka(str, out var id);
            string path = @"imgs\kovka\" + id;

            Directory.CreateDirectory(path);
            if (str.Img1?.Length > 0)
            {
                var filePath = path + @"\1.jpg";
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    str.Img1.CopyTo(fileStream);
                }
            }
            if (str.Img2?.Length > 0)
            {
                var filePath = path + @"\2.jpg";
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    str.Img2.CopyTo(fileStream);
                }
            }
            if (str.Img3?.Length > 0)
            {
                var filePath = path + @"\3.jpg";
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    str.Img3.CopyTo(fileStream);
                }
            }
            return(isAdded);
        }
Пример #3
0
        public bool EditKovka(KovkaDTO str)
        {
            bool isAdded = false;

            isAdded = DataProvider.EditKovka(str);

            return(isAdded);
        }
Пример #4
0
        public static bool AddKovka(KovkaDTO order, out int id)
        {
            int cnt = 0;

            if (order.Img1 != null)
            {
                cnt++;
            }
            if (order.Img2 != null)
            {
                cnt++;
            }
            if (order.Img3 != null)
            {
                cnt++;
            }
            //DataTable dt = new DataTable();

            //List<ProductDTO> ProductsList = new List<ProductDTO>();
            using (SqlConnection conn = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("sp_insert_kovka", conn);

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@name", order.Name);
                cmd.Parameters.AddWithValue("@desc", order.Description);
                cmd.Parameters.AddWithValue("@price", order.Price);
                cmd.Parameters.AddWithValue("@type", order.Type);
                cmd.Parameters.AddWithValue("@discount", order.Discount);
                cmd.Parameters.AddWithValue("@imgscount", cnt);

                //cmd.Parameters.Add("@items", SqlDbType.Structured);
                //cmd.Parameters.Add("@items", SqlDbType.Structured);
                //cmd.Parameters.Add("@items", SqlDbType.Structured);
                SqlParameter outParameter = new SqlParameter("@id", SqlDbType.Int);
                outParameter.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(outParameter);

                //cmd.Parameters["@items"].Value = order.Items;
                //cmd.Parameters.AddWithValue("@items", order.Items);


                conn.Open();
                //dt.Load(cmd.ExecuteReader());
                cmd.ExecuteNonQuery();
                id = Convert.ToInt32(outParameter.Value);
                //foreach (DataRow dr in dt.Rows)
                //{
                //	ProductsList.Add(dr.ConvertToProductDTO());
                //}

                return(true);
            }
        }