Beispiel #1
0
        public ContentResult UserChangePassWordSave(User userModel)
        {
            JsonDataGridResult jsonResult = new JsonDataGridResult();
            try
            {
                string userName = User.Identity.Name.Split(',')[1];
                int userId = Convert.ToInt32(User.Identity.Name.Split(',')[0]);

                User user = UserService.GetModel(userId);
                if (SqlHelper.Fun_Secret(userModel.user_Password_Model) == user.user_Password)
                {
                    user.user_Password = SqlHelper.Fun_Secret(userModel.user_Password);
                    user.user_Update_Time = DateTime.Now;

                    UserService.Update(user);
                    jsonResult.result = true;
                    jsonResult.message = "";
                }
                else
                {
                    jsonResult.result = false;
                    jsonResult.message = "The Old Password is not match!";
                }
            }
            catch (Exception ex)
            {
                jsonResult.result = false;
                jsonResult.message = ex.Message;
            }
            string result = JsonConvert.SerializeObject(jsonResult);
            return Content(result);
        }
Beispiel #2
0
        public static void Delete(User model)
        {
            string sql = "select * from PSS_User where user_Id='" + model.user_Id + "'";
            DataSet ds = SqlHelper.GetDataSetBySql(sql, "PSS_User");
            DataRow dr = ds.Tables["PSS_User"].Rows[0];
            dr.Delete();

            SqlHelper.UpdateDataSet(ds, sql, "PSS_User");
            if (ds != null)
                ds.Dispose();
        }
Beispiel #3
0
        public static List<User> GetList()
        {
            List<User> list = new List<User>();
            User model = null;
            string sql = "select * from PSS_User";
            DataSet ds = SqlHelper.GetDataSetBySql(sql, "PSS_User");
            foreach(DataRow dr in ds.Tables["PSS_User"].Rows)
            {
                model = new User();

                if (!string.IsNullOrEmpty(dr["user_Id"].ToString()))
                {
                    model.user_Id = int.Parse(dr["user_Id"].ToString());
                }

                if (!string.IsNullOrEmpty(dr["user_Trimester_Id"].ToString()))
                {
                    model.user_Trimester_Id = int.Parse(dr["user_Trimester_Id"].ToString());
                }

                model.user_Name = dr["user_Name"].ToString();
                model.user_Password = dr["user_Password"].ToString();
                model.user_Email = dr["user_Email"].ToString();
                model.user_Telephone = dr["user_Telephone"].ToString();
                model.user_StudentId = dr["user_StudentId"].ToString();
                model.user_Introduction = dr["user_Introduction"].ToString();
                model.user_Statue = (bool)dr["user_Statue"];
                model.User_Email_Visiable = (bool)dr["User_Email_Visiable"];
                model.User_Telephone_Visiable = (bool)dr["User_Telephone_Visiable"];

                if (!string.IsNullOrEmpty(dr["user_Register_Time"].ToString()))
                {
                    model.user_Register_Time = DateTime.Parse(dr["user_Register_Time"].ToString());
                    model.Register_Time = model.user_Register_Time.ToString("dd/MM/yyyy HH:mm:ss");
                }
                if (!string.IsNullOrEmpty(dr["user_Log_Time"].ToString()))
                {
                    model.user_Log_Time = DateTime.Parse(dr["user_Log_Time"].ToString());
                    model.Log_Time = model.user_Log_Time.ToString("dd/MM/yyyy HH:mm:ss");
                }
                if (!string.IsNullOrEmpty(dr["user_Update_Time"].ToString()))
                {
                    model.user_Update_Time = DateTime.Parse(dr["user_Update_Time"].ToString());
                    model.Update_Time = model.user_Update_Time.ToString("dd/MM/yyyy HH:mm:ss");
                }
                list.Add(model);
            };
            return list;
        }
Beispiel #4
0
        public ContentResult UserSave(User userModel, int?id)
        {
            JsonDataGridResult jsonResult = new JsonDataGridResult();
            try
            {
                User user = null;
                if (id.HasValue)
                {
                    user = UserService.GetModel(id.Value);
                }
                else if(UserService.IsExistName(userModel.user_Name,userModel.user_Trimester_Id))
                {
                    jsonResult.result = false;
                    jsonResult.message = "There is already exist the name, please change a userName!";
                    return Content(JsonConvert.SerializeObject(jsonResult));
                }
                else
                {
                    user = new User();
                    user.user_Register_Time = DateTime.Now;
                    user.user_Log_Time = DateTime.Now;
                }

                user.user_Name = userModel.user_Name;
                user.user_Password =SqlHelper.Fun_Secret(userModel.user_Password);
                user.user_Email = userModel.user_Email;
                user.user_Telephone = userModel.user_Telephone;
                //user.user_Is_Teacher = userModel.user_Is_Teacher;
                user.user_Skill = userModel.user_Skill;
                user.user_Introduction = userModel.user_Introduction;
                user.user_Update_Time = DateTime.Now;
                user.user_Trimester_Id = userModel.user_Trimester_Id;
                user.user_Statue = true;

                if (id.HasValue)
                {
                    UserService.Update(user);
                }
                else
                {
                    UserService.Save(user);
                }
                jsonResult.result = true;
                jsonResult.message = "";
            }
            catch (Exception ex)
            {
                jsonResult.result = false;
                jsonResult.message = ex.Message;
            }
            string result = JsonConvert.SerializeObject(jsonResult);
            return Content(result);
        }
Beispiel #5
0
        public ContentResult UserPersonalProfileSave(User userModel)
        {
            JsonDataGridResult jsonResult = new JsonDataGridResult();
            try
            {
                string userName = User.Identity.Name.Split(',')[1];
                int userId = Convert.ToInt32(User.Identity.Name.Split(',')[0]);

                User user = UserService.GetModel(userId);

                user.user_Email = userModel.user_Email;
                user.user_Telephone = userModel.user_Telephone;
                user.user_Skill = userModel.user_Skill;
                user.user_Introduction = base.Server.UrlDecode(userModel.user_Introduction);
                user.user_Update_Time = DateTime.Now;
                user.user_Trimester_Id = userModel.user_Trimester_Id;
                user.User_Email_Visiable = userModel.User_Email_Visiable;
                user.User_Telephone_Visiable = userModel.User_Telephone_Visiable;

                user.user_Update_Time = DateTime.Now;

                UserService.Update(user);
                jsonResult.result = true;
                jsonResult.message = "";
            }
            catch (Exception ex)
            {
                jsonResult.result = false;
                jsonResult.message = ex.Message;
            }
            string result = JsonConvert.SerializeObject(jsonResult);
            return Content(result);
        }
Beispiel #6
0
        public static void Update(User model)
        {
            string sql = "select * from PSS_User where user_Id='" + model.user_Id + "'";
            DataSet ds = SqlHelper.GetDataSetBySql(sql, "PSS_User");
            DataRow dr = ds.Tables["PSS_User"].Rows[0];

            dr["user_Name"] = model.user_Name;
            dr["user_Password"] = model.user_Password;
            dr["user_Email"] = model.user_Email;
            dr["user_Telephone"] = model.user_Telephone;
            dr["user_Is_Teacher"] = model.user_Is_Teacher;
            dr["user_StudentId"] = model.user_StudentId;
            dr["user_Skill"] = model.user_Skill;
            dr["user_Introduction"] = model.user_Introduction;
            dr["user_Register_Time"] = model.user_Register_Time;
            dr["user_Log_Time"] = model.user_Log_Time;
            dr["user_Trimester_Id"] = model.user_Trimester_Id;
            dr["user_Statue"] = model.user_Statue;
            dr["User_Email_Visiable"] = model.User_Email_Visiable;
            dr["User_Telephone_Visiable"] = model.User_Telephone_Visiable;

            SqlHelper.UpdateDataSet(ds, sql, "PSS_User");
            if (ds != null)
                ds.Dispose();
        }
Beispiel #7
0
        public static void Save(User model)
        {
            string sql = "select * from PSS_User where 1<>1";
            DataSet ds = SqlHelper.GetDataSetBySql(sql, "PSS_User");
            DataRow dr = ds.Tables["PSS_User"].NewRow();

            int maxId = SqlHelper.GetMaxId("select max(user_Id) from PSS_User");
            dr["user_Id"] = ++maxId;
            dr["user_Name"] = model.user_Name;
            dr["user_Password"] = model.user_Password;
            dr["user_Email"] = model.user_Email;
            dr["user_Telephone"] = model.user_Telephone;
            dr["user_Is_Teacher"] = model.user_Is_Teacher;
            dr["user_StudentId"] = model.user_StudentId;
            dr["user_Skill"] = model.user_Skill;
            dr["user_Introduction"] = model.user_Introduction;
            dr["user_Register_Time"] = model.user_Register_Time;
            dr["user_Log_Time"] = model.user_Log_Time;
            dr["user_Update_Time"] = model.user_Update_Time;
            dr["user_Trimester_Id"] = model.user_Trimester_Id;
            dr["user_Statue"] = model.user_Statue;
            dr["User_Email_Visiable"] = model.User_Email_Visiable;
            dr["User_Telephone_Visiable"] = model.User_Telephone_Visiable;

            ds.Tables["PSS_User"].Rows.Add(dr);

            SqlHelper.UpdateDataSet(ds, sql, "PSS_User");
            if (ds != null)
                ds.Dispose();
        }
Beispiel #8
0
        public static User GetModel(int id)
        {
            string sql = "select * from PSS_User where user_Id='" + id + "'";
            DataSet ds = SqlHelper.GetDataSetBySql(sql, "PSS_User");
            User model = null;

            if (ds.Tables[0].Rows.Count > 0)
            {
                model = new User();
                if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_Id"].ToString()))
                {
                    model.user_Id = int.Parse(ds.Tables[0].Rows[0]["user_Id"].ToString());
                }
                if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_Trimester_Id"].ToString()))
                {
                    model.user_Trimester_Id = int.Parse(ds.Tables[0].Rows[0]["user_Trimester_Id"].ToString());
                }

                model.user_Name = ds.Tables[0].Rows[0]["user_Name"].ToString();
                model.user_Password = ds.Tables[0].Rows[0]["user_Password"].ToString();
                model.user_Email = ds.Tables[0].Rows[0]["user_Email"].ToString();
                model.user_Telephone = ds.Tables[0].Rows[0]["user_Telephone"].ToString();
                model.user_StudentId = ds.Tables[0].Rows[0]["user_StudentId"].ToString();
                model.user_Skill = ds.Tables[0].Rows[0]["user_Skill"].ToString();
                model.user_Introduction = ds.Tables[0].Rows[0]["user_Introduction"].ToString();
                model.user_Statue = (bool)ds.Tables[0].Rows[0]["user_Statue"];
                model.User_Email_Visiable = (bool)ds.Tables[0].Rows[0]["User_Email_Visiable"];
                model.User_Telephone_Visiable = (bool)ds.Tables[0].Rows[0]["User_Telephone_Visiable"];

                if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_Register_Time"].ToString()))
                {
                    model.user_Register_Time = DateTime.Parse(ds.Tables[0].Rows[0]["user_Register_Time"].ToString());
                }
                if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_Log_Time"].ToString()))
                {
                    model.user_Log_Time = DateTime.Parse(ds.Tables[0].Rows[0]["user_Log_Time"].ToString());
                }
                if (!string.IsNullOrEmpty(ds.Tables[0].Rows[0]["user_Update_Time"].ToString()))
                {
                    model.user_Update_Time = DateTime.Parse(ds.Tables[0].Rows[0]["user_Update_Time"].ToString());
                }
            }
            if (ds != null)
                ds.Dispose();
            return model;
        }
Beispiel #9
0
        public static List<User> GetList(Paging paging, string order, string sort, int trimesterId,string status, string queryWord)
        {
            List<User> list = new List<User>();
            User model = null;
            DataSet ds = SqlHelper.GetListByPage("PSS_User","user_Trimester_Id", trimesterId,status,paging, order, sort);
            foreach (DataRow dr in ds.Tables["PSS_User"].Rows)
            {
                model = new User();

                if (!string.IsNullOrEmpty(dr["user_Id"].ToString()))
                {
                    model.user_Id = int.Parse(dr["user_Id"].ToString());
                }

                model.user_Name = dr["user_Name"].ToString();
                model.user_Password = dr["user_Password"].ToString();
                model.user_Email = dr["user_Email"].ToString();
                model.user_Telephone = dr["user_Telephone"].ToString();
                model.user_StudentId = dr["user_StudentId"].ToString();
                model.user_Skill = dr["user_Skill"].ToString();
                model.user_Introduction = dr["user_Introduction"].ToString();
                model.user_Statue = (bool)dr["user_Statue"];
                model.User_Email_Visiable = (bool)dr["User_Email_Visiable"];
                model.User_Telephone_Visiable = (bool)dr["User_Telephone_Visiable"];

                if (!string.IsNullOrEmpty(dr["user_Register_Time"].ToString()))
                {
                    model.user_Register_Time = DateTime.Parse(dr["user_Register_Time"].ToString());
                    model.Register_Time = model.user_Register_Time.ToString("dd/MM/yyyy HH:mm:ss");
                }
                if (!string.IsNullOrEmpty(dr["user_Log_Time"].ToString()))
                {
                    model.user_Log_Time = DateTime.Parse(dr["user_Log_Time"].ToString());
                    model.Log_Time = model.user_Log_Time.ToString("dd/MM/yyyy HH:mm:ss");
                }
                if (!string.IsNullOrEmpty(dr["user_Update_Time"].ToString()))
                {
                    model.user_Update_Time = DateTime.Parse(dr["user_Update_Time"].ToString());
                    model.Update_Time = model.user_Update_Time.ToString("dd/MM/yyyy HH:mm:ss");
                }
                list.Add(model);
            };
            return list;
        }
Beispiel #10
0
        public ActionResult RegisterIndex(User model)
        {
            string sError = "";
            if (ModelState.IsValid)
            {
                try
                {
                    SqlHelper.Initialization();
                    List<SelectListItem> listTrimester = new List<SelectListItem>();
                    foreach (Trimester tri in TrimesterService.GetList().Where(item => item.tri_IsOpen == true))
                    {
                        listTrimester.Add(new SelectListItem { Text = tri.tri_Name, Value = tri.tri_Id.ToString() });
                    }

                    ViewData["listTrimester"] = listTrimester;
                    if (!UserService.IsExistName(model.user_Name_Model,model.user_Trimester_Id))
                    {
                        if (model.user_Password_Model == model.user_confire_Password_Model)
                        {
                            model.user_Name = model.user_Name_Model;
                            model.user_Password = SqlHelper.Fun_Secret(model.user_Password_Model);
                            model.user_Is_Teacher = false;
                            model.user_Register_Time = DateTime.Now;
                            model.user_Log_Time = DateTime.Now;
                            model.user_Update_Time = DateTime.Now;
                            UserService.Save(model);
                            //Object _n = new Object { Title = "注册成功", Details = "您已经成功注册,用户为:" + _user.UserName + " ,请牢记您的密码!", DwellTime = 5, Navigation = Url.Action("FrameIndex", "Frame") };
                            return Content("<script>alert('添加成功!');window.location=''</script>");
                            //return RedirectToAction(("FrameIndex", "Frame");
                            //return RedirectToAction("FrameIndex", "Frame");
                        }
                        else
                        {
                            sError = "The PassWord and Comfirm Password is not same!";
                        }
                    }
                    else
                    {
                        sError = "There is already exist the name, please change a userName!";
                    }
                }
                catch (Exception ex)
                {
                    sError = ex.Message;
                }
                if (!string.IsNullOrEmpty(sError))
                    ModelState.AddModelError("", sError);
            }
            SqlHelper.Dispose();
            return View(model);
        }