コード例 #1
0
        public ActionResult Delivered(int id)
        {
            Export.Delivered(UserID, Employee.ID, Employee.BussinessID, id);
            var record = Export.GetExport(UserID, Employee.ID, id);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.Products, record)
                }, JsonRequestBehavior.AllowGet));
            }
            var model = new ExportList();

            model.List    = Export.History(UserID, Employee.ID, Employee.BussinessID);
            model.Current = record;
            return(View(Views.History, model));
        }
コード例 #2
0
        public ActionResult Detail(int id)
        {
            var record = Export.GetExport(UserID, Employee.ID, id, true);

            foreach (var product in record.Products)
            {
                product.ProductUrl = RenderPartialViewToString("ProductUrl", product);
            }
            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.Products, record)
                }, JsonRequestBehavior.AllowGet));
            }
            var model = new ExportList();

            model.List    = Export.History(UserID, Employee.ID, Employee.BussinessID);
            model.Current = record;
            return(View(Views.History, model));
        }
コード例 #3
0
        public ActionResult Submit(OrderRecord record, FormCollection collection)
        {
            record.EmployeeName = Employee.Name;
            var action      = record.ID > 0 ? DbAction.Order.Modify : DbAction.Order.Create;
            var unavailable = ImexItem.Unavailable(UserID, Employee.ID, record.WarehouseID, action, record.Items, record.ID);
            var orderID     = 0;
            var message     = "";
            var result      = false;
            var login       = Login.Get(UserID);

            //if (record.ID > 0 && login.Username != "admin" && login.Type != LoginType.Office)
            //    message = "Bạn không có quyền cập nhật hóa đơn";
            if (unavailable.Count > 0)
            {
                message = String.Format("Số lượng vượt mức tồn kho:<br/>{0}", String.Join("<br/>", unavailable.Select(i => i.Name)));
            }
            else if (record.ClientID == 0 && (String.IsNullOrEmpty(record.ClientName) || String.IsNullOrEmpty(record.ClientPhone)))
            {
                message = "Thiếu thông tin khách hàng (tên, số điện thoại)";
            }
            else if (record.Items.Sum(i => i.Quantity * i.Price) - record.Discount - record.Paid != 0)
            {
                message = "Tổng tiền khuyến mãi và đã trả không bằng tổng tiền hóa đơn";
            }
            else
            {
                message = "Lưu thông tin không thành công";
                if (record.Items != null && record.Items.Length > 0)
                {
                    if (login.Username != "admin" && record.ID == 0)
                    {
                        record.SubmitDate = DateTime.Now;
                    }
                    if (login.Username != "admin")
                    {
                        record.NewEmployeeID = null;
                    }
                    if ((orderID = SKtimeManagement.Export.SaveOrder(UserID, Employee.ID, Employee.BussinessID, record)) > 0)
                    {
                        message = "Lưu thông tin thành công";
                        result  = true;
                    }
                }
                else
                {
                    message = "Không có sản phẩm được chọn";
                }
            }
            if (result)
            {
                // trigger creating income when do exchange product on order
                if (collection["Action"] == "Exchange")
                {
                    using (var data = new DataClassesDataContext())
                    {
                        data.TriggerInsertIncome(record.ID, Employee.ID, Employee.BussinessID, record.WarehouseID, record.Code, BaseModel.NewUniqueCode(UserID, Employee.ID, Employee.BussinessID, "Income"), DateTime.Now, Convert.ToDecimal(collection["TotalTransactionPaid"]));
                    }
                }

                var model = new ExportList();
                model.List    = Export.OrderHistory(UserID, Employee.ID, Employee.BussinessID);
                model.Current = Export.GetOrder(UserID, Employee.ID, orderID);
                foreach (var product in model.Current.Products)
                {
                    product.ProductUrl = RenderPartialViewToString("ProductUrl", product);
                }
                foreach (var product in model.Current.ReturnProducts)
                {
                    product.ProductUrl = RenderPartialViewToString("ProductUrl", product);
                }
                if (Request.IsAjaxRequest())
                {
                    return(Json(new
                    {
                        html = RenderPartialViewToString(Views.HistoryPartial, model)
                    }, JsonRequestBehavior.DenyGet));
                }
                return(RedirectToAction(Views.History));
            }
            else
            {
                var data  = ImexItem.Find(UserID, Employee.ID, action, Employee.BussinessID);
                var model = new Export(
                    WarehouseInfo.FindAuthorized(UserID, Employee.ID, Employee.BussinessID, UserID, DbAction.Order.View),
                    record, login.Username == "admin", message, result);
                if (record.Return)
                {
                    var returnRecord = new OrderRecord(Export.GetOrder(UserID, Employee.ID, record.ID), true);
                    var items        = model.Selected.ToList();
                    items.AddRange(returnRecord.Items);
                    model.Selected = items.ToArray();
                }
                if (Request.IsAjaxRequest())
                {
                    return(Json(new
                    {
                        html = RenderPartialViewToString(Views.ExportPartial, model)
                    }, JsonRequestBehavior.DenyGet));
                }
                return(RedirectToAction(Views.Export));
            }
        }
コード例 #4
0
        public ActionResult Submit(int id, int warehouseID, int?toWarehouseID, ImexItem[] items, string note, string status)
        {
            var action      = id > 0 ? DbAction.Export.Modify : DbAction.Export.Create;
            var unavailable = ImexItem.Unavailable(UserID, Employee.ID, warehouseID, action, items, 0, id);
            var exportID    = 0;
            var message     = "";
            var result      = false;
            var login       = Login.Get(UserID);

            if (id > 0 && login.Username != "admin" && login.Type != LoginType.Office)
            {
                message = "Bạn không có quyền cập nhật phiếu xuất";
            }
            else if (unavailable.Count > 0)
            {
                message = String.Format("Số lượng vượt mức tồn kho:<br/>{0}", String.Join("<br/>", unavailable.Select(i => i.Name)));
            }
            else if (toWarehouseID.HasValue && toWarehouseID.Value == warehouseID)
            {
                message = "Kho nhận trùng kho xuất";
            }
            else
            {
                message = "Lưu thông tin không thành công";
                if (items != null && items.Length > 0)
                {
                    if ((exportID = SKtimeManagement.Export.Submit(id, UserID, Employee.ID, Employee.BussinessID, warehouseID, toWarehouseID, status, items, note)) > 0)
                    {
                        message = "Lưu thông tin thành công";
                        result  = true;
                    }
                }
                else
                {
                    message = "Không có sản phẩm được chọn";
                }
            }
            if (result)
            {
                var model = new ExportList();
                model.List    = Export.History(UserID, Employee.ID, Employee.BussinessID);
                model.Current = Export.GetExport(UserID, Employee.ID, exportID);
                foreach (var product in model.Current.Products)
                {
                    product.ProductUrl = RenderPartialViewToString("ProductUrl", product);
                }
                if (Request.IsAjaxRequest())
                {
                    return(Json(new
                    {
                        html = RenderPartialViewToString(Views.HistoryPartial, model)
                    }, JsonRequestBehavior.DenyGet));
                }
                return(RedirectToAction(Views.History));
            }
            else
            {
                var model = new Export(Employee.Name,
                                       WarehouseInfo.FindAuthorized(UserID, Employee.ID, Employee.BussinessID, UserID, DbAction.Export.View),
                                       toWarehouseID, status, warehouseID, items, note, message, result);
                model.ID       = id;
                model.Editable = login.Username == "admin";
                if (Request.IsAjaxRequest())
                {
                    return(Json(new
                    {
                        html = RenderPartialViewToString(Views.ExportPartial, model)
                    }, JsonRequestBehavior.DenyGet));
                }
                return(RedirectToAction(Views.Export));
            }
        }