Example #1
0
        public JsonResult InitLine(string lcode)
        {
            JsonData            d  = new JsonData();
            SessionUserValidate iv = SysValidateBll.ValidateSession();

            if (iv.f)
            {
                Sys_ProductionProcessLine sal = new Sys_ProductionProcessLine();
                if (lcode != "")
                {
                    sal = sppb.Query(" and  lcode='" + lcode + "'");
                }
                else
                {
                    sal.lcode = sppb.CreateCode().ToString().PadLeft(4, '0');
                    sal.id    = 0;
                }
                d.d = js.Serialize(sal);
            }
            else
            {
                d.d = iv.badstr;
            }
            return(Json(d));
        }
Example #2
0
        public JsonResult SaveLine(string lcode, string lname, string lid, List <object[]> prow)
        {
            JsonData d = new JsonData();
            Sys_ProductionProcessLine spp = new Sys_ProductionProcessLine();
            SessionUserValidate       iv  = SysValidateBll.ValidateSession();

            if (iv.f)
            {
                int utime = 0;
                int cnum  = 1;
                spp.lname = lname;
                spp.lcode = lcode;
                spp.maker = iv.u.ename;
                spp.cdate = DateTime.Now.ToString();
                if (iv.u.rcode != "xtgl")
                {
                    spp.dcode = iv.u.dcode.Substring(0, 8);
                }
                else
                {
                    spp.dcode = "";
                }
                if (lid == "0")
                {
                    if (sppb.Add(spp) > 0)
                    {
                        d.d = "S";
                    }
                    else
                    {
                        d.d = "F";
                    }
                }
                else
                {
                    if (sppb.Update(spp))
                    {
                        d.d = "S";
                    }
                    else
                    {
                        d.d = "F";
                    }
                }
                if (d.d == "S")
                {
                    List <Sys_ProductionProcessLinePoint> pl = new List <Sys_ProductionProcessLinePoint>();
                    if (prow != null)
                    {
                        foreach (object[] o in prow)
                        {
                            if (o[2].ToString() != "0")
                            {
                                if (cnum < Convert.ToInt32(o[2]))
                                {
                                    cnum = Convert.ToInt32(o[2]);
                                }
                                Sys_ProductionProcessLinePoint p = new Sys_ProductionProcessLinePoint();
                                p.lcode    = lcode;
                                p.lname    = lname;
                                p.cdate    = DateTime.Now.ToString();
                                p.gcode    = o[1].ToString();
                                p.gname    = o[0].ToString();
                                p.maker    = iv.u.ename;
                                p.nsort    = Convert.ToInt32(o[2]);
                                p.pregcode = "";
                                p.ptype    = "";
                                p.usetime  = Convert.ToInt32(o[3]);
                                pl.Add(p);
                                utime = utime + p.usetime;
                            }
                        }
                        if (cnum == pl.Count)
                        {
                            List <Sys_ProductionProcessLinePoint> spl = new List <Sys_ProductionProcessLinePoint>();
                            for (int sn = 1; sn <= cnum; sn++)
                            {
                                foreach (Sys_ProductionProcessLinePoint p in pl)
                                {
                                    if (p.nsort == sn)
                                    {
                                        spl.Add(p);
                                        break;
                                    }
                                }
                            }
                            if (cnum == spl.Count)
                            {
                                sppcb.AddList(lcode, spl);
                                sppb.UpUtime(lcode, utime);
                            }
                            else
                            {
                                sppb.Delete(lcode);
                                d.d = "F";
                            }
                        }
                        else
                        {
                            sppb.Delete(lcode);
                            d.d = "F";
                        }
                    }
                }
            }
            else
            {
                d.d = iv.badstr;
            }
            return(Json(d));
        }