/// <summary>
        /// 组合产品的基础信息添加,用于Create New Product Group 页面的第一阶段
        /// </summary>
        /// <param name="gpModel"></param>
        /// <returns>如果成功,返回新增成功的数据库ID</returns>
        public ActionResult HMGroupBaseInfoAdd(CMS_HMNUM_Model gpModel)
        {
            try
            {
                User_Profile_Model curUserInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);

                HMGroupCreateServices gSvr = new HMGroupCreateServices();
                string errMsg = string.Empty;
                long   newID  = gSvr.HMGroupBaseInfoAdd(gpModel, curUserInfo.User_Account, ref errMsg);
                if (newID > 0)
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.OK,
                        Data = newID
                    }));
                }
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Error,
                    Data = errMsg == string.Empty ? "Faile to add HM# Group" : errMsg
                }));
            }
            catch (DbEntityValidationException e)
            {
                NBCMSLoggerManager.Error("");
                NBCMSLoggerManager.Error("");
                foreach (var eve in e.EntityValidationErrors)
                {
                    foreach (var ve in eve.ValidationErrors)
                    {
                        NBCMSLoggerManager.Error(String.Format(" Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage));
                    }
                }
                NBCMSLoggerManager.Error("");
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = e.Message
                }));
            }
            catch (Exception ex)
            {
                NBCMSLoggerManager.Error("");
                NBCMSLoggerManager.Error(ex.Message);
                NBCMSLoggerManager.Error(ex.Source);
                NBCMSLoggerManager.Error(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
        /// <summary>
        /// 为组合产品新增基础产品,用于Create HM Group 页面的使用
        /// CraeteTime:2013年11月19日11:37:55
        /// </summary>
        /// <param name="rModel"></param>
        /// <returns>如果新增成功,返回新的ID,和价格信息,价格信息用于第三阶段Costing的展示...</returns>
        public ActionResult AddNewHM4Group(CMS_HMGroup_Relation_Model rModel)
        {
            try
            {
                if (rModel.ProductID < 1 || rModel.ChildrenProductID < 1)
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Error,
                        Data = "Request is illegal!"
                    }));
                }

                User_Profile_Model curUserInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);

                HMGroupCreateServices gpSvr = new HMGroupCreateServices();
                string errMsg = string.Empty;
                long   newID  = gpSvr.AddNewHM4Group(rModel, curUserInfo.User_Account);
                if (newID > 0)
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.OK,
                        Data = new
                        {
                            newID = newID,
                            //根据当前主产品的信息获取其子产品的价格,一个一个返回,客户端要判断到傻眼,删除新增编辑都要用JS判断...
                            //2013年11月19日17:41:54
                            ChildrenCostList = gpSvr.GetChildrenCost(rModel)
                        }
                    }));
                }
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Error,
                    Data = errMsg == string.Empty ? "Faile to add HM# Group" : errMsg
                }));
            }
            catch (Exception ex)
            {
                NBCMSLoggerManager.Error("");
                NBCMSLoggerManager.Error(ex.Message);
                NBCMSLoggerManager.Error(ex.Source);
                NBCMSLoggerManager.Error(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
Ejemplo n.º 3
0
        //
        // GET: /Main/

        public ActionResult Index()
        {
            string cookis = Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]];

            //用来阻止第一次登陆的时候没有Cookies触发的解密异常报错 2014年2月22日
            if (string.IsNullOrEmpty(cookis))
            {
                return(null);
            }

            User_Profile_Model userInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);

            return(View(userInfo));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 由于获取Channel这个方法十分常用但是又和当前用户IsChannelControl关联,无法缓存,故而让着方法和Brand方法分散在不同的Controller维护,需要注意
        /// 2014年3月24日
        /// </summary>
        /// <param name="isNeedAll"></param>
        /// <returns></returns>
        public ActionResult GetChannelList(bool isNeedAll)
        {
            var useInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);
            //ChannelID ChannelName
            var list = new ProductCommonServices().GetAllChannels(useInfo.IsChannelControl, useInfo.User_Guid);

            if (isNeedAll)
            {
                list.Insert(0, new Channel_Model//插入第一个位置
                {
                    ChannelID   = 0,
                    ChannelName = "All"
                });
            }
            return(Json(list));
        }
Ejemplo n.º 5
0
        public ActionResult EditChannel(Channel_Model model)
        {
            try
            {
                if (model == null)
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Error,
                        Data = "Request is illegal!"
                    }));
                }

                User_Profile_Model  curUserInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);
                ChannelInfoServices cis         = new ChannelInfoServices();

                string msg = string.Empty;
                if (cis.EditChannel(model, curUserInfo.User_Account, ref msg))
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.OK,
                        Data = "Successfully edit channel"
                    }));
                }
                else
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Error,
                        Data = msg == string.Empty ? "faile to add new Channel" : msg
                    }));
                }
            }
            catch (Exception ex)
            {
                NBCMSLoggerManager.Fatal(ex.Message);
                NBCMSLoggerManager.Fatal(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
Ejemplo n.º 6
0
        public ActionResult AddBrand(Brands_Info_Model model)
        {
            try
            {
                if (model == null)
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Error,
                        Data = "Request is illegal!"
                    }));
                }

                var    curUserInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);
                var    bis         = new BrandInfoServices();
                string msg         = string.Empty;
                if (bis.AddBrand(model, curUserInfo.User_Account, ref msg))
                {
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.OK,
                        Data = "Successfully add brand"
                    }));
                }
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Error,
                    Data = msg == string.Empty ? "faile to add new brand" : msg
                }));
            }
            catch (Exception ex)
            {
                NBCMSLoggerManager.Fatal(ex.Message);
                NBCMSLoggerManager.Fatal(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }
        /// <summary>
        /// Get PO Orders for Dashboard displaying (HightCharts)
        /// </summary>
        /// <returns></returns>
        public ActionResult GetPoOrders(List <Int32> channelList, String sTime, String eTime)
        {
            try
            {
                var sPage = Request["page"];
                var sRows = Request["rows"];
                var page  = 1;
                var rows  = 10;
                if (!string.IsNullOrEmpty(sPage))
                {
                    page = Convert.ToInt32(sPage);
                }
                if (!string.IsNullOrEmpty(sRows))
                {
                    rows = Convert.ToInt32(sRows);
                }

                var useInfo = new CommonController().GetCurrentUserbyCookie(Request[ConfigurationManager.AppSettings["userInfoCookiesKey"]]);
                var dSvs    = new DashboardServices();
                int totalRecord;
                var lowInventoryList = dSvs.GetLowInventory(page, rows, out totalRecord, useInfo);
                var serializer       = new JavaScriptSerializer {
                    MaxJsonLength = Int32.MaxValue
                };
                /*当订单数据量超过13000行记录的时候会报错,需要特殊配置*/
                //var serializer = new JavaScriptSerializer();
                // For simplicity just use Int32's max value.
                // You could always read the value from the config section mentioned above.
                var resultData = new
                {
                    Status  = StatusType.OK,
                    Data    = dSvs.GetEcomOrder(channelList.ToArray(), sTime, eTime).ToArray(),
                    Metrics = new
                    {
                        AvgOrders  = dSvs.GetAvgDailyOrders(sTime, eTime),
                        AvgAmt     = dSvs.GetAvgOrderAmount(sTime, eTime).ToString("C", new CultureInfo("en-US")),
                        ProductDev = dSvs.GetProductsDevCount(),
                        ItemAtt    = dSvs.GetAttentionItemsCount()
                    },
                    LowInventory   = lowInventoryList,
                    ProductDevList = dSvs.GetProductsDevList(),
                    TotalRecord    = totalRecord
                };
                var result = new ContentResult
                {
                    Content     = serializer.Serialize(resultData),
                    ContentType = "application/json"
                };
                return(result);
            }
            catch (EntityCommandExecutionException ex)
            {
                if (ex.InnerException != null)
                {
                    NBCMSLoggerManager.Error(ex.InnerException.Message);
                    NBCMSLoggerManager.Error(ex.InnerException.Source);
                    NBCMSLoggerManager.Error(ex.InnerException.StackTrace);
                    NBCMSLoggerManager.Error("");
                    return(Json(new NBCMSResultJson
                    {
                        Status = StatusType.Exception,
                        Data = ex.InnerException.Message
                    }));
                }
                NBCMSLoggerManager.Error(ex.Message);
                NBCMSLoggerManager.Error(ex.Source);
                NBCMSLoggerManager.Error(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
            catch (Exception ex)
            {
                NBCMSLoggerManager.Error(ex.Message);
                NBCMSLoggerManager.Error(ex.Source);
                NBCMSLoggerManager.Error(ex.StackTrace);
                NBCMSLoggerManager.Error("");
                return(Json(new NBCMSResultJson
                {
                    Status = StatusType.Exception,
                    Data = ex.Message
                }));
            }
        }