コード例 #1
0
ファイル: EmployeeController.cs プロジェクト: war-man/SKTIME
        public ActionResult Remove(int id)
        {
            var message = "Xóa thông tin thành công";

            if (EmployeeInfo.IsAdmin(UserID, Employee.ID, id, DbAction.Employee.Remove))
            {
                message = "Không thể xóa nhân viên có quyền admin";
            }
            else
            {
                EmployeeInfo.Remove(UserID, Employee.ID, id);
            }
            var model = EmployeeInfo.Find(UserID, Employee.ID, Employee.BussinessID, message);

            if (Request.IsAjaxRequest())
            {
                return(Json(new
                {
                    html = RenderPartialViewToString(Views.ListPartial, model)
                }, JsonRequestBehavior.AllowGet));
            }
            return(View(Views.List, model));
        }
コード例 #2
0
ファイル: ImportController.cs プロジェクト: war-man/SKTIME
        public ActionResult Submit(int id, ImexItem[] items, string note, string receipt)
        {
            var action      = id > 0 ? DbAction.Import.Modify : DbAction.Import.Create;
            var message     = "";
            int?recordID    = null;
            int warehouseID = 0;

            if (id > 0 && !EmployeeInfo.IsAdmin(UserID, Employee.ID, Employee.ID, action))
            {
                message = "Bạn không có quyền sử dụng chức năng này";
            }
            else
            {
                message = "Lưu thông tin không thành công";
                if (items != null && items.Length > 0)
                {
                    var warehouses = items.GroupBy(i => i.WarehouseID);
                    foreach (var warehouse in warehouses)
                    {
                        recordID    = SKtimeManagement.Import.Submit(id, UserID, Employee.ID, Employee.BussinessID, warehouse.Key, warehouse.ToArray(), note, receipt);
                        warehouseID = warehouse.Key;
                    }
                    if (recordID.HasValue)
                    {
                        message = "Lưu thông tin thành công";
                    }
                }
                else
                {
                    message = "Không có sản phẩm được chọn";
                }
            }
            if (!recordID.HasValue)
            {
                var model = new Import(Employee.Name,
                                       WarehouseInfo.FindAuthorized(UserID, Employee.ID, Employee.BussinessID, UserID, DbAction.Import.View),
                                       warehouseID, items, note, message)
                {
                    Receipt = receipt
                };
                model.ID = id;
                if (Request.IsAjaxRequest())
                {
                    return(Json(new
                    {
                        html = RenderPartialViewToString(Views.ImportPartial, model)
                    }, JsonRequestBehavior.DenyGet));
                }
                return(View(Views.Import, model));
            }
            else
            {
                if (Request.IsAjaxRequest())
                {
                    return(Json(new
                    {
                        result = true,
                        redirect = Url.Action("Detail", "Import", new { id = recordID.Value })
                    }, JsonRequestBehavior.DenyGet));
                }
                return(RedirectToAction(Views.Detail, new { id = recordID.Value }));
            }
        }