예제 #1
0
        public ActionResult upd1()
        {
            int  lineid  = int.Parse(Request.Params["lineid"]);
            int  isStart = int.Parse(Request.Params["isStart"]);
            int  uid     = int.Parse(Session["userid"].ToString());
            bool b       = true;
            MyElectrCheck_DBDataContext mdc = new MyElectrCheck_DBDataContext();
            ps_line_info result             = (from l in mdc.ps_line_info
                                               where l.id == lineid
                                               select l).FirstOrDefault();
            var user = (from u in mdc.ps_user
                        where u.id == uid
                        select u).FirstOrDefault();

            //修改数据
            result.isStart        = isStart;
            result.lastUpdateTime = DateTime.Now;
            result.createdBy      = user.userCode;
            try
            {
                //保存修改
                mdc.SubmitChanges();
            }
            catch (Exception)
            {
                b = false;
            }

            return(Json(b));
        }
예제 #2
0
        public ActionResult UpdCheck()
        {
            string roleid   = Request.Params["roleid"];
            string rolename = Request.Params["rolename"];


            MyElectrCheck_DBDataContext medc = new MyElectrCheck_DBDataContext();

            bool b = false;

            var role = (from r in medc.ps_role
                        where r.id == roleid
                        select r).FirstOrDefault();

            if (role.roleName == rolename)
            {
                b = true;
            }
            else
            {
                var roleinfo = (from r in medc.ps_role
                                where r.roleName == rolename
                                select r).FirstOrDefault();
                if (roleinfo == null)
                {
                    b = true;
                }
            }
            return(Json(b));
        }
예제 #3
0
        public ActionResult ChangeStatus()
        {
            string id     = Request.Params["roleid"];
            int    status = int.Parse(Request.Params["status"]);

            MyElectrCheck_DBDataContext medc = new MyElectrCheck_DBDataContext();

            var role = (from r in medc.ps_role
                        where r.id == id
                        select r).FirstOrDefault();

            bool b = true;

            //修改数据
            role.isStart = status;

            try
            {
                //保存数据
                medc.SubmitChanges();
            }
            catch (Exception)
            {
                b = false;
            }
            return(Json(b));
        }
예제 #4
0
        //验证登录
        public ActionResult CheckLogin()
        {
            //获得用户名和密码
            string userid  = Request.Params["userid"];
            string userpwd = Request.Params["userpwd"];

            MyElectrCheck_DBDataContext medc = new MyElectrCheck_DBDataContext();
            var result = (from u in medc.ps_user
                          where u.userCode == userid && u.userPassword == userpwd
                          select u).FirstOrDefault();

            string b = "false";

            if (result != null)
            {
                if (result.userStatus == 1)
                {
                    b = "true";
                    Session["userid"]   = result.id;
                    Session["userCode"] = result.userCode;
                    Session["roleid"]   = result.roleId;

                    //修改数据
                    result.lastLoginTime  = DateTime.Now;
                    result.lastUpdateTime = DateTime.Now;

                    try
                    {
                        medc.SubmitChanges();
                    }
                    catch (Exception)
                    {
                        b = "false";
                    }

                    if (b == "true")
                    {
                        //添加logo日志
                        ps_logs logs = new ps_logs()
                        {
                            userCode        = result.userCode,
                            userName        = result.userName,
                            operateInfo     = "登录系统",
                            operateDateTime = DateTime.Now
                        };
                        medc.ps_logs.InsertOnSubmit(logs);
                        //保存数据
                        medc.SubmitChanges();
                    }
                }
                else
                {
                    b = "freeze";
                }
            }
            return(Json(b));
        }
예제 #5
0
        public FileResult Excel2()
        {
            MyElectrCheck_DBDataContext mdc = new MyElectrCheck_DBDataContext();

            List <DataEliminate> list = new List <DataEliminate>();

            if (Session["solvelist"] != null)
            {
                //将session转为集合
                list = (List <DataEliminate>)Session["solvelist"];
            }

            NPOI.HSSF.UserModel.HSSFWorkbook Book   = new NPOI.HSSF.UserModel.HSSFWorkbook();
            NPOI.SS.UserModel.ISheet         sheet1 = Book.CreateSheet("Sheet1");
            NPOI.SS.UserModel.IRow           row1   = sheet1.CreateRow(0);
            row1.CreateCell(0).SetCellValue("任务编号");
            row1.CreateCell(1).SetCellValue("任务名称");
            row1.CreateCell(2).SetCellValue("线路编号");
            row1.CreateCell(3).SetCellValue("线路编号");
            row1.CreateCell(4).SetCellValue("有无故障");
            row1.CreateCell(5).SetCellValue("缺陷级别");
            row1.CreateCell(6).SetCellValue("缺陷类型");
            row1.CreateCell(7).SetCellValue("消缺时间");
            row1.CreateCell(8).SetCellValue("发现时间");
            row1.CreateCell(9).SetCellValue("缺陷描述");
            for (int i = 0; i < list.Count; i++)
            {
                NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue(list[i].solveTaskCode);
                rowtemp.CreateCell(1).SetCellValue(list[i].solveTaskName);
                rowtemp.CreateCell(2).SetCellValue(list[i].lineCode);
                if (list[i].isBug == 1)
                {
                    rowtemp.CreateCell(3).SetCellValue("有");
                }
                else
                {
                    rowtemp.CreateCell(3).SetCellValue("无");
                }
                rowtemp.CreateCell(4).SetCellValue(list[i].bugLevelName);
                rowtemp.CreateCell(5).SetCellValue(list[i].bugLevelName);
                rowtemp.CreateCell(6).SetCellValue(list[i].bugTypeName);
                rowtemp.CreateCell(7).SetCellValue(list[i].finishTime.ToString());
                rowtemp.CreateCell(8).SetCellValue(list[i].discoverTime.ToString());
                rowtemp.CreateCell(9).SetCellValue(list[i].bugDesc);
            }
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            Book.Write(ms);
            ms.Seek(0, System.IO.SeekOrigin.Begin);
            DateTime dt       = DateTime.Now;
            string   dateTime = dt.ToString("yyMMddHHmmssff");
            string   fileName = "查询结果" + dateTime + ".xls";

            return(File(ms, "application/vnd.ms-excel", fileName));
        }
예제 #6
0
        //添加角色信息
        public ActionResult AddRole()
        {
            string roleid   = Request.Params["roleid"];
            string rolename = Request.Params["rolename"];
            int    status   = int.Parse(Request.Params["status"]);

            MyElectrCheck_DBDataContext medc = new MyElectrCheck_DBDataContext();

            //获得session中保存的值
            int id   = int.Parse(Session["userid"].ToString());
            var user = (from u in medc.ps_user
                        where u.id == id
                        select u).FirstOrDefault();

            //创建实体类对象
            ps_role role = new ps_role()
            {
                id             = roleid,
                roleName       = rolename,
                creationTime   = DateTime.Now,
                createdBy      = user.userCode,
                lastUpdateTime = DateTime.Now,
                isStart        = status
            };

            bool b = true;

            //添加到数据库
            medc.ps_role.InsertOnSubmit(role);
            try
            {
                //保存数据
                medc.SubmitChanges();

                ps_logs logs = new ps_logs()
                {
                    userCode        = user.userCode,
                    userName        = user.userName,
                    operateInfo     = "添加角色信息",
                    operateDateTime = DateTime.Now
                };
                medc.ps_logs.InsertOnSubmit(logs);
                medc.SubmitChanges();
            }
            catch (Exception)
            {
                b = false;
            }
            return(Json(b));
        }
예제 #7
0
        public ActionResult GetData()
        {
            MyElectrCheck_DBDataContext mdc = new MyElectrCheck_DBDataContext();
            var result = from l in mdc.ps_line_info
                         select l;
            int pageindex = int.Parse(Request.Params["pageindex"]);

            int        skip = (pageindex - 1) * 5;
            DataSource ds   = new DataSource();

            ds.datalist  = result.Skip(skip).Take(5).ToList();
            ds.linecount = result.Count();
            string str = JsonConvert.SerializeObject(ds);

            return(Content(str));;
        }
예제 #8
0
        public ActionResult SelectHaveUser()
        {
            string rid = Request.Params["roleid"];

            MyElectrCheck_DBDataContext medc = new MyElectrCheck_DBDataContext();

            var user = (from u in medc.ps_user
                        where u.roleId == rid
                        select u).ToList();

            bool b = false;

            if (user.Count() > 0)
            {
                b = true;
            }
            return(Json(b));
        }
예제 #9
0
        public ActionResult MyLogin()
        {
            bool   b        = false;
            string u2_input = Request.Params["u2_input"];
            string u3_input = Request.Params["u3_input"];
            MyElectrCheck_DBDataContext mdc = new MyElectrCheck_DBDataContext();
            var result = (from u in mdc.ps_user
                          where u.userName == u2_input && u.userPassword == u3_input
                          select u).FirstOrDefault();

            if (result != null)
            {
                Session["userid"] = result.id;
                b = true;
            }

            return(Json(b));
        }
예제 #10
0
        public FileResult Excel1()
        {
            MyElectrCheck_DBDataContext mdc = new MyElectrCheck_DBDataContext();

            List <DataManager> list = new List <DataManager>();

            if (Session["inspectlist"] != null)
            {
                //将session转为集合
                list = (List <DataManager>)Session["inspectlist"];
            }

            NPOI.HSSF.UserModel.HSSFWorkbook Book   = new NPOI.HSSF.UserModel.HSSFWorkbook();
            NPOI.SS.UserModel.ISheet         sheet1 = Book.CreateSheet("Sheet1");
            NPOI.SS.UserModel.IRow           row1   = sheet1.CreateRow(0);
            row1.CreateCell(0).SetCellValue("任务编号");
            row1.CreateCell(1).SetCellValue("任务名称");
            row1.CreateCell(2).SetCellValue("线路编号(起始杆号-终止杆号)");
            row1.CreateCell(3).SetCellValue("杆塔编号");
            row1.CreateCell(4).SetCellValue("缺陷级别");
            row1.CreateCell(5).SetCellValue("缺陷类型");
            row1.CreateCell(6).SetCellValue("发现时间");
            row1.CreateCell(7).SetCellValue("缺陷描述");
            for (int i = 0; i < list.Count; i++)
            {
                NPOI.SS.UserModel.IRow rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue(list[i].inspectionTaskCode);
                rowtemp.CreateCell(1).SetCellValue(list[i].inspectionTaskName);
                rowtemp.CreateCell(2).SetCellValue(list[i].lineCode + "(" + list[i].startPoleCode + "-" + list[i].endPoleCode + ")");
                rowtemp.CreateCell(3).SetCellValue(list[i].poleCode);
                rowtemp.CreateCell(4).SetCellValue(list[i].buglevelname);
                rowtemp.CreateCell(5).SetCellValue(list[i].bugtypename);
                rowtemp.CreateCell(6).SetCellValue(list[i].discoverTime.ToString());
                rowtemp.CreateCell(7).SetCellValue(list[i].bugDesc);
            }
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            Book.Write(ms);
            ms.Seek(0, System.IO.SeekOrigin.Begin);
            DateTime dt       = DateTime.Now;
            string   dateTime = dt.ToString("yyMMddHHmmssff");
            string   fileName = "查询结果" + dateTime + ".xls";

            return(File(ms, "application/vnd.ms-excel", fileName));
        }
예제 #11
0
        public ActionResult Del()
        {
            MyElectrCheck_DBDataContext mdc = new MyElectrCheck_DBDataContext();
            int  id     = int.Parse(Request.Params["id"]);
            bool b      = false;
            var  count1 = mdc.ps_line_info.Count();
            var  result = (from l in mdc.ps_line_info
                           where l.id == id
                           select l).FirstOrDefault();

            mdc.ps_line_info.DeleteOnSubmit(result);
            mdc.SubmitChanges();
            var count2 = mdc.ps_line_info.Count();

            if (count1 > count2)
            {
                b = true;
            }
            return(Json(b));
        }
예제 #12
0
        public ActionResult GetData()
        {
            int pageindex = int.Parse(Request.Params["pageindex"]);

            MyElectrCheck_DBDataContext medc = new MyElectrCheck_DBDataContext();

            int skip = (pageindex - 1) * 6;

            var rolelist = (from r in medc.ps_role
                            select r).ToList();

            DataSource ds = new DataSource();

            ds.rolelist = rolelist.Skip(skip).Take(6).ToList();

            ds.rolecount = rolelist.Count();

            string jsonstr = JsonConvert.SerializeObject(ds);

            return(Content(jsonstr));
        }
예제 #13
0
        //删除数据
        public ActionResult DelData()
        {
            string rid = Request.Params["roleid"];

            MyElectrCheck_DBDataContext medc = new MyElectrCheck_DBDataContext();

            //获得session中保存的值
            int id   = int.Parse(Session["userid"].ToString());
            var user = (from u in medc.ps_user
                        where u.id == id
                        select u).FirstOrDefault();

            var role = (from u in medc.ps_role
                        where u.id == rid
                        select u).FirstOrDefault();

            bool b = true;

            medc.ps_role.DeleteOnSubmit(role);

            try
            {
                medc.SubmitChanges();

                ps_logs logs = new ps_logs()
                {
                    userCode        = user.userCode,
                    userName        = user.userName,
                    operateInfo     = "删除角色信息",
                    operateDateTime = DateTime.Now
                };
                medc.ps_logs.InsertOnSubmit(logs);
                medc.SubmitChanges();
            }
            catch (Exception)
            {
                b = false;
            }
            return(Json(b));
        }
예제 #14
0
        public ActionResult Sel()
        {
            string lineCode = "";
            int    status   = -1;

            if (Request.Params["lineCode"] != null)
            {
                lineCode = Request.Params["lineCode"];
            }
            if (Request.Params["status"] != null)
            {
                if (Request.Params["status"] != "no")
                {
                    status = int.Parse(Request.Params["status"]);
                }
            }

            MyElectrCheck_DBDataContext mdc = new MyElectrCheck_DBDataContext();

            int pageindex = int.Parse(Request.Params["pageindex"]);

            int skip = (pageindex - 1) * 5;
            List <ps_line_info> list = new List <ps_line_info>();
            var result = (from l in mdc.ps_line_info
                          select l).ToList();

            if (status != -1 && lineCode != "")
            {
                foreach (var v in result)
                {
                    if (v.lineCode.Contains(lineCode) && v.runningStatus == status)
                    {
                        list.Add(v);
                    }
                }
            }
            else if (status != -1)
            {
                foreach (var v in result)
                {
                    if (v.runningStatus == status)
                    {
                        list.Add(v);
                    }
                }
            }
            else if (lineCode != "")
            {
                foreach (var v in result)
                {
                    if (v.lineCode.Contains(lineCode))
                    {
                        list.Add(v);
                    }
                }
            }
            else
            {
                foreach (var v in result)
                {
                    list.Add(v);
                }
            }
            DataSource ds = new DataSource();

            ds.datalist  = list.Skip(skip).Take(5).ToList();
            ds.linecount = list.Count();
            string str = JsonConvert.SerializeObject(ds);

            return(Content(str));;
        }
예제 #15
0
        public ActionResult SelectData()
        {
            string rolename = "";
            int    status   = -1;

            if (Request.Params["rolename"] != null)
            {
                rolename = Request.Params["rolename"];
            }
            if (Request.Params["status"] != null)
            {
                if (Request.Params["status"].ToString() != "no")
                {
                    status = int.Parse(Request.Params["status"]);
                }
            }
            int pageindex = int.Parse(Request.Params["pageindex"]);

            int skip = (pageindex - 1) * 6;

            MyElectrCheck_DBDataContext medc = new MyElectrCheck_DBDataContext();

            List <ps_role> list = new List <ps_role>();

            var rolelist = (from r in medc.ps_role
                            select r).ToList();

            if (status != -1 && rolename != "")
            {
                foreach (var v in rolelist)
                {
                    if (v.roleName.Contains(rolename) && v.isStart == status)
                    {
                        list.Add(v);
                    }
                }
            }
            else if (status != -1)
            {
                foreach (var v in rolelist)
                {
                    if (v.isStart == status)
                    {
                        list.Add(v);
                    }
                }
            }
            else if (rolename != "")
            {
                foreach (var v in rolelist)
                {
                    if (v.roleName.Contains(rolename))
                    {
                        list.Add(v);
                    }
                }
            }
            else
            {
                foreach (var v in rolelist)
                {
                    list.Add(v);
                }
            }

            DataSource ds = new DataSource();

            ds.rolelist = list.Skip(skip).Take(6).ToList();

            ds.rolecount = list.Count();

            string jsonstr = JsonConvert.SerializeObject(ds);

            return(Content(jsonstr));
        }