Exemplo n.º 1
0
        /// <summary>
        /// Create a new BeautyPrice
        /// </summary>
        /// <param name="newBeautyPrice">new BeautyPrice</param>
        /// <returns>new BeautyPrice id</returns>
        public Guid Create(BeautyPrice newBeautyPrice)
        {
            string sql = string.Format("EXEC sp_Price_c {0},{1},{2},{3},{4},{5},{6},{7},{8}"
                                       , ToQuote(newBeautyPrice.ID)
                                       , ToQuote(newBeautyPrice.Pricename)
                                       , ToQuote(newBeautyPrice.Price)
                                       , ToQuote(newBeautyPrice.PromotionPrice)
                                       , ToQuote(CurrentUserName)
                                       , ToQuote(DateTime.Now)
                                       , ToQuote(CurrentUserName)
                                       , ToQuote(DateTime.Now)
                                       , ToQuote(newBeautyPrice.Statues)

                                       );

            try
            {
                int rowcount = SqlHelper.ExecuteNonQuery(ConnectStr, CommandType.Text, sql);

                if (rowcount == 1)
                {
                    return(newBeautyPrice.ID);
                }
                else
                {
                    throw new Exception("SQL execution failed");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("SQL execution failed", ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete an existing BeautyPrice
        /// </summary>
        /// <param name="thisBeautyPrice">BeautyPrice</param>
        /// <returns>bool</returns>
        public bool Delete(BeautyPrice thisBeautyPrice)
        {
            string sql = string.Format("exec dbo.sp_Price_d {0} "
                                       , ToQuote(thisBeautyPrice.ID)

                                       );

            try
            {
                int rowcount = SqlHelper.ExecuteNonQuery(ConnectStr, CommandType.Text, sql);

                if (rowcount >= 1)
                {
                    return(true);
                }
                else
                {
                    throw new Exception("SQL execution failed");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("SQL execution failed", ex);
            }
        }
Exemplo n.º 3
0
        public ActionResult PriceEdit(string id)
        {
            BeautyPrice price    = iprice.Get(new Guid(id));
            WebPrice    webprice = AutoMapper.Mapper.Map <WebPrice>(price);

            return(View(webprice));
        }
Exemplo n.º 4
0
        public ActionResult PriceEdit(WebPrice webprice)
        {
            BeautyPrice price = AutoMapper.Mapper.Map <BeautyPrice>(webprice);

            price.Statues = 1;
            bool isupdate = iprice.Update(price);

            if (isupdate)
            {
                return(RedirectToAction("Pricesetting"));
            }
            return(View());
        }
Exemplo n.º 5
0
        /// <summary>
        /// Don't repeat yourself! This private function is for shared by all query public functions
        /// </summary>
        /// <param name="sql"></param>
        /// <param name="page"></param>
        /// <param name="pg"></param>
        /// <returns></returns>
        IList <BeautyPrice> GetBeautyPrices(string sql, int page, string sortKey, out PaginationInfo paging)
        {
            using (DataSet ds = SqlHelper.ExecuteDataset(ConnectStr, CommandType.Text, sql))
            {
                if (ds == null || ds.Tables.Count != 2)
                {
                    throw new Exception("SQL execution failed");
                }
                else
                {
                    List <BeautyPrice> Comments = new List <BeautyPrice>();

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        BeautyPrice Comment = new BeautyPrice()
                        {
                            ID             = new Guid(dr["id"].ToString()),
                            Price          = ParseDecimal(dr["Price"].ToString()),
                            Pricename      = ParseStr(dr["Pricename"]),
                            PromotionPrice = ParseNDecimal(dr["PromotionPrice"].ToString()),
                            Statues        = ParseInt(dr["Statues"]),
                            Createby       = ParseStr(dr["Createby"]),
                            Createtime     = ParseStr(dr["Createtime"]),
                            Updateby       = ParseStr(dr["Updateby"]),
                            Updatetime     = ParseStr(dr["Updatetime"])
                        };

                        Comments.Add(Comment);
                    }


                    paging = new PaginationInfo()
                    {
                        Current      = page,
                        Size         = ParseInt(ds.Tables[1].Rows[0]["pagesize"]),
                        TotalRecords = ParseInt(ds.Tables[1].Rows[0]["totalrecords"]),
                        TotalPages   = (int)Math.Ceiling(ParseInt(ds.Tables[1].Rows[0]["totalrecords"]) /
                                                         ParseFloat(ds.Tables[1].Rows[0]["pagesize"]))
                    };

                    return(Comments);
                }
            }
        }
Exemplo n.º 6
0
        public ActionResult PriceCreate(WebPrice model)
        {
            if (string.IsNullOrEmpty(model.Pricename))
            {
                ModelState.AddModelError("", "产品名称不能空");
            }

            if (ModelState.IsValid)
            {
                BeautyPrice price = AutoMapper.Mapper.Map <BeautyPrice>(model);
                price.Statues = 1;
                price.ID      = Guid.NewGuid();
                Guid id = iprice.Create(price);
                if (id == price.ID)
                {
                    return(RedirectToAction("Pricesetting"));
                }
            }

            return(View());
        }