/// <summary>
        /// 账号注册
        /// </summary>
        /// <param name="police"></param>
        /// <returns></returns>
        public bool AccountRegister(Login_AdminModel adminmodel, string filenames, string username, string ip)
        {
            bool bl = false;

            bl = accountdal.AccountRegister(adminmodel, filenames, username, ip);
            return(bl);
        }
        public ActionResult LoginCheckUser(string user_name, string user_password)
        {
            // string userName = Request["userName"];
            // string userPwd = Request["userPwd"];

            Login_AdminModel adminmodel = new Login_AdminModel();
            Login_Record     record     = new Login_Record();

            IpHelper iphel        = new IpHelper();
            string   ip           = iphel.GetRealIP();
            string   responseText = "";
            string   address;

            address = iphel.GetPosition(ip);
            Response.Cookies["ip"].Value        = ip;
            Response.Cookies["ip"].Expires      = DateTime.Now.AddHours(2);
            Response.Cookies["address"].Value   = address;
            Response.Cookies["address"].Expires = DateTime.Now.AddHours(2);

            adminmodel = lgBll.loginCheckUser(user_name, user_password);
            /*********记录当前登陆用户信息作日志*********/
            record.Ip         = ip;
            record.Address    = address;
            record.Guid       = adminmodel.Guid;
            record.User_name  = adminmodel.Admin_name;
            record.Admin_id   = adminmodel.Admin_id;
            record.Sigin_time = DateTime.Now.ToString();

            /*********记录当前登陆用户信息作日志*********/
            if (adminmodel.bl)
            {
                record.Sigin_content = "登录成功";

                responseText = "[{\"msg\":\"success\",\"status\":\"" + adminmodel.backmessage + "\"}]";
                Response.Cookies["userName"].Value   = System.Web.HttpContext.Current.Server.UrlEncode(adminmodel.Admin_name);
                Response.Cookies["userName"].Expires = DateTime.Now.AddHours(2);
                //  Response.Cookies["userName"].Expires = DateTime.Now.AddMinutes(1);


                Response.Cookies["ADMIN_ID"].Value   = adminmodel.Admin_id;
                Response.Cookies["ADMIN_ID"].Expires = DateTime.Now.AddHours(2);
                Response.Cookies["GUID"].Value       = adminmodel.Guid;
                Response.Cookies["GUID"].Expires     = DateTime.Now.AddHours(2);



                //   Response.Cookies["Role_id"].Expires = DateTime.Now.AddMinutes(1);
                //ViewBag.welcome = police.Police_name;
                //ViewBag.author_id = police.Role_id;
            }
            else
            {
                responseText         = "[{\"msg\":\"fail\",\"status\":\"" + adminmodel.backmessage + "\"}]";
                record.Sigin_content = "登录失败";
            }
            lgBll.loginRecord(record);//日志
            return(Content(responseText));
        }
        /// <summary>
        /// 账号修改视图
        /// </summary>
        /// <returns></returns>
        public ActionResult AccountModify()
        {
            string guid = Request["guid"];

            Login_AdminModel usfo = new Login_AdminModel();

            usfo = accountbll.AccountEdit(guid);

            return(View(usfo));
        }
        /// <summary>
        /// 修改账号信息
        /// </summary>
        /// <param name="police"></param>
        /// <returns></returns>
        public bool AccountEdit(Login_AdminModel adminmodel, string username, string ip)
        {
            bool bl   = false;
            int  flag = accountdal.AccountEdit(adminmodel, username, ip);

            if (flag != 0)
            {
                bl = true;
            }
            return(bl);
        }
Beispiel #5
0
        /// <summary>
        /// 账号注册
        /// </summary>
        /// <param name="police"></param>
        /// <returns></returns>
        public bool AccountRegister(Login_AdminModel adminmodel, string filenames, string username, string ip)
        {
            bool      bl      = false;
            string    sql     = "select * from GX_ADMIN_ACCOUNT where ADMIN_NAME=:admin_name";
            string    log     = "";
            string    time    = DateTime.Now.ToString();
            bool      logFlag = false;
            DataTable dt      = OracleHelper.GetTable(sql, new OracleParameter(":admin_name", adminmodel.Admin_name));

            if (dt.Rows.Count != 0)
            {
                bl = false;
            }
            else
            {
                string oracle = "insert into GX_ADMIN_ACCOUNT(GUID,ADMIN_NAME,ADMIN_PASSWORD,ADMIN_ID,HEAD,REG_TIME) " +
                                "values(:guid,:adminname,:adminpassword,:adminid,:head,:reg_time)";
                OracleParameter[] orpa =
                {
                    new   OracleParameter(":guid",          OracleType.VarChar, 400),
                    new   OracleParameter(":adminname",     OracleType.VarChar, 400),
                    new   OracleParameter(":adminpassword", OracleType.VarChar, 400),
                    new   OracleParameter(":adminid",       OracleType.VarChar, 400),
                    new   OracleParameter(":head",          OracleType.VarChar, 400),
                    new   OracleParameter(":reg_time",      OracleType.VarChar, 400)
                };
                orpa[0].Value = Guid.NewGuid().ToString("D");
                orpa[1].Value = adminmodel.Admin_name;
                orpa[2].Value = adminmodel.Admin_password;
                orpa[3].Value = adminmodel.Admin_id;
                orpa[4].Value = filenames;
                orpa[5].Value = time;
                int flag = OracleHelper.ExecuteNonQuery(oracle, orpa);
                if (flag != 0)
                {
                    bl      = true;
                    logFlag = true;
                }
            }
            if (logFlag)
            {
                log = username + " 成功注册了一个名字为" + adminmodel.Admin_name + "的新用户";
            }
            else
            {
                log = username + " 注册新用户失败";
            }
            lgdal.setOperationLog(username, log, ip);
            return(bl);
        }
        public ContentResult AccountSaveRegister(Login_AdminModel adminmodel)
        {
            string        fileExt   = "";
            List <string> filename  = new List <string>();
            string        filenames = "";
            bool          bl;
            string        response;

            if (Request.Cookies["ip"] != null)
            {
                ip = Request.Cookies["ip"].Value;
            }
            if (Request.Cookies["userName"] != null)
            {
                username = System.Web.HttpContext.Current.Server.UrlDecode(Request.Cookies["userName"].Value);
            }
            /****************上传图片到服务器****************/
            //int cnt = System.Web.HttpContext.Current.Request.Files.Count;
            //if (cnt == 0)
            //{
            //    filenames = "";
            //}
            //for (int i = 0; i < cnt; i++)
            //{
            //    HttpPostedFile hpf = System.Web.HttpContext.Current.Request.Files[i];
            //    filenames = Path.GetFileName(hpf.FileName);
            //    fileExt = Path.GetExtension(hpf.FileName).ToLower();//带.的后缀
            //    filename.Add(filenames);
            //    string fileFilt = ".jpg|.png|.JPG|.PNG|......";
            //    if ((fileFilt.IndexOf(fileExt) <= -1) || (fileExt == "") || (hpf.ContentLength > 4 * 1024 * 1024))
            //        continue;
            ////    D:\MVCRoot\blueunion\uploadimages\Head
            //    hpf.SaveAs("D:\\MVCRoot\\gxdzbackstage\\image\\Head\\" + filenames);
            //    //hpf.SaveAs("D:\\MVCRoot\\blueunion\\uploadimages\\Head\\" + filenames);
            //}
            /****************上传图片到服务器****************/
            bl = accountbll.AccountRegister(adminmodel, filenames, username, ip);
            if (bl)
            {
                response = "{\"msg\":\"success\",\"status\":\"注册账号成功\"}";
            }
            else
            {
                response = "{\"msg\":\"fail\",\"status\":\"注册账号失败\"}";
            }

            return(Content(response));
        }
Beispiel #7
0
        public Login_AdminModel loginCheckUser(string user_name, string user_password)
        {
            Login_AdminModel usfo = new Login_AdminModel();



            DataTable dt = lgDal.loginCheckUser(user_name);

            if (dt.Rows.Count == 0)
            {
                usfo.bl          = false;
                usfo.backmessage = "查无此用户";
                return(usfo);
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                usfo.Admin_name = dt.Rows[i]["ADMIN_NAME"].ToString();

                usfo.Admin_password = dt.Rows[i]["ADMIN_PASSWORD"].ToString();
                usfo.Admin_id       = dt.Rows[i]["ADMIN_ID"].ToString();
                usfo.Guid           = dt.Rows[i]["GUID"].ToString();
            }
            if (usfo.Admin_name == user_name)
            {
                if (usfo.Admin_password == user_password)
                {
                    usfo.bl          = true;
                    usfo.backmessage = "正确";
                }
                else
                {
                    usfo.bl          = false;
                    usfo.backmessage = "密码输入不正确";
                }
            }
            else
            {
                usfo.bl          = false;
                usfo.backmessage = "用户名输入不正确";
            }

            return(usfo);
        }
        /// <summary>
        /// 显示登陆的账号信息
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public Login_AdminModel AccountEdit(string guid)
        {
            Login_AdminModel usfo = new Login_AdminModel();
            DataTable        dt   = accountdal.AccountEdit(guid);

            if (dt.Rows.Count == 0)
            {
                usfo.bl          = false;
                usfo.backmessage = "查无此用户";
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                usfo.Admin_name     = dt.Rows[i]["ADMIN_NAME"].ToString();
                usfo.Admin_password = dt.Rows[i]["ADMIN_PASSWORD"].ToString();
                usfo.Admin_id       = dt.Rows[i]["ADMIN_ID"].ToString();
                usfo.Guid           = dt.Rows[i]["GUID"].ToString();
                usfo.bl             = true;
                usfo.backmessage    = "查到正确信息";
            }
            return(usfo);
        }
Beispiel #9
0
        /// <summary>
        /// 修改账号信息
        /// </summary>
        /// <param name="police"></param>
        /// <returns></returns>
        public int AccountEdit(Login_AdminModel adminmodel, string username, string ip)
        {
            int    flag    = 0;
            string log     = "";
            bool   logFlag = false;
            string sql     = "update GX_ADMIN_ACCOUNT set ADMIN_NAME=:adminname,ADMIN_PASSWORD=:adminpassword,ADMIN_ID=:adminid where GUID=:guid";

            OracleParameter[] orpa =
            {
                new   OracleParameter(":adminname",     OracleType.VarChar, 400),
                new   OracleParameter(":adminpassword", OracleType.VarChar, 400),
                new   OracleParameter(":adminid",       OracleType.VarChar, 400),
                new   OracleParameter(":guid",          OracleType.VarChar, 400)
            };

            orpa[0].Value = adminmodel.Admin_name;
            orpa[1].Value = adminmodel.Admin_password;
            orpa[2].Value = adminmodel.Admin_id;
            orpa[3].Value = adminmodel.Guid;


            flag = OracleHelper.ExecuteNonQuery(sql, orpa);
            if (flag > 0)
            {
                logFlag = true;
            }
            if (logFlag)
            {
                log = username + " 修改id为" + adminmodel.Guid + "的用户信息成功";
            }
            else
            {
                log = username + " 修改id为" + adminmodel.Guid + "的用户信息失败";
            }
            lgdal.setOperationLog(username, log, ip);
            return(flag);
        }
        public ContentResult AccountSaveModify(Login_AdminModel adminmodel)
        {
            string response = "";

            if (Request.Cookies["ip"] != null)
            {
                ip = Request.Cookies["ip"].Value;
            }
            if (Request.Cookies["userName"] != null)
            {
                username = System.Web.HttpContext.Current.Server.UrlDecode(Request.Cookies["userName"].Value);
            }
            bool bl = accountbll.AccountEdit(adminmodel, username, ip);

            if (bl)
            {
                response = "{\"msg\":\"success\",\"status\":\"修改账号成功\"}";
            }
            else
            {
                response = "{\"msg\":\"fail\",\"status\":\"修改账号失败\"}";
            }
            return(Content(response));
        }