示例#1
0
        /// <summary>
        ///用户表的显示
        /// </summary>
        /// <returns></returns>
        public List <UserinfoModel> UserinfoList()
        {
            string        str = @"SELECT [Userid]
      ,[Username]
      ,[Userpwd]
      ,[Userrole]
      ,[Usercheng]
      ,[Usersex]
      ,[Userstate]
  FROM [dbo].[UserInfo]";
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            SqlCommand           command = new SqlCommand(str, con);
            List <UserinfoModel> list    = new List <UserinfoModel>();
            SqlDataReader        reader  = command.ExecuteReader();

            while (reader.Read())
            {
                UserinfoModel mm = new UserinfoModel();
                mm.Userid    = Convert.ToInt32(reader["Userid"].ToString());
                mm.Username  = reader["Username"].ToString();
                mm.Userpwd   = reader["Userpwd"].ToString();
                mm.Userrole  = Convert.ToInt32(reader["Userrole"].ToString());
                mm.Usercheng = reader["Usercheng"].ToString();
                mm.Usersex   = Convert.ToInt32(reader["Usersex"].ToString());
                mm.Userstate = Convert.ToInt32(reader["Userstate"].ToString());
                list.Add(mm);
            }
            con.Close();
            return(list);
        }
示例#2
0
        public ActionResult EditUserinfo(UserinfoModel model)
        {
            //管理员组
            ViewData["RGroups"] = new SelectList(RGroupService.GetRoleGroups(), "RG_no", "RG_name");
            //验证
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            int result = 0;

            //修改
            if (model.U_no != null)
            {
                result = userService.UpdateUser(Mapper.Map <Userinfo>(model));
            }
            //新增
            else
            {
                model.U_regtime = DateTime.Now;
                result          = userService.InsertUser(Mapper.Map <Userinfo>(model));
            }
            if (result != 0)
            {
                return(RedirectToAction("UserinfoList"));
            }
            return(View(model));
        }
示例#3
0
        protected override void OnRequest()
        {
            base.OnRequest();

            ChatContent chatContent = getModel <ChatContent>();

            try
            {
                if (chatContent != null)
                {
                    UserinfoModel userModel = null;
                    using (Controller.Account controllerAccount = new Controller.Account())
                    {
                        userModel = controllerAccount.GetUserinfo(aid);
                        if (userModel == null)
                        {
                            throw new UnfulfilException(0, "未找到指定用户");
                        }
                    }

                    String sendUserName = userModel.userNickname;
                    new Controller.Message().AddMessage(chatContent.userid, chatContent.content, this.aid, Controller.Message.MESSAGE_STATUS.UNREACH, Controller.Message.MESSAGE_STYLE.INFORMATION, sendUserName, Controller.Message.MESSAGE_TYPE.CHAT);
                    WriteSuccess <string>("发送成功");
                }
                else
                {
                    WriteUnfulfil("");
                }
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
示例#4
0
        public ActionResult Create([Bind(Include = "UserInfoID,DateOfBirth,PhoneNumber,Adress,UserImage,fk_GenderID")] UserinfoModel Userinfo)
        {
            var dataSet = Session["Users"] as tbl_Member;

            var member = db.tbl_Userinfo.FirstOrDefault(m => m.fk_UserID == dataSet.UserID);


            if (ModelState.IsValid)
            {
                if (member == null)
                {
                    var userinfo = new tbl_Userinfo();
                    userinfo.UserInfoID  = Userinfo.UserInfoID;
                    userinfo.Adress      = Userinfo.Adress;
                    userinfo.DateOfBirth = Userinfo.DateOfBirth;
                    userinfo.PhoneNumber = Userinfo.PhoneNumber;
                    userinfo.UserImage   = Userinfo.UserImage;
                    userinfo.fk_GenderID = Userinfo.fk_GenderID;
                    var userData = Session["Users"] as tbl_Member;
                    userinfo.fk_UserID = userData.UserID;
                    db.tbl_Userinfo.Add(userinfo);
                    db.SaveChanges();

                    return(RedirectToAction("Show"));
                }
                else
                {
                    ViewBag.den = "Zaten bir kaydınız var.";
                    return(RedirectToAction("UserToDoList", "Home"));
                }
            }
            ViewBag.fk_GenderID = new SelectList(db.tbl_Gender, "GenderID", "Gender", Userinfo.fk_GenderID);
            return(View(Userinfo));
        }
        public HttpResponseMessage EditCurrentUserInfo([FromBody] UserinfoModel userinfo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }
                using (WebbanhangDBEntities entities = new WebbanhangDBEntities())
                {
                    entities.Configuration.ProxyCreationEnabled = false;
                    string uid    = User.Identity.GetUserId();
                    var    entity = entities.UserInfos.FirstOrDefault(e => e.UserID == uid);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Có lỗi xảy ra"));
                    }
                    else
                    {
                        entity.Name        = userinfo.Name;
                        entity.HomeAddress = userinfo.HomeAddress;
                        entity.Email       = userinfo.Email;
                        entity.PhoneNumber = userinfo.PhoneNumber;
                        entity.CMND        = userinfo.CMND;
                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, "Đã sửa"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
示例#6
0
        public ActionResult Show()
        {// find 1 den fazla yani liste şeklinde firsordefault ise sadece  1 kayıt döndürür
            var           dataSet       = Session["Users"] as tbl_Member;
            UserinfoModel userinfoModel = null;

            ViewBag.Name = dataSet.UserName + " " + dataSet.UserSurname;
            var userinfo = db.tbl_Userinfo.FirstOrDefault(p => p.fk_UserID == dataSet.UserID);

            if (userinfo != null)
            {
                if (userinfo.fk_GenderID == 1)
                {
                    ViewBag.Gender = "Male";
                }
                else
                {
                    ViewBag.Gender = "Female";
                }

                userinfoModel = new UserinfoModel
                {
                    DateOfBirth = userinfo.DateOfBirth,
                    PhoneNumber = userinfo.PhoneNumber,
                    Adress      = userinfo.Adress,
                    UserImage   = userinfo.UserImage
                };
            }



            return(View(userinfoModel));
        }
示例#7
0
        public UserinfoModel GetUserinfo(uint aid)
        {
            UserinfoModel userInfo = null;

            string where = String.Format("view_userinfo.aid={0}", aid);
            List <ViewUserinfoModel> list = db.SelectData <ViewUserinfoModel>("view_userinfo", where);

            if (list != null)
            {
                userInfo = new UserinfoModel();
                ViewUserinfoModel userinfoModel = list[0];

                if (DateTime.Compare((DateTime)userinfoModel.MemberValid, DateTime.Now) > 0)
                {
                    userInfo.memberValid = true;
                }
                else
                {
                    userInfo.memberValid = false;
                }

                userInfo.userAvatar   = userinfoModel.Avatar;
                userInfo.userID       = (uint)userinfoModel.aid;
                userInfo.userMail     = userinfoModel.Mail;
                userInfo.userNickname = userinfoModel.Nickname;
                userInfo.userPhone    = userinfoModel.Name;
            }

            return(userInfo);
        }
示例#8
0
        /// <summary>
        /// 登录判断
        /// </summary>
        /// <returns></returns>
        public int LoginDo()
        {
            //
            UserinfoModel        mm        = new UserinfoModel();
            string               username  = Request["sname"];;
            string               pwd       = Request["spwd"];
            int                  isChecked = Convert.ToInt32(Request["isChecked"]);
            List <UserinfoModel> list      = bll.UserinfoList();
            UserinfoModel        Ulist     = list.Where(p => p.Username == username && p.Userpwd == pwd).FirstOrDefault();

            if (Ulist != null)
            {
                Session["userid"] = Ulist.Userid;
                //选中记住密码复选框后创建Cookie
                if (isChecked == 1)
                {
                    HttpCookie cookie = new HttpCookie("UserInfo");
                    //如果不存在该Cookie
                    if (cookie == null)
                    {
                        cookie["Uname"] = Ulist.Username;
                        cookie["Upwd"]  = Ulist.Userpwd;
                        cookie.Expires.AddDays(3);
                        Response.Cookies.Add(cookie);
                    }
                    else
                    {
                        if (Ulist.Username == cookie["Uname"])
                        {
                        }
                        else
                        {
                            HttpCookie newCookie = new HttpCookie("UserInfo");
                            cookie["Uname"] = Ulist.Username;
                            cookie["Upwd"]  = Ulist.Userpwd;
                            cookie.Expires  = DateTime.Now.AddDays(10);
                            Response.Cookies.Set(cookie);
                        }
                    }
                }
                else
                {
                    HttpCookie theCookie = Request.Cookies["UserInfo"];
                    if (theCookie != null)
                    {
                        theCookie.Values.Remove("Uname");
                        theCookie.Values.Remove("Upwd");
                        theCookie.Expires = DateTime.Now.AddDays(1);
                        Response.Cookies.Add(theCookie);
                    }
                }
                return(1);
            }
            else
            {
                return(0);
            }
        }
示例#9
0
        public JsonResult userinfo()
        {
            int id = Convert.ToInt32(Session["userid"]);
            List <UserinfoModel> list = usbl.UserinfoList();
            UserinfoModel        user = new UserinfoModel();

            user = list.Where(p => p.Userid == id).FirstOrDefault();
            return(Json(user));
        }
示例#10
0
        public UserinfoModel userInfo(string userid, string Typecard)
        {
            HttpContext context  = HttpContext.Current;
            var         Userdata = (UserLoginModel)context.Items["user_data"];

            UserinfoModel userinfo = new UserinfoModel();

            userinfo = this._memberService.userinfo(userid, Userdata.CompanyID, Typecard);
            return(userinfo);
        }
        public ActionResult UserInfo()
        {
            //获得用户ID
            string UserId = (string)Session["id"];

            //获得用户信息,填model
            UserinfoModel model = new UserinfoModel(null, null, null, null, null, 0);

            //model = getUserInfo(UserId);
            return(View(model));//View(Model model)
        }
示例#12
0
        /// <summary>
        /// 判断用户名是否已存在
        /// </summary>
        /// <param name="mm"></param>
        /// <returns></returns>
        public int UserinfoCount(UserinfoModel mm)
        {
            string        str = string.Format(@"SELECT count(1) [Username]  FROM [dbo].[UserInfo] where Username='******'", mm.Username);
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            SqlCommand com = new SqlCommand(str, con);
            int        i   = Convert.ToInt32(com.ExecuteScalar());

            con.Close();
            return(i);
        }
示例#13
0
        /// <summary>
        ///用户登录时判断是否存在该用户
        /// </summary>
        /// <returns></returns>
        public int UserinfoLogin(UserinfoModel mm)
        {
            string        str = string.Format(@"SELECT   [Userid] ,[Username] ,[Userpwd]  FROM [dbo].[UserInfo] 
            where [Username]='{0}' and [Userpwd]='{1}'", mm.Username, mm.Userpwd);
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            SqlCommand command = new SqlCommand(str, con);
            int        i       = Convert.ToInt32(command.ExecuteScalar());

            con.Close();
            return(i);
        }
        public ActionResult ManageAccountInfo(/*string UserId*/)
        {
            //检查是否管理员
            if (needRedirect())
            {
                return(redirectAction);
            }
            //找到用户信息,填写model
            UserinfoModel model = new UserinfoModel(null, null, null, null, null, 0);

            //model = getUserInfo(UserId);
            return(View("UserInfo", model));//View(models)
        }
示例#15
0
        public ActionResult Edit(UserinfoModel Userinfo)
        {
            var dataSet = Session["Users"] as tbl_Member;
            var member  = db.tbl_Userinfo.FirstOrDefault(m => m.fk_UserID == dataSet.UserID);

            member.Adress      = Userinfo.Adress;
            member.DateOfBirth = Userinfo.DateOfBirth;
            member.PhoneNumber = Userinfo.PhoneNumber;
            member.UserImage   = Userinfo.UserImage;
            member.fk_GenderID = Userinfo.fk_GenderID;
            db.SaveChanges();
            return(RedirectToAction("Show"));
        }
示例#16
0
        /// <summary>
        /// 用户表的删除
        /// </summary>
        /// <param name="mm"></param>
        /// <returns></returns>
        public int UserinfoDelete(UserinfoModel mm)
        {
            string        str = string.Format(@"
DELETE FROM [dbo].[UserInfo]
      WHERE  Userid='{0}'", mm.Userid);
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            SqlCommand com = new SqlCommand(str, con);
            int        i   = com.ExecuteNonQuery();

            con.Close();
            return(i);
        }
示例#17
0
        /// <summary>
        /// 用户表的修改
        /// </summary>
        /// <param name="mm"></param>
        /// <returns></returns>
        public int UserinfoUpdate(UserinfoModel mm)
        {
            string        str = string.Format(@"UPDATE [dbo].[UserInfo]
   SET [Userpwd] = '{0}'
      ,[Usercheng] = '{1}'
      ,[Usersex] = '{2}'
 WHERE Userid='{3}' ", mm.Userpwd, mm.Usercheng, mm.Usersex, mm.Userid);
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            SqlCommand com = new SqlCommand(str, con);
            int        i   = com.ExecuteNonQuery();

            con.Close();
            return(i);
        }
示例#18
0
        private void FillPage(string id)
        {
            string totalprice = Convert.ToString(HttpContext.Current.Session["total_price"]);
            // get data from the given id

            UserinfoModel db   = new UserinfoModel();
            Users         user = db.Get_userinfo(id);

            // fill text boxes with the new data

            FullName.Text    = user.FullName;
            email.Text       = user.Email;
            ContactNum.Text  = Convert.ToString(user.Contact);
            address.Text     = user.Address;
            total_price.Text = totalprice;
        }
示例#19
0
        public ActionResult Edit()
        {
            var dataSet = Session["Users"] as tbl_Member;
            var member  = db.tbl_Userinfo.FirstOrDefault(m => m.fk_UserID == dataSet.UserID);
            var change  = new UserinfoModel();

            change.UserInfoID   = member.UserInfoID;
            change.Adress       = member.Adress;
            change.DateOfBirth  = member.DateOfBirth;
            change.PhoneNumber  = member.PhoneNumber;
            change.UserImage    = member.UserImage;
            change.fk_UserID    = member.fk_UserID;
            ViewBag.fk_GenderID = new SelectList(db.tbl_Gender, "GenderID", "Gender");


            return(View(change));
        }
示例#20
0
        /// <summary>
        /// 点赞
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int dianzan(int id)
        {
            LikesBLL      lbll = new LikesBLL();
            UserinfoModel m    = Session["userid"] as UserinfoModel;
            LikesModel    z    = new LikesModel();

            z.UserId  = m.Userid;
            z.Worksid = id;
            if (lbll.LikesADD(z) > 0)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
示例#21
0
        public async Task <IActionResult> GetLogin(string user_id, string user_pw, string token)
        {
            if (User.Identity != null && User.Identity.IsAuthenticated == true)
            {
                Redirect("/");
            }

            try
            {
                var verify = await ReCaptchaModel.RecaptchaVerify(token);

                if (verify.Success == false || verify.Score < 0.3F)
                {
                    return(Json(new { msg = string.Join(',', verify.ErrorCodes) }));
                }

                var login = UserinfoModel.GetLogin(user_id, user_pw);

                if (login == null) //로그인 오류
                {
                    return(Redirect("/"));
                }

                var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role);

                identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, login.USER_ID));
                identity.AddClaim(new Claim(ClaimTypes.Name, login.USER_NAME));
                identity.AddClaim(new Claim(ClaimTypes.Role, login.ROLES));
                identity.AddClaim(new Claim("NextCheckDate", DateTime.Now.AddMinutes(1).ToString("yyyyMMddHHmmss"), typeof(DateTime).ToString()));

                var principal = new ClaimsPrincipal(identity);
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties {
                    IsPersistent = false,                      //로그인 쿠키 영속성 (브라우저 종료시 유지) 여부
                    ExpiresUtc   = DateTime.UtcNow.AddDays(7), //7일간 미접속시 쿠키 만료
                    AllowRefresh = true,                       //갱신여부
                });

                return(Json(new { msg = "OK" }));
            }
            catch (Exception ex)
            {
                return(Json(new { msg = ex.Message }));
            }
        }
示例#22
0
        /// <summary>
        /// 用户表的注册
        /// </summary>
        /// <returns></returns>
        public int UserinfoADD(UserinfoModel mm)
        {
            string        str = string.Format(@"INSERT INTO [dbo].[UserInfo]
           ([Username]
           ,[Userpwd]
           ,[Userrole]
           ,[Usercheng]
           ,[Usersex]
           ,[Userstate])
     VALUES
           ('{0}','{1}','{2}','{3}','{4}','{5}')", mm.Username, mm.Userpwd, mm.Userrole, mm.Usercheng, mm.Usersex, mm.Userstate);
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            SqlCommand com = new SqlCommand(str, con);
            int        i   = com.ExecuteNonQuery();

            con.Close();
            return(i);
        }
示例#23
0
        public ActionResult Details()
        {
            var dataSet = Session["Users"] as tbl_Member;
            var member  = db.tbl_Userinfo.FirstOrDefault(m => m.fk_UserID == dataSet.UserID);
            var change  = new UserinfoModel();

            change.UserInfoID  = member.UserInfoID;
            change.Adress      = member.Adress;
            change.DateOfBirth = member.DateOfBirth;
            change.PhoneNumber = member.PhoneNumber;
            change.UserImage   = member.UserImage;
            if (member.fk_GenderID == 1)
            {
                ViewBag.Gender = "Male";
            }
            else
            {
                ViewBag.Gender = "Female";
            }
            return(View(change));
        }
示例#24
0
        protected override void OnRequest()
        {
            base.OnRequest();
            UserinfoModel userInfo = null;

            uint?userID = getParameterUint("user_id");

            try
            {
                if (userID == null)
                {
                    throw new UnfulfilException(0, "未指定用户");
                }

                using (Controller.Account controllerAccount = new Controller.Account())
                {
                    userInfo = controllerAccount.GetUserinfo((uint)userID);
                    if (userInfo == null)
                    {
                        throw new UnfulfilException(0, "未找到指定用户");
                    }
                }

                WriteSuccess <UserinfoModel>(userInfo);
            }
            catch (UnfulfilException ex)
            {
                WriteUnfulfil(ex.DisplayMessage);
            }
            catch (Database.Exception ex)
            {
                WriteException(ex);
            }
            catch (Exception ex)
            {
                WriteException(ex);
            }
        }
示例#25
0
        public int upda()
        {
            UserinfoModel ml = new UserinfoModel();

            ml.Userid    = Convert.ToInt32(Session["userid"]);
            ml.Usercheng = Request["cheng"];
            string sex = Request["sex"].ToString();

            if (sex == "男")
            {
                ml.Usersex = 1;
            }
            else if (sex == "女")
            {
                ml.Usersex = 2;
            }
            else
            {
                ml.Usersex = 0;
            }
            ml.Userpwd = Request["pwd"];
            return(usbl.UserinfoUpdate(ml));
        }
示例#26
0
        /// <summary>
        /// 注册判断
        /// </summary>
        /// <returns></returns>
        public int RegisterDo()
        {
            UserinfoModel mm = new UserinfoModel();

            mm.Username  = Request["sname"];
            mm.Userpwd   = Request["spwd"];
            mm.Userstate = 1;
            if (bll.UserinfoCount(mm) >= 1)
            {
                return(1);
            }
            else
            {
                if (bll.UserinfoADD(mm) > 0)
                {
                    return(3);
                }
                else
                {
                    return(0);
                }
            }
        }
        public HttpResponseMessage Put(int id, [FromBody] UserinfoModel userinfo)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
                }

                using (WebbanhangDBEntities entities = new WebbanhangDBEntities())
                {
                    entities.Configuration.ProxyCreationEnabled = false;
                    var entity = entities.UserInfos.FirstOrDefault(e => e.UserInfoID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                           "User Info with Id " + id.ToString() + " not found to update"));
                    }
                    else
                    {
                        entity.Name        = userinfo.Name;
                        entity.HomeAddress = userinfo.HomeAddress;
                        entity.Email       = userinfo.Email;
                        entity.PhoneNumber = userinfo.PhoneNumber;
                        entity.CMND        = userinfo.CMND;
                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, "Edited"));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
示例#28
0
        public UserinfoModel userinfo(string userId, string TernCode, string TypeCard)
        {
            DataTable     dt       = new DataTable();
            UserinfoModel userinfo = new UserinfoModel();
            string        sql      = "";

            if (TypeCard.Equals("C"))
            {
                sql = " select " +
                      "  userinfo.BADGENUMBER," +
                      "  coalesce(userinfo.tfirstname,'') as name1, " +
                      "  coalesce(userinfo.tlastname,'') as LastName1, " +
                      "  case USERINFO.Member_Carbill when 1 then 'บริษัทร' when 2 then 'พนักงาน' else 'ไม่พบประเภทการเรียกเก็บเงิน' end as Carbill, " +
                      "  case USERINFO.Cardcontact_Cartype when 0 then 'Temp' when 1 then 'Fix' when 2 then 'Cir' when 3 then ' Fix pay more' when 4 then 'Cir up Fix'  end as Cartype, " +
                      "  convert(nvarchar(10), USERINFO.Firstdate_Car,120) as Firstdate, " +
                      "  convert(nvarchar(10), USERINFO.Expdate_Car,120) as Expdate ,  " +
                      "  USERINFO.CarID as vehicalID, " +
                      "  USERINFO.CarModel as Model, " +
                      "  USERINFO.Carcolor as color," +
                      "  USERINFO.CarID1 as vehicalID1," +
                      "  USERINFO.CarModel1 as Model1, " +
                      "  USERINFO.Carcolor1 as color1," +
                      "  USERINFO.CarID2 as vehicalID2," +
                      "  USERINFO.CarModel2 as Model2, " +
                      "  USERINFO.Carcolor2 as color2 " +
                      " from userinfo left join pkdepartments on userinfo.terncode=pkdepartments.terncode " +
                      " left join vcountcardpermember_car on userinfo.badgenumber=vcountcardpermember_car.custno " +
                      " left join pkcar_contact on userinfo.Cardcontact_Car=pkcar_contact.id1 " +
                      " left join pklocation on userinfo.IssueLoc_ID_Car=pklocation.loc_id " +
                      " left join Pklocationparkingzone on userinfo.issueloc_id_car2=Pklocationparkingzone.zoneid1 " +
                      " left join pkgroupbill on userinfo.Groupmemberparking_car=pkgroupbill.groupmember " +
                      " where (usertype=1) and (ParkingMembercar=1) and USERID = '" + userId + "' and userinfo.TernCode = '" + TernCode + "' ";
            }
            else
            {
                sql = "select  " +
                      "  userinfo.BADGENUMBER, " +
                      "  coalesce(userinfo.tfirstname,'') as name1, " +
                      "  coalesce(userinfo.tlastname,'') as LastName1, " +
                      "  case USERINFO.Member_motorbill when 1 then 'บริษัทร' when 2 then 'พนักงาน' else 'ไม่พบประเภทการเรียกเก็บเงิน' end as Carbill, " +
                      "  case USERINFO.Cardcontact_motortype when 0 then 'Temp' when 1 then 'Fix' when 2 then 'Cir' when 3 then ' Fix pay more' when 4 then 'Cir up Fix'  end as Cartype, " +
                      "  convert(nvarchar(10), USERINFO.Firstdate_Motor,120)  as Firstdate, " +
                      "  convert(nvarchar(10),USERINFO.Expdate_Motor,120) as Expdate, " +
                      "  USERINFO.MotorID as vehicalID, " +
                      "  USERINFO.MotorModel as Model, " +
                      "  USERINFO.MotorColor as color, " +
                      "  USERINFO.MotorID1 as vehicalID1, " +
                      "  USERINFO.MotorModel1 as Model1, " +
                      "  USERINFO.MotorColor1  as color1, " +
                      "  USERINFO.MotorID2 as vehicalID2, " +
                      "  USERINFO.MotorModel2 as Model2, " +
                      "  USERINFO.MotorColor2 as color2 " +
                      "	from userinfo left join pkdepartments on userinfo.terncode=pkdepartments.terncode " +
                      " left join vcountcardpermember_motor on userinfo.badgenumber=vcountcardpermember_motor.custno " +
                      " left join pkcar_contact on userinfo.Cardcontact_motor=pkcar_contact.id1 " +
                      " left join pklocation on userinfo.IssueLoc_ID_motor=pklocation.loc_id " +
                      "  left join Pklocationparkingzone on userinfo.issueloc_id_motor2=Pklocationparkingzone.zoneid1 " +
                      " left join pkgroupbill on userinfo.Groupmemberparking_motor=pkgroupbill.groupmember " +
                      "  where (usertype=1) and (ParkingMembermotor=1) and " +
                      "   USERID = '" + userId + "' and userinfo.TernCode = '" + TernCode + "' ";
            }

            dt       = this.db.QueryDataTable(sql);
            userinfo = (from c in dt.AsEnumerable()
                        select new UserinfoModel
            {
                BADGENUMBER = c["BADGENUMBER"].ToString(),
                name1 = c["name1"].ToString(),
                LastName1 = c["LastName1"].ToString(),
                Carbill = c["Carbill"].ToString(),
                Cartype = c["Cartype"].ToString(),
                Firstdate = c["Firstdate"].ToString(),
                Expdate = c["Expdate"].ToString(),
                vehicalID = c["vehicalID"].ToString(),
                Model = c["Model"].ToString(),
                color = c["color"].ToString(),
                vehicalID1 = c["vehicalID1"].ToString(),
                Model1 = c["Model1"].ToString(),
                color1 = c["color1"].ToString(),
                vehicalID2 = c["vehicalID2"].ToString(),
                Model2 = c["Model2"].ToString(),
                color2 = c["color2"].ToString()
            }).SingleOrDefault();

            return(userinfo);
        }
    //[WebMethod]
    //public static string create_user(Users context)
    //{

    //    var user = new Users();
    //    user.FullName = context.FullName;
    //    user.UserName = context.UserName;
    //    user.Password = context.Password;
    //    user.Email = context.Email;
    //    user.Contact = context.Contact;
    //    user.Address = context.Address;
    //    Account_db account_db = new Account_db();
    //    account_db.create_user(user);
    //    return "Success";

    //}

    protected void createBtn_Click(object sender, EventArgs e)
    {
        UserStore <IdentityUser> userstore = new UserStore <IdentityUser>();

        userstore.Context.Database.Connection.ConnectionString =
            System.Configuration.ConfigurationManager.
            ConnectionStrings["ShopDBContext"].ConnectionString;

        UserManager <IdentityUser> manager = new UserManager <IdentityUser>(userstore);

        //creating new user and storing in database
        IdentityUser user = new IdentityUser();

        user.UserName = UserName.Text;
        if (validation())
        {
            if (password.Text == pass_confirm.Text)
            {
                try
                {
                    //create user object
                    //database will be created

                    IdentityResult result = manager.Create(user, password.Text);
                    if (result.Succeeded)
                    {
                        Users info = new Users
                        {
                            FullName = FullName.Text,
                            Email    = email.Text,
                            Contact  = Convert.ToInt64(ContactNum.Text),
                            Address  = Address.Text,
                            AuthID   = user.Id,
                            reg_Date = Convert.ToString(DateTime.Today)
                        };

                        UserinfoModel model = new UserinfoModel();
                        model.Insert_userinfo(info);

                        //store user in DB
                        var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;

                        //set to login new user by cookie
                        var userIdentity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

                        //login to the new user and redirect to the homepage
                        authenticationManager.SignIn(new AuthenticationProperties(), userIdentity);
                        Response.Redirect("~/Home.aspx");
                    }
                    else
                    {
                        litStatus.Text = String.Format("<font style='color : red;'> {0} </font>", result.Errors.FirstOrDefault());
                    }
                }
                catch (Exception ex)
                {
                    litStatus.Text = ex.ToString();
                }
            }

            else
            {
                litStatus.Text = "<font style='color : red;'>Passwords does not match</font>";
            }
        }
    }
示例#30
0
        /// <summary>
        /// 用户界面显示
        /// </summary>
        public UserHomeMODEL <UserinfoModel> UserHomeList(int id)
        {
            /// <summary>
            ///用户信息的显示
            /// </summary>
            /// <returns></returns>
            string        str = string.Format(@"SELECT [Userid]
      ,[Username]
      ,[Usercheng]
  FROM [dbo].[UserInfo] WHERE [Userid]='{0}'", id);
            SqlConnection con = new SqlConnection(conString);

            con.Open();
            SqlCommand           command = new SqlCommand(str, con);
            List <UserinfoModel> list    = new List <UserinfoModel>();
            SqlDataReader        reader  = command.ExecuteReader();

            while (reader.Read())
            {
                UserinfoModel mm = new UserinfoModel();
                mm.Userid   = Convert.ToInt32(reader["Userid"].ToString());
                mm.Username = reader["Username"].ToString();


                mm.Usercheng = reader["Usercheng"].ToString();

                list.Add(mm);
            }
            con.Close();

            //用户作品数量

            SqlConnection workscountcon     = new SqlConnection(conString);
            string        workscountsql     = string.Format(@"SELECT COUNT([Worksid]) FROM [Venus].[dbo].[Works] WHERE [Userid]='{0}'", id);
            SqlCommand    workscountcommand = new SqlCommand(workscountsql, workscountcon);

            workscountcon.Open();
            int workscount = Convert.ToInt32(workscountcommand.ExecuteScalar());

            workscountcon.Close();



            ///用户未审核作品数量
            SqlConnection notworkscountcon     = new SqlConnection(conString);
            string        notworkscountsql     = string.Format(@"SELECT COUNT([Worksid]) FROM [Venus].[dbo].[Works] WHERE [Userid]='{0}' and [Worksstate]=3", id);
            SqlCommand    notworkscountcommand = new SqlCommand(notworkscountsql, notworkscountcon);

            notworkscountcon.Open();
            int notworkscount = Convert.ToInt32(notworkscountcommand.ExecuteScalar());

            notworkscountcon.Close();

            ///用户已审核作品数量
            SqlConnection auditworkscountcon     = new SqlConnection(conString);
            string        auditworkscountsql     = string.Format(@"SELECT COUNT([Worksid]) FROM [Venus].[dbo].[Works] WHERE [Userid]='{0}' and [Worksstate]=4", id);
            SqlCommand    auditworkscountcommand = new SqlCommand(auditworkscountsql, auditworkscountcon);

            auditworkscountcon.Open();
            int auditworkscount = Convert.ToInt32(auditworkscountcommand.ExecuteScalar());

            auditworkscountcon.Close();

            ///用户收藏数量
            SqlConnection collectcountcon     = new SqlConnection(conString);
            string        collectcountsql     = string.Format(@"SELECT COUNT([collectid]) FROM [Venus].[dbo].[Collect] WHERE [Userid]='{0}'", id);
            SqlCommand    collectcountcommand = new SqlCommand(collectcountsql, collectcountcon);

            collectcountcon.Open();
            int collectcount = Convert.ToInt32(collectcountcommand.ExecuteScalar());

            collectcountcon.Close();
            ///用户评论数量
            SqlConnection reviewcountcon     = new SqlConnection(conString);
            string        reviewcountsql     = string.Format(@"SELECT COUNT([Reviewid]) FROM [Venus].[dbo].[Review] WHERE [Userid]='{0}'", id);
            SqlCommand    reviewcountcommand = new SqlCommand(reviewcountsql, reviewcountcon);

            reviewcountcon.Open();
            int reviewcount = Convert.ToInt32(reviewcountcommand.ExecuteScalar());

            reviewcountcon.Close();



            UserHomeMODEL <UserinfoModel> Userhome = new UserHomeMODEL <UserinfoModel>();

            Userhome.datalist        = list;
            Userhome.Workscount      = workscount;
            Userhome.NotWorkscount   = notworkscount;
            Userhome.auditWorkscount = auditworkscount;
            Userhome.Collectcount    = collectcount;
            Userhome.Reviewcount     = reviewcount;



            return(Userhome);
        }