예제 #1
0
        public ActionResult EditSave(long id, Z10Order xorder)
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }

            EAP.Logic.Z10.Order.Snap(id, _tenant.TenantID.Value, _user.UserID.Value, db); //制作快照

            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.CreateWithSession();
            order.Z10Order.OrderID    = null;
            order.Z10Order.OriID      = id;
            order.Z10Order.CustomerID = xorder.CustomerID;
            order.Z10Order.DateOrder  = xorder.DateOrder;
            order.Z10Order.DateShip   = xorder.DateShip;
            order.Z10Order.Currency   = xorder.Currency;
            order.Z10Order.Remark     = xorder.Remark;

            foreach (Z10OrderItem item in order.Items)
            {
                item.ItemID = null;
            }
            order.Save(_tenant.TenantID.Value, db, id);
            Session.Remove("Z10Order");
            return(Content("1"));
        }
예제 #2
0
        public ActionResult PutIn(long id)
        {
            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.LoadFromDB(id, _tenant.TenantID.Value, db);
            //Session["Z10Order"] = order;
            ViewData["db"] = db;

            return(View(order));
        }
예제 #3
0
        public ActionResult Pay(long id)
        {
            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.LoadFromDB(id, _tenant.TenantID.Value, db);

            ViewBag.banks    = db.Take <Z01Beetle.Entity.Z01Bank>("TenantID=@TenantID order by DisplayOrder", db.CreateParameter("TenantID", _tenant.TenantID));
            ViewBag.customer = db.FindUnique <Z01Beetle.Entity.Z01Customer>(order.Z10Order.CustomerID ?? 0);
            ViewBag.currency = order.Z10Order.Currency;


            return(View(order));
        }
예제 #4
0
파일: Order.cs 프로젝트: honj51/EAP
 /// <summary>
 /// 从数据库中载入订单
 /// </summary>
 /// <param name="orderID"></param>
 /// <param name="tenantID"></param>
 /// <param name="db"></param>
 /// <returns></returns>
 public static Order LoadFromDB(long orderID, Guid tenantID, Zippy.Data.IDalProvider db)
 {
     Order order = new Order();
     order.Z10Order = db.FindUnique<Z10Order>("OrderID=@OrderID and TenantID=@TenantID",
         db.CreateParameter("OrderID", orderID),
         db.CreateParameter("TenantID", tenantID));
     order.Items = db.Take<Z10OrderItem>("OrderID=@OrderID and TenantID=@TenantID",
         db.CreateParameter("OrderID", orderID),
         db.CreateParameter("TenantID", tenantID));
     return order;
 }
예제 #5
0
파일: Order.cs 프로젝트: honj51/EAP
        public static Order CreateWithSession(string orderKey)
        {
            Order order = null;
            if (System.Web.HttpContext.Current.Session[orderKey] != null)
            {
                order = System.Web.HttpContext.Current.Session[orderKey] as Order;
            }
            else
            {
                order = new Order();
                order.Z10Order = new Z10Order();
                System.Web.HttpContext.Current.Session[orderKey] = order;
            }

            return order;
        }
예제 #6
0
        public ActionResult Purchase()
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }

            //Session["Z10Order"] = null;
            ViewData["VTitle"] = "新建采购单";
            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.CreateWithSession();

            ViewData["CurrentDate"]  = DateTime.Now.ToString("yyyy-MM-dd");
            ViewData["DepotOptions"] = EAP.Logic.Z10.HtmlHelper.DepotSelectOptions(_tenant.TenantID.Value, db);
            ViewData["MoneyOptions"] = EAP.Logic.Bus.HtmlHelper.CurrencySelectOptions(order.Z10Order.Currency, db);

            return(View(order));
        }
예제 #7
0
        public ActionResult Delete(long id)
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Delete) != Zippy.SaaS.Entity.CRUD.Delete)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }

            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.LoadFromDB(id, _tenant.TenantID.Value, db);

            var index = Z10OrderHelper.Delete(db, order.Z10Order);

            if (index > 0)
            {
                return(Content("1"));
            }
            else
            {
                return(Content("0"));
            }
        }
예제 #8
0
        public ActionResult SaveItem2Session(int?index, Z10OrderItem item)
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }

            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.CreateWithSession();
            if (item.ItemID.HasValue && item.ItemID > 0)
            {
                Z10OrderItem mItem = order.Items.Where(s => s.ItemID == item.ItemID).FirstOrDefault();
                if (mItem != null)
                {
                    mItem.ExtColor    = item.ExtColor;
                    mItem.ExtSize     = item.ExtSize;
                    mItem.CountShould = item.CountShould;
                    mItem.Price       = item.Price;
                    mItem.ProductID   = item.ProductID;
                    mItem.Total       = item.Total;
                    mItem.UpdateDate  = DateTime.Now;
                }
                else
                {
                    return(Content("错误的库存商品。"));
                }
            }
            else
            {
                if (order.Items.Where(s => s.ProductID == item.ProductID && s.DepotID == item.DepotID && s.ExtColor == item.ExtColor && s.ExtSize == item.ExtSize).Count() > 0)
                {
                    return(Content("同一件商品不允许多次加入同一个仓库。"));
                }
                item.ItemStatus = index;
                item.Total      = item.Price * item.CountShould;
                order.Items.Add(item);

                //return Content("商品数量" + order.Items.Count);
            }
            //Session["Z10Order"] = order;
            return(Content("1"));
        }
예제 #9
0
        /// <summary>
        /// 修改订单G:\LiWill\EAP\LiUI\Views\User\
        /// </summary>
        /// <param name="orderID"></param>
        /// <returns></returns>
        public ActionResult Edit(long id)
        {
            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.LoadFromDB(id, _tenant.TenantID.Value, db);
            Session["Z10Order"] = order;
            return(Redirect("/z10order/Purchase/"));

            //if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update) return RedirectToAction("NoPermission", "Error");

            //ViewData["VTitle"] = "修改采购单";


            //string returnUrl = Request["ReturnUrl"];
            //if (returnUrl.IsNullOrEmpty())
            //    returnUrl = "/" + _ContollerName;

            //ViewData["ReturnUrl"] = returnUrl;
            //ViewData["DepotOptions"] = EAP.Logic.Z10.HtmlHelper.DepotSelectOptions(_tenant.TenantID.Value, db);
            //ViewData["MoneyOptions"] = EAP.Logic.Bus.HtmlHelper.CurrencySelectOptions(db);
            //ViewData["db"] = db;
            //return View(order);
        }
예제 #10
0
        public ActionResult PurchaseSave(Z10Order xorder)
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Create) != Zippy.SaaS.Entity.CRUD.Create)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }
            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.CreateWithSession();

            order.Z10Order.CustomerID = xorder.CustomerID;
            order.Z10Order.DateOrder  = xorder.DateOrder;
            order.Z10Order.DateShip   = xorder.DateShip;
            order.Z10Order.Currency   = xorder.Currency;
            order.Z10Order.Remark     = xorder.Remark;
            order.Z10Order.OrderType  = (int)EAP.Logic.Z10.OrderTypes.Purchase;
            order.Z10Order.FeeShip    = xorder.FeeShip;
            order.Z10Order.FeeShould  = xorder.FeeShould;

            order.Save(_tenant.TenantID.Value, db, null);
            Session.Remove("Z10Order");
            return(Content("1"));
        }
예제 #11
0
        public ActionResult ModiItemCountHappend2Session(int?index, Z10OrderItem item)
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }

            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.CreateWithSession();
            int xindex = index ?? 0;

            if (xindex > 0)
            {
                var currentItem = order.Items[xindex - 1]; //order.Items.Where(s => s.ItemID == item.ItemID).FirstOrDefault();

                if (currentItem != null)
                {
                    currentItem.Price         = item.Price;
                    currentItem.DepotID       = item.DepotID;
                    currentItem.DepotID2      = item.DepotID2;
                    currentItem.CountShould   = item.CountShould;
                    currentItem.CountChecked  = item.CountChecked;
                    currentItem.CountHappend  = item.CountHappend;
                    currentItem.CountHappend2 = item.CountHappend2;
                    //if (item.CountHappend2 != null)
                    //    currentItem.CountHappend2 = item.CountHappend2;
                    //else if (item.CountHappend != null)
                    //    currentItem.CountHappend = item.CountHappend;
                }
                else
                {
                    return(Content("错误的库存商品!"));
                }
            }
            else
            {
                return(Content("错误的库存商品!"));
            }

            return(Content("1"));
        }
예제 #12
0
        public ActionResult Detail(long id)
        {
            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.LoadFromDB(id, _tenant.TenantID.Value, db);
            if (order.Z10Order == null)
            {
                return(Content("订单不存在。"));
            }

            EAP.Logic.Z10.OrderTypes otype = (EAP.Logic.Z10.OrderTypes)(order.Z10Order.OrderType ?? 0);
            if (otype.BitIs(EAP.Logic.Z10.OrderTypes.Purchase))
            {
                ViewData["VTitle"] = "采购单";
            }
            else if (otype.BitIs(EAP.Logic.Z10.OrderTypes.Sale))
            {
                ViewData["VTitle"] = "销售单";
            }
            else if (otype.BitIs(EAP.Logic.Z10.OrderTypes.Transfer))
            {
                ViewData["VTitle"] = "调库单";
            }
            else
            {
                ViewData["VTitle"] = "订单";
            }
            string rUrl = Request["ReturnUrl"];

            if (rUrl.IsNullOrEmpty())
            {
                rUrl = "/Z10Order/PurchaseList";
            }
            ViewData["ReturnUrl"] = rUrl;

            //Session["Z10Order"] = order;
            ViewBag._user  = _user;
            ViewData["db"] = db;

            return(View(order));
        }
예제 #13
0
        public ActionResult RemoveItem2Session(int?productid)
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }

            if (productid.Value > 0)
            {
                EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.CreateWithSession();

                var item = order.Items.Where <Z10OrderItem>(s => s.ProductID == productid).FirstOrDefault();

                //order.Items.RemoveAt()
                if (item != null)
                {
                    order.Items.Remove(item);
                }

                //Session["Z10Order"] = order;
            }

            return(Content("1"));
        }
예제 #14
0
        public ActionResult Pay(long id, long bank, decimal feePaid, int orderStatus, string returnUrl)
        {
            decimal absPaid = Math.Abs(feePaid);

            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.LoadFromDB(id, _tenant.TenantID.Value, db);
            if (order.Z10Order.OrderType.BitIs(EAP.Logic.Z10.OrderTypes.Purchase) || order.Z10Order.OrderType.BitIs(EAP.Logic.Z10.OrderTypes.SaleReturn))
            {
                feePaid = -absPaid;
            }
            else if (order.Z10Order.OrderType.BitIs(EAP.Logic.Z10.OrderTypes.Sale) || order.Z10Order.OrderType.BitIs(EAP.Logic.Z10.OrderTypes.PurchaseReturn))
            {
                feePaid = absPaid;
            }

            var xOrderStatus = (EAP.Logic.Z10.OrderStatus)orderStatus;

            //throw new Exception(feePaid.ToString());

            if (order != null)
            {
                var result = order.Pay(_tenant.TenantID.Value, _user.UserID.Value, xOrderStatus, feePaid, bank);

                if (result)
                {
                    return(Redirect(returnUrl));
                }
                else
                {
                    return(Content("系统内部错误,请联系管理员。"));
                }
            }
            else
            {
                return(Content("不存在的采购单信息!"));
            }
        }
예제 #15
0
        public ActionResult SavePutIn(int orderStatus)
        {
            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.CreateWithSession();

            Hashtable hsItem = new Hashtable();

            foreach (var item in order.Items)
            {
                hsItem.Add(item.ItemID, item.CountHappend);
            }

            var oStatus = (EAP.Logic.Z10.OrderStatus)orderStatus;

            var result = order.InOutDepot(_tenant.TenantID.Value, _user.UserID.Value, oStatus, hsItem, db);

            if (result)
            {
                return(Content("1"));
            }
            else
            {
                return(Content("0"));
            }
        }
예제 #16
0
파일: Order.cs 프로젝트: honj51/EAP
        /// <summary>
        /// 制作一个订单的快照
        /// </summary>
        /// <param name="orderID"></param>
        /// <param name="tenantID"></param>
        /// <param name="userID"></param>
        /// <param name="db"></param>
        public static void Snap(long orderID, Guid tenantID, Guid userID, Zippy.Data.IDalProvider db)
        {
            Order order = new Order();
            order.Z10Order = db.FindUnique<Z10Order>("OrderID=@OrderID and TenantID=@TenantID",
                db.CreateParameter("OrderID", orderID),
                db.CreateParameter("TenantID", tenantID));
            order.Items = db.Take<Z10OrderItem>("OrderID=@OrderID and TenantID=@TenantID",
                db.CreateParameter("OrderID", orderID),
                db.CreateParameter("TenantID", tenantID));

            order.Z10Order.IsSnap = 1;
            order.Z10Order.UpdateDate = DateTime.Now;
            order.Z10Order.Updater = userID;
            foreach (Z10OrderItem item in order.Items)
            {
                item.UpdateDate = DateTime.Now;
                item.Updater = userID;
            }

            order.Save(tenantID, db, null);
        }
예제 #17
0
        public ActionResult ModiItem2Session(int?index, Z10OrderItem item)
        {
            if ((_crud & Zippy.SaaS.Entity.CRUD.Update) != Zippy.SaaS.Entity.CRUD.Update)
            {
                return(RedirectToAction("NoPermission", "Error"));
            }

            EAP.Logic.Z10.Order order = EAP.Logic.Z10.Order.CreateWithSession();

            //if (order.Items.Where(s => s.ProductID == item.ProductID && s.DepotID == item.DepotID && s.ExtColor == item.ExtColor && s.ExtSize == item.ExtSize).Count() > 0)
            //{
            //    return Content("同一件商品同一个规格不允许多次加入同一个仓库。");
            //}

            int xindex = index ?? 0;

            if (xindex > 0)
            {
                var currentItem = order.Items[xindex - 1]; //order.Items.Where(s => s.ItemID == item.ItemID).FirstOrDefault();

                if (currentItem != null)
                {
                    currentItem.Price         = item.Price;
                    currentItem.DepotID       = item.DepotID;
                    currentItem.DepotID2      = item.DepotID2;
                    currentItem.CountShould   = item.CountShould;
                    currentItem.CountChecked  = item.CountChecked;
                    currentItem.CountHappend  = item.CountHappend;
                    currentItem.CountHappend2 = item.CountHappend2;
                    currentItem.Total         = item.Price * item.CountShould;
                    currentItem.UpdateDate    = DateTime.Now;
                    //if (item.CountHappend2 != null)
                    //    currentItem.CountHappend2 = item.CountHappend2;
                    //else if (item.CountHappend != null)
                    //    currentItem.CountHappend = item.CountHappend;
                }
                else
                {
                    return(Content("错误的库存商品!"));
                }
            }
            else
            {
                return(Content("错误的库存商品!"));
            }


            if (item.ItemID.HasValue)
            {
                Z10OrderItem mItem = order.Items.Where(s => s.ItemID == item.ItemID).FirstOrDefault();

                if (mItem != null)
                {
                    mItem.CountShould = item.CountShould;
                    mItem.Price       = item.Price;
                    mItem.ProductID   = item.ProductID;
                    mItem.Total       = item.Total;
                    mItem.DepotID     = item.DepotID;
                    mItem.UpdateDate  = DateTime.Now;
                }
                else
                {
                    return(Content("错误的库存商品。"));
                }
            }
            else
            {
                //if (order.Items.Where(s => s.ItemStatus != index && s.ProductID == item.ProductID && s.DepotID == item.DepotID).Count() > 0)
                //{
                //    return Content("同一件商品不允许多次加入同一个仓库。");
                //}
                Z10OrderItem mItem = order.Items.Where(s => s.ItemStatus == index).FirstOrDefault();

                if (mItem != null)
                {
                    mItem.CountShould = item.CountShould;
                    mItem.Price       = item.Price;
                    mItem.ProductID   = item.ProductID;
                    mItem.Total       = item.Total;
                    mItem.UpdateDate  = DateTime.Now;
                }
                else
                {
                    return(Content("错误的库存商品。"));
                }
            }

            return(Content("1"));
        }