Esempio n. 1
0
        public ActionResult Edit(Model.Flower Flower)
        {
            Business.Sys_Flower Sys_Flower = new Business.Sys_Flower();
            //Model.Flower Flowers = Sys_Flower.GetFlowerByFlowerNumber(Flower.FlowerNumber);

            if (Request.Files["attach_path"] != null)
            {
                HttpPostedFileBase file = Request.Files["attach_path"];
                if (!string.IsNullOrEmpty(file.FileName))
                {
                    DeleteFlowerPhoto(Flower.FlowerWatchPhoto);
                    Flower.FlowerWatchPhoto = Utility.ChangeText.SaveUploadPicture(file, "FlowerPhoto");
                }
            }
            //else
            //{
            //    Flower.FlowerWatchPhoto = Flowers.FlowerWatchPhoto;
            //}
            //ViewData["success"] = "修改失败";
            if (Sys_Flower.UpdateFlowerWatch(Flower))
            {
                // ViewData["success"] = "修改成功";
            }
            Response.Write("<script>parent.layer.closeAll();</script>");
            return(View());
        }
Esempio n. 2
0
        public ActionResult PayOrdersNow(string Remark)
        {
            #region 生成订单
            string ids = Request["ids"].TrimEnd(',');
            Business.Sys_Flower        Sys_Flower        = new Business.Sys_Flower();
            Business.Sys_OrdersManaage Sys_OrdersManaage = new Business.Sys_OrdersManaage();
            string[] idarry        = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            string   FlowerNum     = Request["FlowerNums"];
            string[] FlowerNumarry = FlowerNum.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            string ConsigneAaddress = Request["DetailedAddress"];
            string ConsigneeName    = Request["ConsigneeName"];
            string ConsigneePhone   = Request["ConsigneePhone"];
            //唯一的订单
            Model.Orders Orders = new Model.Orders();
            Orders.UsersId          = int.Parse(userid);
            Orders.CreateTime       = DateTime.Now;
            Orders.OrdersState      = 1;
            Orders.OrderId          = Utility.ChangeText.OrderIdCreate();
            Orders.GoodsSum         = int.Parse(Request["goodnum"]);// 总件数
            Orders.ConsigneeName    = ConsigneeName;
            Orders.ConsigneePhone   = ConsigneePhone;
            Orders.ConsigneAaddress = ConsigneAaddress;
            //详情列表
            List <Model.OrdersDetails> OrdersDetailsList = new List <Model.OrdersDetails>();
            for (int j = 0; j < idarry.Length; j++)
            {
                //每一种花
                Model.Flower Flower = Sys_Flower.GetFlower(idarry[j]);
                Orders.SellingPrice += Flower.FlowerSalesPrice * int.Parse(FlowerNumarry[j]);
                Orders.CostPrice    += Flower.FlowerCostPrice * int.Parse(FlowerNumarry[j]);
                //每种花对应的数量
                for (int i = 0; i < int.Parse(FlowerNumarry[j]); i++)
                {
                    Model.OrdersDetails OrdersDetails = new Model.OrdersDetails();
                    OrdersDetails.OrderId          = Orders.OrderId;
                    OrdersDetails.FlowerNumber     = Flower.FlowerNumber;
                    OrdersDetails.FlowerWatchName  = Flower.FlowerWatchName;
                    OrdersDetails.FlowerWatchPhoto = Flower.FlowerWatchPhoto;
                    OrdersDetails.SellingPrice     = Flower.FlowerSalesPrice;
                    OrdersDetails.SellingNum       = 1;
                    OrdersDetails.CostPrice        = Flower.FlowerCostPrice;
                    OrdersDetailsList.Add(OrdersDetails);
                }
            }
            Model.OrdersLog OrdersLog = new Model.OrdersLog();
            OrdersLog.OrdersId    = Orders.OrderId;
            OrdersLog.OrdersState = 1;
            OrdersLog.UserName    = Utility.ChangeText.GetUserName();
            OrdersLog.Remark      = Remark;
            OrdersLog.Time        = DateTime.Now;

            #endregion
            Sys_OrdersManaage.TransactionAddOrders(Orders, OrdersDetailsList, OrdersLog);
            //return Redirect("/WxPay/Index?OrdersId=" + Orders.OrderId + "&PayTotal=" + Orders.SellingPrice);
            return(Json(new { OrdersId = Orders.OrderId, PayTotal = Orders.SellingPrice }, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public ActionResult Delete()
        {
            Business.Sys_Flower Sys_Flower = new Business.Sys_Flower();
            string id = Request["id"];

            Model.Flower Flower = Sys_Flower.GetFlower(id);
            if (Sys_Flower.DeleteFlowerWatch(id))
            {
                DeleteFlowerPhoto(Flower.FlowerWatchPhoto);
                return(Content("True"));
            }
            return(Content("Fasle"));
        }
Esempio n. 4
0
 public ActionResult AddByExcel(HttpPostedFileBase files)
 {
     try
     {
         files = Request.Files["file"];
         string path = Utility.ChangeText.SaveUploadPicture(files, "xlt");
         Business.Sys_Flower Sys_Flower = new Business.Sys_Flower();
         DataTable           dt         = new DataTable();
         string templetpath             = Server.MapPath("~") + path;
         dt = Utility.Excel.ExcelToTable(templetpath);
         if (dt.Rows.Count <= 0)
         {
             Response.Write("<script>parent.layer.alert('导入失败!');</script>");
             return(View());
         }
         dt.Rows.RemoveAt(0);
         List <Model.Flower> list = Sys_Flower.GetFlowerList();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             Model.Flower model = new Model.Flower();
             model.FlowerNumber = GetFlowerNum();
             var fname = dt.Rows[i][0].ToString();//检查名称重复
             if (list.Count(m => m.FlowerWatchName.Contains(fname)) < 1)
             {
                 model.FlowerWatchName = fname;
             }
             model.FlowerWatchType    = dt.Rows[i][1].ToString();
             model.FlowerStock        = Convert.ToInt32(dt.Rows[i][2].ToString());
             model.FlowerCostPrice    = Convert.ToInt32(dt.Rows[i][3].ToString());
             model.FlowerSalesPrice   = Convert.ToDecimal(dt.Rows[i][4].ToString());
             model.FlowerIntroduction = dt.Rows[i][5].ToString();
             model.XiXin        = dt.Rows[i][6].ToString();
             model.YangHuFangFa = dt.Rows[i][7].ToString();
             Sys_Flower.InsertFlowerWatch(model);
         }
         //删除上传的导入文件
         if (System.IO.File.Exists(templetpath))
         {
             System.IO.File.Delete(templetpath);
         }
         Response.Write("<script>parent.layer.alert('导入成功!');parent.layer.closeAll();</script>");
         return(View());
     }
     catch (Exception ex)
     {
         Utility.Log.WriteTextLog("导入Excel", "异常", ex.ToString(), "", "");
         Response.Write("<script>parent.layer.alert('表格格式或数据有误!');</script>");
         return(View());
     }
 }
Esempio n. 5
0
        public ActionResult Add(Model.Flower Flower)
        {
            HttpPostedFileBase file = Request.Files["attach_path"];

            Flower.FlowerNumber     = GetFlowerNum();
            Flower.FlowerWatchPhoto = Utility.ChangeText.SaveUploadPicture(file, "FlowerPhoto");
            Business.Sys_Flower Sys_Flower = new Business.Sys_Flower();
            //ViewData["success"] = "添加失败";
            if (Sys_Flower.InsertFlowerWatch(Flower))
            {
                //ViewData["success"] = "添加成功";
            }
            Response.Write("<script>parent.layer.closeAll();</script>");
            return(View());
        }
Esempio n. 6
0
        public ActionResult CreateOrders()
        {
            string GoodsId = Request["GoodsId"];

            Business.Sys_Flower Sys_Flower = new Business.Sys_Flower();
            Model.Flower        Flower     = Sys_Flower.GetFlowerByFlowerNumber(GoodsId);
            //判断库存是否足够商品
            if (Flower.FlowerStock < Convert.ToInt32(Request["FlowerStock"]))
            {
                ViewData["success"] = "抱歉,库存不足";
                return(View());
            }
            Model.Orders Orders = new Model.Orders();
            Orders.OrderId          = Utility.ChangeText.GenerateOutTradeNo();
            Orders.OrdersState      = 1;
            Orders.SellingPrice     = Flower.FlowerSalesPrice * Convert.ToInt32(Request["FlowerStock"]);
            Orders.CostPrice        = Flower.FlowerCostPrice * Convert.ToInt32(Request["FlowerStock"]);
            Orders.ConsigneAaddress = Request["ConsigneAaddress"];
            Orders.ConsigneeName    = Request["ConsigneeName"];
            Orders.GoodsSum         = Convert.ToInt32(Request["FlowerStock"]);
            Orders.ConsigneePhone   = Request["ConsigneePhone"];
            List <Model.OrdersDetails> OrdersDetailsList = new List <Model.OrdersDetails> ();

            for (int i = 0; i < Convert.ToInt32(Request["FlowerStock"]); i++)
            {
                Model.OrdersDetails OrdersDetails = new Model.OrdersDetails();
                OrdersDetails.OrderId          = Orders.OrderId;
                OrdersDetails.SellingPrice     = Flower.FlowerSalesPrice;
                OrdersDetails.FlowerNumber     = Flower.FlowerNumber;
                OrdersDetails.CostPrice        = Flower.FlowerCostPrice;
                OrdersDetails.FlowerWatchPhoto = Flower.FlowerWatchPhoto;
                OrdersDetails.SellingNum       = 1;
                OrdersDetails.FlowerWatchName  = Flower.FlowerWatchName;
                OrdersDetailsList.Add(OrdersDetails);
            }
            Model.OrdersLog OrdersLog = new Model.OrdersLog();
            OrdersLog.OrdersId    = Orders.OrderId;
            OrdersLog.OrdersState = 1;
            OrdersLog.UserName    = Utility.ChangeText.GetUserName();
            Business.Sys_OrdersManaage Sys_OrdersManaage = new Business.Sys_OrdersManaage();
            if (!Sys_OrdersManaage.InsertOrders(Orders, OrdersDetailsList, OrdersLog))
            {
                ViewData["success"] = "下单失败,请联系管理员";
                return(View());
            }
            return(RedirectToAction("", ""));
        }
Esempio n. 7
0
        /// <summary>
        /// 修改一条记录
        /// </summary>
        /// <param name="Flower"></param>
        /// <returns></returns>
        public bool UpdateFlowerWatch(Model.Flower Flower)
        {
            const string sql =
                @"UPDATE  Flower SET FlowerWatchName=@FlowerWatchName,FlowerWatchPhoto=@FlowerWatchPhoto,FlowerCostPrice=@FlowerCostPrice,FlowerSalesPrice=@FlowerSalesPrice,
FlowerStock=@FlowerStock,FlowerIntroduction=@FlowerIntroduction,FlowerWatchType=@FlowerWatchType,XiXin=@XiXin,YangHuFangFa=@YangHuFangFa  WHERE id=@id";

            return(Factory.DBHelper.ExecSQL(SQLConString, sql.ToString(), new DynamicParameters(new
            {
                Flower.FlowerWatchName,
                Flower.FlowerWatchPhoto,
                Flower.FlowerCostPrice,
                Flower.FlowerSalesPrice,
                Flower.FlowerStock,
                Flower.FlowerIntroduction,
                Flower.FlowerWatchType,
                Flower.XiXin,
                Flower.YangHuFangFa,
                Flower.id,
            })));
        }
Esempio n. 8
0
        /// <summary>
        /// 写入一条记录
        /// </summary>
        /// <param name="Flower"></param>
        /// <returns></returns>
        public bool InsertFlowerWatch(Model.Flower Flower)
        {
            const string sql =
                @"INSERT INTO Flower(FlowerWatchName,FlowerWatchPhoto,FlowerCostPrice,FlowerSalesPrice,FlowerStock,FlowerIntroduction,FlowerWatchType,XiXin,YangHuFangFa,FlowerNumber) 
 VALUES(@FlowerWatchName,@FlowerWatchPhoto,@FlowerCostPrice,@FlowerSalesPrice,@FlowerStock,@FlowerIntroduction,@FlowerWatchType,@XiXin,@YangHuFangFa,@FlowerNumber)";

            return(Factory.DBHelper.ExecSQL(SQLConString, sql.ToString(), new DynamicParameters(new
            {
                Flower.FlowerWatchName,
                Flower.FlowerWatchPhoto,
                Flower.FlowerCostPrice,
                Flower.FlowerSalesPrice,
                Flower.FlowerStock,
                Flower.FlowerIntroduction,
                Flower.FlowerWatchType,
                Flower.XiXin,
                Flower.YangHuFangFa,
                Flower.FlowerNumber,
            })));
        }
Esempio n. 9
0
        public ActionResult PayOrders(string id)
        {
            #region 生成订单
            ////string id = Request["id"];
            //Business.Sys_Flower Sys_Flower = new Business.Sys_Flower();
            //Model.Flower Flower = Sys_Flower.GetFlower(id);
            //string FlowerNum = Request["FlowerNum"];
            //string address = Request["province"] + Request["city"] + Request["area"] + Request["ConsigneAaddress"];
            //string ConsigneeName = Request["ConsigneeName"];
            //string ConsigneePhone = Request["ConsigneePhone"];
            //Model.Orders Orders = new Model.Orders();
            //Orders.UsersId = Utility.ChangeText.GetUsersId();
            //Orders.CreateTime = DateTime.Now;
            //Orders.SellingPrice = Flower.FlowerSalesPrice * int.Parse(FlowerNum);
            //Orders.OrdersState = 1;
            //Orders.OrderId = Utility.ChangeText.OrderIdCreate();
            //Orders.GoodsSum = int.Parse(FlowerNum);
            //Orders.CostPrice = Flower.FlowerCostPrice * int.Parse(FlowerNum);
            //Orders.ConsigneeName = ConsigneeName;
            //Orders.ConsigneePhone = ConsigneePhone;
            //Orders.ConsigneAaddress = address;
            //List<Model.OrdersDetails> OrdersDetailsList = new List<Model.OrdersDetails>();
            //for (int i = 0; i < int.Parse(FlowerNum); i++)
            //{
            //    Model.OrdersDetails OrdersDetails = new Model.OrdersDetails();
            //    OrdersDetails.OrderId = Orders.OrderId;
            //    OrdersDetails.FlowerNumber = Flower.FlowerNumber;
            //    OrdersDetails.FlowerWatchName = Flower.FlowerWatchName;
            //    OrdersDetails.FlowerWatchPhoto = Flower.FlowerWatchPhoto;
            //    OrdersDetails.SellingPrice = Flower.FlowerSalesPrice;
            //    OrdersDetails.SellingNum = 1;//从原来的FlowerNum修改成1
            //    OrdersDetails.CostPrice = Flower.FlowerCostPrice;
            //    OrdersDetailsList.Add(OrdersDetails);
            //}
            //Model.OrdersLog OrdersLog = new Model.OrdersLog();
            //OrdersLog.OrdersId = Orders.OrderId;
            //OrdersLog.OrdersState = 1;
            //OrdersLog.UserName = Utility.ChangeText.GetUserName();
            //OrdersLog.Remark = "商品详情页中下单";
            //OrdersLog.Time = DateTime.Now;

            //Business.Sys_OrdersManaage Sys_OrdersManaage = new Business.Sys_OrdersManaage();
            //Sys_OrdersManaage.InsertOrders(Orders, OrdersDetailsList, OrdersLog);
            #endregion
            ViewData["ids"] = id;
            ViewData["msg"] = " 提示:请在30分钟内完成在线支付,逾期将视为订单无效";
            Business.Sys_Flower Sys_Flower = new Business.Sys_Flower();
            Model.Flower        flower     = Sys_Flower.GetFlower(id);
            Model.FlowerCartVM  fc         = new Model.FlowerCartVM();
            fc.Id               = 0;
            fc.FlowerId         = flower.id.ToString();
            fc.Num              = int.Parse(Request["FlowerNum"]);
            fc.FlowerSalesPrice = flower.FlowerSalesPrice;
            fc.FlowerWatchPhoto = flower.FlowerWatchPhoto;
            fc.FlowerWatchName  = flower.FlowerWatchName;
            List <Model.FlowerCartVM> list = new List <Model.FlowerCartVM> {
                fc
            };
            Model.CartLine model = new Model.CartLine();
            model.Products = list;
            return(View(model));
        }