예제 #1
0
 public int InserProject(string Pname, string PjCity, string MachineNum, string IsNow, string PjXSName, string IsDealer, string Phone, string Other)
 {
     using (var db = new TestTryEntities1())
     {
         //数据操作
         //var getGser = db.User.Where(x => x.Name == name || x.Email == email).Take(1).ToList();
         //if (getGser.Count > 0)
         //{
         //}
         ProjectInfo pro = new ProjectInfo()
         {
             PName      = Pname,
             PCity      = PjCity,
             MchineNum  = MachineNum,
             IsNow      = Convert.ToInt32(IsNow),
             Salesman   = PjXSName,
             StartTime  = IsDealer,
             SalesPhone = Phone,
             SubmitTime = Other,
             CreateTime = DateTime.UtcNow,
             UpdateTime = DateTime.UtcNow
         };
         db.ProjectInfo.Add(pro);
         db.SaveChanges();
         return(pro.id);
     }
 }
예제 #2
0
        //public void GetProjectInfoList(int page, int id = 0)
        //{
        //     DBHelper<ProjectInfo> dbhelper = new DBHelper<ProjectInfo>();
        //     var count = dbhelper.FindList(x => x.id > 0).ToList().Count(); ;
        //     int i = 0;
        //     List<ProjectInfo> entityes = dbhelper.FindPagedList(1, 1, out i, x => x.id > 0, s => s.createtime, true).ToList<ProjectInfo>();

        //     //List<UserInfo> list = entityes.ToList<UserInfo>();
        //}
        public List <PreAdminIndex> GetProjectInfoList(int page, int id = 0)
        {
            using (var db = new TestTryEntities1())
            {
                List <PreAdminIndex> modelList = new List <PreAdminIndex>();
                List <ProjectInfo>   proList   = new List <ProjectInfo>();
                if (id == 0)
                {
                    proList = db.ProjectInfo.OrderBy(x => x.CreateTime).Skip(page - 1 * 1).Take(1).ToList();;
                }
                else
                {
                    proList = db.ProjectInfo.Where(x => x.id == id).Take(1).ToList();;
                }

                ViewData["ProCount"] = db.ProjectInfo.Count();

                foreach (var item in proList)
                {
                    PreAdminIndex model = new PreAdminIndex();
                    model.id         = item.id;
                    model.PName      = item.PName;
                    model.PCity      = item.PCity;
                    model.Salesman   = item.Salesman;
                    model.SalesPhone = item.SalesPhone;
                    model.MchineNum  = item.MchineNum;
                    model.StartTime  = item.StartTime;;
                    model.IsNow      = item.IsNow;
                    model.SubmitTime = item.SubmitTime;
                    modelList.Add(model);
                }
                return(modelList);
            }
        }
예제 #3
0
        public ProAdminEdit GetMachine(int proId)
        {
            using (var db = new TestTryEntities1())
            {
                List <machineinfo> malist = db.machineinfo.Where(x => x.ProId == proId).ToList();
                //TestTryEntities1<machineinfo> entry = db.machineinfo<machineinfo>.Where(x => x.proID == proId).ToList();
                ProAdminEdit model = new ProAdminEdit();
                foreach (var ma in malist)
                {
                    // model.Machine. = ma.id;
                    // model.Machine.machineName = ma.machineName;
                    // model.Machine.test = ma.test;
                    // model.Machine.other = ma.other;
                    //model.List.Add(model.Machine)
                    model.Machine.id           = ma.id;
                    model.Machine.MachineName  = ma.MachineName;
                    model.Machine.MachineNum   = ma.MachineNum;
                    model.Machine.MachineModel = ma.MachineModel;
                    model.Machine.Remark       = ma.Remark;

                    model.List.Add(model.Machine);
                }
                return(model);
            }
        }
예제 #4
0
        public void ProcessRequest(HttpContext context)
        {
            //string action = context.Request.Params["key"];
            string email = context.Request.Form["emal"];
            string name  = context.Request.Form["name"];
            string pass  = context.Request.Form["pass"];

            string status = "1";
            string error  = "null";

            try
            {
                using (var db = new TestTryEntities1())
                {
                    //数据操作
                    var getGser = db.User.Where(x => x.Name == name || x.Email == email).Take(1).ToList();
                    if (getGser.Count > 0)
                    {
                        status = "0";
                        error  = "该用户名或邮箱已存在,请重试";
                    }
                    User user = new User()
                    {
                        Name     = pass,
                        Email    = email,
                        Password = pass
                    };
                    db.User.Add(user);
                    db.SaveChanges();
                    //var user = (from v in db.Student
                    //            where v.Name == "51aspx"
                    //            select v).Single();
                    //user.Password = "******";
                    //db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                status = "0";
                error  = e.ToString();
            }

            StringBuilder json = new StringBuilder();

            json.Append("[");
            json.Append("{");
            json.Append("\"status\":" + "\"" + status + "\",");
            json.Append("\"error\":" + "\"" + error + "\"");
            json.Append("}");
            json.Append("]");
            //CreateXmlFile createXml = new CreateXmlFile();
            //TestTryEntities Db = new TestTryEntities();
            // int total = Db.Student.Count();
            string returnStr = json.ToString();

            context.Response.Write(returnStr);
        }
예제 #5
0
 public bool InserMachineInfo(string jsonstr, int id)
 {
     try
     {
         //use json.net
         JArray         o     = (JArray)JsonConvert.DeserializeObject(jsonstr);
         IList <JToken> oList = (IList <JToken>)o;
         int            proId = 0;
         foreach (JToken jt in oList)
         {
             JObject jo = jt as JObject;
             using (var db = new TestTryEntities1())
             {
                 if (jt == o[0])
                 {
                     ProjectInfo pro = new ProjectInfo()
                     {
                         PName      = jo["Pname"].ToString(),
                         PCity      = jo["PjCity"].ToString(),
                         MchineNum  = jo["MachineNum"].ToString(),
                         StartTime  = jo["IsNow"].ToString(),
                         Salesman   = jo["PjXSName"].ToString(),
                         IsNow      = Convert.ToInt32(jo["IsDealer"].ToString()),
                         SalesPhone = jo["Phone"].ToString(),
                         SubmitTime = jo["Other"].ToString(),
                         CreateTime = DateTime.Now,
                         UpdateTime = DateTime.Now
                     };
                     db.ProjectInfo.Add(pro);
                     db.SaveChanges();
                     proId = pro.id;
                 }
                 if (oList.Count >= 1 & jt != o[0])
                 {
                     machineinfo model = new machineinfo()
                     {
                         MachineName  = jo["PjName"].ToString(),
                         MachineNum   = Convert.ToInt32(jo["PjNum"].ToString()),
                         MachineModel = jo["Xdd"].ToString(),
                         Remark       = jo["Xddw"].ToString(),
                         CreateTime   = DateTime.Now,
                         UpdateTime   = DateTime.Now,
                         ProId        = proId
                     };
                     db.machineinfo.Add(model);
                     db.SaveChanges();
                 }
             }
         }
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
예제 #6
0
        public void ProcessRequest(HttpContext context)
        {
            //string email = context.Request.Form["emal"];
            string name   = context.Request.Form["name"];
            string pass   = context.Request.Form["pass"];
            string status = "1";
            string error  = "null";

            //var students = null;
            try
            {
                using (var db = new TestTryEntities1())
                {
                    var user = db.User.Where(x => x.Name == name && x.Password == pass).Take(1).ToList();
                    if (user.Count == 0)
                    {
                        status = "0";
                        error  = " 未找到给用户!";
                    }
                };
            }
            catch (Exception e)
            {
                status = "0";
                error  = e.ToString();
            }

            StringBuilder json = new StringBuilder();

            json.Append("[");
            json.Append("{");
            json.Append("\"status\":" + "\"" + status + "\",");
            json.Append("\"error\":" + "\"" + error + "\"");
            json.Append("}");
            json.Append("]");
            //CreateXmlFile createXml = new CreateXmlFile();
            //createXml.CreateXml();
            string returnStr = json.ToString();

            context.Response.Write(returnStr);
        }
예제 #7
0
 public BaseCommon(TestTryEntities1 context)
 {
     this.db = context;
 }