Esempio n. 1
0
        public ActionResult Edit(ViewItemMaintenance view)
        {
            var        userinfo = LoginUserInfo.GetUserInfo();
            ResultInfo resultInfo;

            try
            {
                resultInfo = ResultInfo.Parse(
                    Proc.ProcUpdateItem(
                        db,
                        view.CN_ITEM_CODE,
                        view.CN_NAME,
                        view.CN_WEIGHT,
                        view.CN_UNIT,
                        view.CN_PRODUCTLINECODE,
                        view.CN_TYPEIDS,
                        userinfo)
                    );
            }
            catch (Exception ex)
            {
                resultInfo = ResultInfo.Fail(ex.Message);
            }
            return(Json(resultInfo));
        }
Esempio n. 2
0
        public JsonResult UserAdd(int groupid, UserProductLibraryView[] users)
        {
            if (groupid == 0 || users.Length == 0)
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            //添加用户
            List <AppWorkgroupUser> users2add = new List <AppWorkgroupUser>();
            DateTime now = DateTime.Now;

            foreach (var user in users)
            {
                users2add.Add(new AppWorkgroupUser
                {
                    CN_GROUPID      = groupid,
                    CN_USERID       = user.id,
                    CN_USERNAME     = user.name,
                    CN_DT_CREATE    = now,
                    CN_CREATE_BY    = LoginUserInfo.GetUserInfo().UserId,
                    CN_CREATE_LOGIN = LoginUserInfo.GetUserInfo().Login,
                    CN_CREATE_NAME  = LoginUserInfo.GetUserInfo().Name
                });
            }
            db.AppWorkgroupUsers.AddRange(users2add);
            db.SaveChanges();
            return(Json(ResultInfo.Success("添加成功。")));
        }
Esempio n. 3
0
        /// <summary>自动打印订单下货单数据
        /// </summary>
        /// <param name="warehouseId"></param>
        /// <param name="saleFilialeId"></param>
        /// <param name="salePlatformIds"></param>
        /// <param name="expressIds"></param>
        /// <param name="isPrintInvoice"></param>
        /// <param name="topNum"></param>
        /// <param name="orderType"></param>
        /// <returns></returns>
        public ResultInfo <List <OrderPrintDataDTO> > AutoPrintOrderBills(Guid warehouseId, Guid saleFilialeId, List <Guid> salePlatformIds, List <Guid> expressIds, Boolean isPrintInvoice, int topNum, int orderType)
        {
            if (warehouseId == default(Guid) || saleFilialeId == default(Guid) || salePlatformIds.Count == 0 || expressIds.Count == 0)
            {
                return(ResultInfo <List <OrderPrintDataDTO> > .Fail(PARAMETER_MSG));
            }
            var printBillsRequest = new PrintBillsRequest
            {
                WarehouseId        = warehouseId,
                SaleFilialeId      = saleFilialeId,
                SalePlatformIds    = salePlatformIds,
                ExpressIds         = expressIds,
                IsAutoPrintInvoice = isPrintInvoice,
                StorageType        = ConfigManager.StorageType,
                TopNum             = topNum == 0 ? 1000 : topNum,
                OrderType          = (byte)orderType
            };

            try
            {
                var url = String.Format("{0}", AssembleRequestUrl(_apiControllerName, "AutoPrintOrderBills"));
                var httpResponseMessage = GetApiRequestJsonResultWithParmas(url, ToJson(printBillsRequest));
                if (string.IsNullOrWhiteSpace(httpResponseMessage))
                {
                    return(ResultInfo <List <OrderPrintDataDTO> > .Fail(ERROR_MSG));
                }
                return(ToObj <ResultInfo <List <OrderPrintDataDTO> > >(httpResponseMessage));
            }
            catch (Exception ex)
            {
                return(ResultInfo <List <OrderPrintDataDTO> > .Fail(ex.Message));
            }
        }
Esempio n. 4
0
        public JsonResult SearchByTypePageList(ViewItemByType view, string[] typenames, int page = 1, int rows = 10)
        {
            if (typenames == null || typenames.Length == 0)
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }

            var query = db.ViewItemsByType.Where(where => typenames.Contains(where.typename));

            if (!string.IsNullOrWhiteSpace(view.code))
            {
                var codes = view.code.Split(',');
                query = query.Where(obj => codes.Contains(obj.code));
            }
            if (!string.IsNullOrWhiteSpace(view.name))
            {
                query = query.Where(obj => obj.name.Contains(view.name));
            }
            if (!string.IsNullOrWhiteSpace(view.itemcode))
            {
                var itemcodes = view.itemcode.Split(',');
                query = query.Where(obj => itemcodes.Contains(obj.itemcode));
            }
            var list  = query.OrderByDescending(obj => obj.code).Skip((page - 1) * rows).Take(rows).ToList();
            var count = query.Count();

            return(Json(ResultInfo.Success(new { rows = list, total = count })));
        }
Esempio n. 5
0
        public JsonResult AddProduct(Guid guid_line, string[] itemcodes)
        {
            if (guid_line == Guid.Empty || itemcodes == null || itemcodes.Length == 0)
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            List <AppProductionLineProduct> list = new List <AppProductionLineProduct>();
            DateTime now  = DateTime.Now;
            var      user = LoginUserInfo.GetLoginUser();

            for (int i = 0, j = itemcodes.Length; i < j; i++)
            {
                list.Add(new AppProductionLineProduct
                {
                    CN_GUID             = Guid.NewGuid(),
                    CN_GUID_LINE        = guid_line,
                    CN_PRODUCT_ITEMCODE = itemcodes[i],
                    CN_DT_EFFECTIVE     = now,
                    CN_DT_EXPIRY        = DateTime.Parse("2100-01-01"),
                    CN_DT_CREATE        = now,
                    CN_CREATE_BY        = user.UserId,
                    CN_CREATE_LOGIN     = user.Login,
                    CN_CREATE_NAME      = user.Name
                });
            }
            db.AppProductionLineProducts.AddRange(list);
            db.SaveChanges();
            return(Json(ResultInfo.Success("添加成功!")));
        }
Esempio n. 6
0
        public JsonResult AddProductVer(AppProductionLineProcessVer model)
        {
            if (model.CN_GUID_LINE_PRODUCT == Guid.Empty)
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            if (string.IsNullOrWhiteSpace(model.CN_NAME))
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var user = LoginUserInfo.GetLoginUser();
            var date = DateTime.Now;

            model.CN_GUID         = Guid.NewGuid();
            model.CN_DT_CREATE    = date;
            model.CN_DT_EFFECTIVE = date;
            model.CN_DT_EXPIRY    = DateTime.Parse("2100-01-01");
            model.CN_DT_TOERP     = DateTime.Parse("2100-01-01");
            model.CN_CREATE_BY    = user.UserId;
            model.CN_CREATE_LOGIN = user.Login;
            model.CN_CREATE_NAME  = user.Name;
            db.AppProductionLineProcessVers.Add(model);
            db.SaveChanges();
            return(Json(ResultInfo.Success("添加成功")));
        }
Esempio n. 7
0
        public ActionResult Delete(int id)
        {
            var item = db.AppItems.SingleOrDefault(where => where.CN_ID == id);

            if (item == null)
            {
                return(Json(ResultInfo.Fail("物料不存在,或已经被删除,请刷新后重试。")));
            }
            // TODO:检测是否被引用
            if (item == null)
            {
                return(Json(ResultInfo.Fail("物料已经被引用,无法进行删除。")));
            }

            if (item.CN_PDM_CLS_ID != 0)
            {
                return(Json(ResultInfo.Fail("物料非自定义添加的物料,无法删除!")));
            }
            if (item.CN_IS_TOERP > 0)
            {
                return(Json(ResultInfo.Fail("物料已发布到ERP系统,无法删除!")));
            }
            db.AppItemHLinks.RemoveRange(db.AppItemHLinks.Where(where => where.CN_ID == item.CN_ID));
            db.AppBoms.RemoveRange(db.AppBoms.Where(where => where.CN_CODE == item.CN_CODE));
            db.AppItems.Remove(item);
            db.SaveChanges();
            return(Json(ResultInfo.Success("已成功删除自定义物料")));
        }
Esempio n. 8
0
        public JsonResult ProductProcessInfo(string prod_itemcode)
        {
            if (string.IsNullOrEmpty(prod_itemcode))
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var itemlist = (from p
                            in db.AppProcessVers
                            join pvl
                            in db.AppProcessVerHlinks
                            on p.CN_ID equals pvl.CN_ID
                            where
                            pvl.CN_SYS_STATUS.Equals("Y") &&
                            p.CN_ITEM_CODE.TrimEnd().Equals(prod_itemcode.TrimEnd()) &&
                            p.CN_SYS_STATUS.Equals("Y")
                            orderby pvl.CN_GX_CODE
                            select new ProcItemProcess
            {
                HLINK_ID = pvl.CN_HLINK_ID,
                GX_NAME = pvl.CN_GX_NAME,
                GX_CODE = pvl.CN_GX_CODE,
                GXNR = pvl.CN_GXNR
            });

            return(Json(ResultInfo.Success(itemlist.ToList())));
        }
Esempio n. 9
0
        public JsonResult Add(UserProductLibraryView view)
        {
            var userinfo = LoginUserInfo.GetLoginUser();

            if (string.IsNullOrWhiteSpace(view.name))
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            //判断是否重名
            var list = db.UserProductLibraries.Where(where => where.ParentId == view.parentid && where.Name.Trim() == view.name.Trim()).ToList();

            if (list.Count > 0)
            {
                return(Json(ResultInfo.Fail("之前已经创建过新节点,请先编辑新节点名称")));
            }
            var model = Mapper.Map <UserProductLibrary>(view);

            model.CreateBy    = userinfo.UserId;
            model.CreateLogin = userinfo.Login;
            model.CreateName  = userinfo.Name;
            model             = db.UserProductLibraries.Add(model);
            db.SaveChanges();
            var rt = Mapper.Map <UserProductLibraryView>(model);

            return(Json(ResultInfo.Success(rt)));
        }
Esempio n. 10
0
        public JsonResult Edit(int roleId, int[] menuIds)
        {
            //判断role是否存在,不存在刷新
            BaseDbContext db       = new BaseDbContext();
            SysRole       roleInfo = db.SysRoles.Find(roleId);

            if (roleInfo == null)
            {
                return(Json(ResultInfo.Fail(Lang.RoleNotExist)));
            }
            db.SysRoleRights.RemoveRange(db.SysRoleRights.Where(w => w.RoleId == roleId));
            if (menuIds == null)
            {
                db.SaveChanges();
                return(Json(ResultInfo.Success(Lang.EditRoleRightSuccess)));
            }
            List <SysRoleRight> list = new List <SysRoleRight>();

            for (int i = 0; i < menuIds.Length; i++)
            {
                list.Add(new SysRoleRight
                {
                    RoleId  = roleId,
                    RightId = menuIds[i]
                });
            }
            db.SysRoleRights.AddRange(list);
            db.SaveChanges();
            return(Json(ResultInfo.Success(Lang.EditRoleRightSuccess)));
        }
Esempio n. 11
0
        public override void OnException(ExceptionContext filterContext)
        {
            base.OnException(filterContext);
            //处理
            //获取出错的【控制器】和【动作】
            string controllerName = (string)filterContext.RouteData.Values["controller"];
            string actionName     = (string)filterContext.RouteData.Values["action"];
            string errMsg         = filterContext.Exception.Message;
            string innerErrMsg    = filterContext.Exception.InnerException == null ? "没有详细错误信息" : filterContext.Exception.InnerException.Message;

            //
            log.ErrorFormat("{0}.{1};{2}{3}。", controllerName, actionName, errMsg, innerErrMsg);
            //
            filterContext.ExceptionHandled = true;
#if DEBUG
            // 调试用代码
            filterContext.ExceptionHandled = false;
#endif
            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                switch (filterContext.HttpContext.Response.StatusCode)
                {
                case 403:
                    filterContext.Result = new JsonResult {
                        Data = ResultInfo.Fail("用户没有操作权限"), JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                    break;

                case 404:
                    filterContext.Result = new JsonResult {
                        Data = ResultInfo.Fail("404——资源未找到"), JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                    break;

                default:
                    filterContext.Result = new ContentResult
                    {
                        Content         = "<p>" + errMsg + "</p><p>" + innerErrMsg + "</p>",
                        ContentEncoding = Encoding.UTF8,
                        ContentType     = "html/text"
                    };
                    break;
                }
            }
            else
            {
                var viewData = new ViewDataDictionary();
                viewData["Message"]      = errMsg;
                viewData["InnerMessage"] = innerErrMsg;
                filterContext.Result     = new ViewResult
                {
                    ViewName = "~/Views/Shared/Error.cshtml",
                    ViewData = viewData
                };
            }
        }
Esempio n. 12
0
 public JsonResult LinkDelete(int[] ids)
 {
     if (ids.Length == 0)
     {
         return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
     }
     db.UserProductLibraryLink.RemoveRange(db.UserProductLibraryLink.Where(where => ids.Contains(where.ID)));
     db.SaveChanges();
     return(Json(ResultInfo.Success()));
 }
Esempio n. 13
0
        public JsonResult BaseInfo(string prod_itemcode)
        {
            var model = db.ViewProjectProductPboms.SingleOrDefault(m => m.PRODUCT_ITEM_CODE == prod_itemcode.Trim());

            if (model == null)
            {
                return(Json(ResultInfo.Fail("未查询到产品信息。")));
            }
            return(Json(ResultInfo.Success(model)));
        }
Esempio n. 14
0
        public JsonResult ProductProcessList(string prod_itemcode)
        {
            if (string.IsNullOrEmpty(prod_itemcode))
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var itemlist = Proc.ProcGetProcessItemList(db, prod_itemcode);

            return(Json(ResultInfo.Success(itemlist)));
        }
Esempio n. 15
0
        public JsonResult MbomTree(string prod_itemcode, DateTime date)
        {
            if (string.IsNullOrWhiteSpace(prod_itemcode))
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var prodTree = Proc.ProcGetItemMBomTree(db, prod_itemcode, date);

            return(Json(ResultInfo.Success(prodTree)));
        }
Esempio n. 16
0
 public JsonResult Delete(int id)
 {
     if (id == 0)
     {
         return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
     }
     db.SysMenus.Remove(db.SysMenus.Find(id));
     db.SaveChanges();
     return(Json(ResultInfo.Success()));
 }
Esempio n. 17
0
 public JsonResult New(MenuView menuView)
 {
     if (string.IsNullOrWhiteSpace(menuView.name))
     {
         return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
     }
     db.SysMenus.Add(Mapper.Map <SysMenu>(menuView));
     db.SaveChanges();
     return(Json(ResultInfo.Success()));
 }
Esempio n. 18
0
        public JsonResult Users(int groupid)
        {
            if (groupid == 0)
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var list = db.AppWorkgroupUsers.Where(where => where.CN_GROUPID == groupid);

            return(Json(ResultInfo.Success(list)));
        }
Esempio n. 19
0
 public JsonResult RemoveProcess(AppProductionLineProductProcess process)
 {
     if (process.CN_ID == 0)
     {
         return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
     }
     db.AppProductionLineProductProcesses.Attach(process);
     db.AppProductionLineProductProcesses.Remove(process);
     db.SaveChanges();
     return(Json(ResultInfo.Success("删除成功!")));
 }
Esempio n. 20
0
        public JsonResult ItemProcessByVerId(int id)
        {
            if (id == 0)
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var itemlist = db.AppProcessVerHlinks.Where(process => process.CN_ID == id).ToList();
            var dtoModel = Mapper.Map <List <ProcItemProcess> >(itemlist);

            return(Json(ResultInfo.Success(dtoModel)));
        }
Esempio n. 21
0
 public ActionResult IntegrityCheckIndex(string prod_itemcode)
 {
     try
     {
         var prod = Proc.ProcMbomIntegrityCheck(db, prod_itemcode);
         return(View(ResultInfo.Success(prod)));
     }
     catch (SqlException ex)
     {
         return(View(ResultInfo.Fail(ex.Message)));
     }
 }
Esempio n. 22
0
        public JsonResult LinkList(int id, int page = 1, int rows = 10)
        {
            if (id == 0)
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var query = db.UserProductLibraryLink.Where(w => w.LibraryId == id);
            var data  = query.OrderBy(d => d.ID).Skip((page - 1) * rows).Take(rows);
            var count = query.Count();

            return(Json(ResultInfo.Success(new { rows = data, total = count })));
        }
Esempio n. 23
0
        // MBOM 标记
        public JsonResult Mark(string prod_itemcode)
        {
            var prod = db.AppProducts.Where(w => w.CN_ITEM_CODE == prod_itemcode.TrimEnd()).First();

            if (prod == null)
            {
                return(Json(ResultInfo.Fail("获取产品信息失败,标记失败")));
            }
            prod.CN_MARK         = !prod.CN_MARK;
            db.Entry(prod).State = System.Data.Entity.EntityState.Modified;
            db.SaveChanges();
            return(Json(ResultInfo.Success()));
        }
Esempio n. 24
0
        public JsonResult ItemUnlink(string prod_itemcode, string guids)
        {
            ResultInfo rt = null;

            try
            {
                rt = ResultInfo.Parse(Proc.ProcItemUnLink(db, prod_itemcode, guids, LoginUserInfo.GetUserInfo()));
            }
            catch (SqlException ex)
            {
                rt = ResultInfo.Fail(ex.Message);
            }
            return(Json(rt));
        }
Esempio n. 25
0
        public JsonResult ProductCateList(string prod_itemcode, string catename)
        {
            if (string.IsNullOrEmpty(prod_itemcode))
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            else if (string.IsNullOrEmpty(catename))
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var itemlist = Proc.ProcGetItemCateList(db, prod_itemcode, catename);

            return(Json(ResultInfo.Success(itemlist)));
        }
Esempio n. 26
0
        public JsonResult Publish(string prod_itemcode)
        {
            var        userinfo = LoginUserInfo.GetUserInfo();
            ResultInfo resultInfo;

            try
            {
                resultInfo = ResultInfo.Parse(Proc.ProcProductTransferPublish(db, prod_itemcode, userinfo));
            }
            catch (Exception ex)
            {
                resultInfo = ResultInfo.Fail(ex.Message);
            }
            return(Json(resultInfo));
        }
Esempio n. 27
0
        public JsonResult ItemList(string itemcode)
        {
            ResultInfo rt = null;

            try
            {
                var list = Proc.ProcGetItemList(db, itemcode);
                rt = ResultInfo.Success(list);
            }
            catch (SqlException ex)
            {
                rt = ResultInfo.Fail(ex.Message);
            }
            return(Json(rt));
        }
Esempio n. 28
0
        public JsonResult ItemPublish(string itemcode)
        {
            ResultInfo rt = null;

            try
            {
                var list = Proc.ProcItemPublish(db, itemcode, LoginUserInfo.GetUserInfo());
                rt = ResultInfo.Success(list);
            }
            catch (SqlException ex)
            {
                rt = ResultInfo.Fail(ex.Message);
            }
            return(Json(rt));
        }
Esempio n. 29
0
        public JsonResult ProcessVerList(string prod_itemcode)
        {
            if (string.IsNullOrWhiteSpace(prod_itemcode))
            {
                return(Json(ResultInfo.Fail(Lang.ParamIsEmpty)));
            }
            var date = DateTime.Now;
            var list = db.AppProductionLineProcessVers
                       .Where(w =>
                              w.CN_PRODUCT_ITEMCODE == prod_itemcode &&
                              w.CN_DT_EFFECTIVE <date &&
                                                 w.CN_DT_EXPIRY> date).ToList();

            return(Json(ResultInfo.Success(list)));
        }
Esempio n. 30
0
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            var errorCode = filterContext.HttpContext.Response.StatusCode;

            if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                switch (errorCode)
                {
                case 403:
                    filterContext.Result = new JsonResult {
                        Data = ResultInfo.Fail("没有操作权限,请联系管理员!"), JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                    break;

                case 412:
                    filterContext.Result = new JsonResult {
                        Data = ResultInfo.Fail("您的账号已在其他地方登录,请重新登录!"), JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                    break;

                default:
                    filterContext.Result = new JsonResult {
                        Data = ResultInfo.Fail("登录已失效,请重新登录。"), JsonRequestBehavior = JsonRequestBehavior.AllowGet
                    };
                    break;
                }
            }
            else
            {
                var viewData = new ViewDataDictionary();
                switch (errorCode)
                {
                case 403:
                    viewData["Message"]  = "没有操作权限,请联系管理员!";
                    filterContext.Result = new ViewResult
                    {
                        ViewName = "~/Views/Shared/Error.cshtml",
                        ViewData = viewData
                    };
                    break;

                case 412:
                default:
                    base.HandleUnauthorizedRequest(filterContext);
                    break;
                }
            }
        }