//获取产品材质信息 ChanPinCZ

        public ActionResult ChanPinCZ()
        {
            var temp = T_SczzItemService.LoadEntities(x => x.Del == 0);
            var tem  = from a in temp
                       select new
            {
                ID      = a.ID,
                MyTexts = a.Text
            };

            return(Json(tem, JsonRequestBehavior.AllowGet));
        }
        //获取信息列表
        public ActionResult GetHref()
        {
            int pageIndex = Request["page"] != null ? Request["page"].ToString().Trim().Length <= 0?1: int.Parse(Request["page"]) : 1;
            int pageSize  = Request["rows"] != null?int.Parse(Request["rows"]) : 10;

            string MyColums = Request["MyColums"];
            int    totalCount;

            if (MyColums == "CPlist")
            {
                var actioninfolist = T_SczzDanjuService.LoadPageEntities <DateTime?>(pageIndex, pageSize, out totalCount, a => a.AddUser == LoginUser.ID && a.del != 1, a => a.AddTime, false);
                var temp           = from a in actioninfolist
                                     select new
                {
                };
                return(Json(new { rows = temp, total = totalCount }, JsonRequestBehavior.AllowGet));
            }
            else
            if (MyColums == "CPxinghao")//规格型号
            {
                var actioninfolist = T_SczzItemService.LoadPageEntities <DateTime?>(pageIndex, pageSize, out totalCount, a => a.Del != 1, a => a.AddTime, false);
                var temp           = from a in actioninfolist
                                     select new
                {
                    a.ID,
                    a.AddTime,
                    a.Text
                };
                return(Json(new { rows = temp, total = totalCount }, JsonRequestBehavior.AllowGet));
            }
            if (MyColums == "JiHuaName")//单据
            {
                var actioninfolist = T_ShengChanZhiZhaoTopNameService.LoadPageEntities <DateTime?>(pageIndex, pageSize, out totalCount, a => a.Del != 1, a => a.addtime, false);
                var temp           = from a in actioninfolist
                                     select new
                {
                    a.ID,
                    a.TopText,
                    a.addtime
                };
                return(Json(new { rows = temp, total = totalCount }, JsonRequestBehavior.AllowGet));
            }
            return(Json(null, JsonRequestBehavior.AllowGet));
        }
        //添加型号 与产品头部信息
        public ActionResult ADDitems()
        {
            var obj = Request["obj"].ToString().Trim();
            var VL  = int.Parse(Request["VL"]);

            if (VL == 1)
            {
                var tmp = T_SczzItemService.LoadEntities(x => x.Text == obj).FirstOrDefault();
                if (tmp != null)
                {
                    return(Json("Isdistict", JsonRequestBehavior.AllowGet));
                }
                T_SczzItem TS = new T_SczzItem();
                TS.AddTime = MvcApplication.GetT_time();
                TS.AddUser = LoginUser.ID;
                TS.Text    = obj;
                TS.Del     = 0;
                T_SczzItemService.AddEntity(TS);
                return(Json("ok", JsonRequestBehavior.AllowGet));
            }
            else if (VL == 0)
            {
                var tmp = T_ShengChanZhiZhaoTopNameService.LoadEntities(x => x.TopText == obj).FirstOrDefault();
                if (tmp != null)
                {
                    return(Json("Isdistict", JsonRequestBehavior.AllowGet));
                }
                T_ShengChanZhiZhaoTopName tt = new T_ShengChanZhiZhaoTopName();
                tt.addtime = MvcApplication.GetT_time();
                tt.adduser = LoginUser.ID;
                tt.Del     = 0;
                tt.TopText = obj;
                T_ShengChanZhiZhaoTopNameService.AddEntity(tt);
                return(Json("ok", JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json("errer", JsonRequestBehavior.AllowGet));
            }
        }
        //删除 表头和规格型号
        public ActionResult Delitems()
        {
            var id       = Convert.ToInt64(Request["delID"]);
            var MyColums = Request["MyColums"].ToString();

            if (MyColums == "CPxinghao")//规格型号
            {
                T_SczzItem ts = T_SczzItemService.LoadEntities(x => x.ID == id && x.AddUser == LoginUser.ID).FirstOrDefault();
                if (ts == null)
                {
                    return(Json("noperson", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    ts.Del = 1;
                    if (T_SczzItemService.EditEntity(ts))
                    {
                        return(Json("ok", JsonRequestBehavior.AllowGet));
                    }
                }
            }
            else if (MyColums == "JiHuaName")
            {
                var top = T_ShengChanZhiZhaoTopNameService.LoadEntities(x => x.ID == id && x.adduser == LoginUser.ID).FirstOrDefault();
                if (top == null)
                {
                    return(Json("noperson", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    top.Del = 1;
                    if (T_ShengChanZhiZhaoTopNameService.EditEntity(top))
                    {
                        return(Json("ok", JsonRequestBehavior.AllowGet));
                    }
                }
            }

            return(Json("no", JsonRequestBehavior.AllowGet));
        }
        //获取选项列表
        public ActionResult GetSelect()
        {
            var actioninfolist = T_SczzItemService.LoadEntities(x => x.Del == 0).DefaultIfEmpty();
            var Caiz           = from a in actioninfolist
                                 select new
            {
                a.ID,
                a.AddTime,
                a.Text
            };

            var topss = T_ShengChanZhiZhaoTopNameService.LoadEntities(x => x.Del == 0).DefaultIfEmpty();
            var Top   = from a in topss
                        select new
            {
                a.ID,
                a.addtime,
                a.TopText
            };

            return(Json(new { Top = Top, Caiz = Caiz, ret = "ok" }, JsonRequestBehavior.AllowGet));
        }