public void EditInventoryPlan(HttpContext context)
        {
            string callback = context.Request["jsoncallback"];
            int    planid   = Convert.ToInt32(context.Request["itemid"]);
            string name     = context.Request["name"];
            int    result;

            if (new EmsBLL.InventoryPlan().IsNameExists(name, planid))
            {
                result = -1;
            }
            else
            {
                EmsModel.InventoryPlan plan = new EmsBLL.InventoryPlan().GetEmsModel(planid);
                string useridcard           = context.Request["useridcard"];
                plan.Id            = planid;
                plan.Name          = name;
                plan.InventoryTime = Convert.ToDateTime(context.Request["invtime"]);
                plan.Type          = Convert.ToByte(context.Request["type"]);
                plan.Editor        = useridcard;
                plan.UpdateTime    = DateTime.Now;
                result             = new EmsBLL.InventoryPlan().Update(plan);
            }
            //输出Json
            HttpContext.Current.Response.Write(callback + "({\"result\":" + result + "})");
            HttpContext.Current.Response.End();
        }
        public void AddInventoryPlan(HttpContext context)
        {
            string callback = context.Request["jsoncallback"];
            string name     = context.Request["name"];
            int    result;

            if (new EmsBLL.InventoryPlan().IsNameExists(name))
            {
                result = -1;
            }
            else
            {
                string useridcard           = context.Request["useridcard"];
                EmsModel.InventoryPlan plan = new EmsModel.InventoryPlan();
                plan.Name          = name;
                plan.InventoryNo   = context.Request["invno"];
                plan.InventoryTime = Convert.ToDateTime(context.Request["invtime"]);
                plan.Type          = Convert.ToByte(context.Request["type"]);
                plan.Creator       = useridcard;
                plan.CreateTime    = DateTime.Now;
                plan.Status        = 0;
                plan.IsGenerate    = 0;
                plan.IsDelete      = 0;
                result             = new EmsBLL.InventoryPlan().Add(plan);
            }
            //输出Json
            HttpContext.Current.Response.Write(callback + "({\"result\":" + result + "})");
            HttpContext.Current.Response.End();
        }
Beispiel #3
0
        public JsonModel CreateInventoryList(int planid, string type, string useridcard)
        {
            //定义JSON标准格式实体中
            JsonModel jsonModel = new JsonModel();

            try
            {
                //事务
                using (SqlTransaction trans = dal.GetTran())
                {
                    try
                    {
                        int listCount = new EmsDAL.InventoryList().AddInventoryList(trans, planid, type, useridcard);
                        if (listCount <= 0)
                        {
                            trans.Rollback();//回滚
                            jsonModel.Status = "no";
                            jsonModel.Msg    = "生成盘点单失败";
                            return(jsonModel);
                        }
                        int addCount = dal.AddInventoryListDetail(trans, planid, type);
                        if (addCount <= 0)
                        {
                            trans.Rollback();//回滚
                            jsonModel.Status = "no";
                            jsonModel.Msg    = "生成盘点单失败";
                            return(jsonModel);
                        }
                        EmsModel.InventoryPlan plan = new EmsBLL.InventoryPlan().GetEmsModel(planid);
                        plan.IsGenerate = 1;
                        int upcount = new EmsDAL.InventoryPlan().Update(plan);
                        if (upcount <= 0)
                        {
                            trans.Rollback();//回滚
                            jsonModel.Status = "no";
                            jsonModel.Msg    = "生成盘点单失败";
                            return(jsonModel);
                        }
                        trans.Commit();//提交
                    }
                    catch (Exception)
                    {
                        trans.Rollback();//回滚
                        throw;
                    }
                }
                jsonModel.Status = "ok";
                jsonModel.Msg    = "操作成功";
                return(jsonModel);
            }
            catch (Exception ex)
            {
                jsonModel.Status = "error";
                jsonModel.Msg    = ex.ToString();
                return(jsonModel);
            }
        }
        public void GetModelById(HttpContext context)
        {
            string callback = context.Request["jsoncallback"];
            int    planid   = Convert.ToInt32(context.Request["itemid"]);

            //序列化
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            EmsModel.InventoryPlan plan = new EmsBLL.InventoryPlan().GetEmsModel(planid);
            //输出Json
            HttpContext.Current.Response.Write(callback + "({\"result\":" + jss.Serialize(plan) + "})");
            HttpContext.Current.Response.End();
        }
        public void DeleteInventoryPlan(HttpContext context)
        {
            string callback = context.Request["jsoncallback"];
            int    planid   = Convert.ToInt32(context.Request["intID"]);

            EmsModel.InventoryPlan plan = new EmsBLL.InventoryPlan().GetEmsModel(planid);
            plan.Id       = planid;
            plan.IsDelete = 1;
            int result = new EmsBLL.InventoryPlan().Update(plan);

            //输出Json
            HttpContext.Current.Response.Write(callback + "({\"result\":" + result + "})");
            HttpContext.Current.Response.End();
        }
        public void GetDataPage(HttpContext context)
        {
            string callback = context.Request["jsoncallback"];
            //当前页
            int startIndex = Convert.ToInt32(context.Request["startIndex"]);
            //页容量
            int    pageSize = Convert.ToInt32(context.Request["pageSize"]);
            string name     = context.Request["name"];

            EmsModel.InventoryPlan plan = new EmsModel.InventoryPlan();
            if (!string.IsNullOrEmpty(name))
            {
                plan.Name = name;
            }
            plan.IsDelete = 0;
            //序列化
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            EmsModel.JsonModel mod = new EmsBLL.InventoryPlan().GetJsonModel(plan, startIndex, pageSize);
            //输出Json
            HttpContext.Current.Response.Write(callback + "({\"result\":" + jss.Serialize(mod) + "})");
            HttpContext.Current.Response.End();
        }