예제 #1
0
파일: Manager_cwb.cs 프로젝트: bzl337/CMS
        public int UpdateUser(Userinf userinf, string currentacc)
        {
            int flag = 0;

            flag = repository.UpdateUserinfs(userinf, currentacc);
            return(flag);
        }
예제 #2
0
        public JsonResult UpdatetheUser()
        {
            int sex;

            if (Request.QueryString["Sex"] == "1")
            {
                sex = 1;
            }
            else
            {
                sex = 0;
            }
            Userinf userinf = new Userinf()
            {
                Account  = Request.QueryString["Account"],
                Password = Request.QueryString["Password"],
                Name     = Request.QueryString["Name"],
                Phone    = Request.QueryString["Phone"],
                Sex      = sex
            };
            string currentacc = Request.QueryString["current"];
            int    flag       = manager.UpdateUser(userinf, currentacc);

            userinf.flag = flag;
            return(Json(userinf, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
파일: Manager_cwb.cs 프로젝트: bzl337/CMS
        public int DeleteUser(Userinf userinf)
        {
            int flag = 0;

            flag = repository.DeleteUserinfs(userinf);
            return(flag);
        }
예제 #4
0
파일: Manager_cwb.cs 프로젝트: bzl337/CMS
        public int InsertUser(Userinf userinf)
        {
            // string a = "123";
            int flag = 0;

            flag = repository.InsertUserinfs(userinf);
            return(flag);
        }
예제 #5
0
        public Userinf SearchUserinfs(Userinf userinf)
        {
            Userinf result = new Userinf();

            result.flag = -1;
            string account      = userinf.Account;
            string queryString1 = "SELECT 账号ID,密码 FROM 账号 WHERE 权限=0";
            string queryString2 = "SELECT 账号ID,昵称,电话,性别 FROM 用户";
            int    flag         = 0;

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                using (MySqlCommand command1 = new MySqlCommand())
                {
                    command1.Connection  = connection;
                    command1.CommandText = queryString1;
                    MySqlDataReader reader = command1.ExecuteReader();
                    while (reader.Read())
                    {
                        if (account == reader["账号ID"].ToString())
                        {
                            flag            = 1;
                            result.flag     = 1;
                            result.Account  = reader["账号ID"].ToString();
                            result.Password = reader["密码"].ToString();
                            break;
                        }
                    }
                    reader.Close();
                    if (flag == 0)
                    {
                        connection.Close();
                        result.flag = 0;
                        return(result);
                    }
                }
                using (MySqlCommand command2 = new MySqlCommand())
                {
                    command2.Connection  = connection;
                    command2.CommandText = queryString2;
                    MySqlDataReader reader = command2.ExecuteReader();
                    while (reader.Read())
                    {
                        if (account == reader["账号ID"].ToString())
                        {
                            result.Name  = reader["昵称"].ToString();
                            result.Phone = reader["电话"].ToString();
                            result.Sex   = (int)reader["性别"];
                        }
                    }
                    reader.Close();
                }
                connection.Close();
            }
            return(result);
        }
예제 #6
0
        public JsonResult DeletetheUser()
        {
            Userinf userinf = new Userinf()
            {
                Account = Request.QueryString["Account"]
            };
            int flag = manager.DeleteUser(userinf);

            return(Json(flag, JsonRequestBehavior.AllowGet));
        }
예제 #7
0
        public JsonResult SearchtheUser()
        {
            Userinf userinf = new Userinf()
            {
                Account = Request.QueryString["Account"]
            };
            Userinf userinf1 = manager.SearchUser(userinf);

            return(Json(userinf1, JsonRequestBehavior.AllowGet));
        }
예제 #8
0
        public int InsertUserinfs(Userinf userinf)
        {
            string account      = userinf.Account;
            string password     = userinf.Password;
            string name         = userinf.Name;
            string phone        = userinf.Phone;
            int    sex          = userinf.Sex;
            string checkString  = "SELECT 账号ID,昵称 FROM 用户";
            string queryString1 = "INSERT INTO 账号 SET" + " 账号ID='" + account + "',密码='" + password + "',权限='0'";
            string queryString2 = "INSERT INTO 用户 SET" + " 账号ID='" + account + "',昵称='" + name + "',电话='" + phone + "',性别='" + sex + "'";

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                using (MySqlCommand command0 = new MySqlCommand())
                {
                    command0.Connection  = connection;
                    command0.CommandText = checkString;
                    MySqlDataReader reader = command0.ExecuteReader();
                    while (reader.Read())
                    {
                        if (account == reader["账号ID"].ToString() || name == reader["昵称"].ToString())
                        {
                            reader.Close();
                            connection.Close();
                            return(0);
                        }
                    }
                    reader.Close();
                }
                using (MySqlCommand command1 = new MySqlCommand())
                {
                    command1.Connection  = connection;
                    command1.CommandText = queryString1;
                    command1.ExecuteNonQuery();
                }
                using (MySqlCommand command2 = new MySqlCommand())
                {
                    command2.Connection  = connection;
                    command2.CommandText = queryString2;
                    command2.ExecuteNonQuery();
                }
                connection.Close();
            }
            return(1);
        }
예제 #9
0
        public int DeleteUserinfs(Userinf userinf)
        {
            string account      = userinf.Account;
            int    flag         = 0;
            string queryString1 = "START TRANSACTION;" +
                                  "SET foreign_key_checks = 0;" +
                                  "DELETE FROM 账号 WHERE 账号ID='" + account + "';" +
                                  "DELETE FROM 用户 WHERE 账号ID='" + account + "';" +
                                  "DELETE FROM 反馈记录 WHERE 账号ID='" + account + "';" +
                                  "DELETE FROM 回复内容 WHERE 反馈账号ID='" + account + "';" +
                                  "DELETE FROM 评分记录 WHERE 账号ID='" + account + "';" +
                                  "DELETE FROM 收藏记录 WHERE 账号ID='" + account + "';" +
                                  "DELETE FROM 影票 WHERE 拥有者账号ID='" + account + "';" +
                                  "SET foreign_key_checks = 1;COMMIT;";

            //string queryString2 = "DELETE FROM 账号 WHERE 账号ID='" + account + "'";
            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                using (MySqlCommand command1 = new MySqlCommand())
                {
                    command1.Connection  = connection;
                    command1.CommandText = queryString1;
                    command1.ExecuteNonQuery();
                    flag += 2;
                }

                /*using(MySqlCommand command2=new MySqlCommand())
                 * {
                 *  command2.Connection = connection;
                 *  command2.CommandText = queryString2;
                 *  command2.ExecuteNonQuery();
                 *  flag += 1;
                 * }*/
                connection.Close();
            }
            return(flag);
        }
예제 #10
0
 public JsonResult SendNewUser()
 {
     if (Request.QueryString["Account"] != null)
     {
         int sex;
         if (Request.QueryString["Sex"] == "1")
         {
             sex = 1;
         }
         else
         {
             sex = 0;
         }
         Userinf userinf = new Userinf()
         {
             Account  = Request.QueryString["Account"],
             Password = Request.QueryString["Password"],
             Name     = Request.QueryString["Name"],
             Phone    = Request.QueryString["Phone"],
             Sex      = sex
         };
         int flag;
         flag = manager.InsertUser(userinf);
         if (flag == 1)
         {
             userinf.flag = 1;
         }
         else
         {
             userinf.flag = 0;
         }
         return(Json(userinf, JsonRequestBehavior.AllowGet));
     }
     else
     {
         return(Json(false, JsonRequestBehavior.AllowGet));
     }
 }
예제 #11
0
        public int UpdateUserinfs(Userinf userinf, string currentacc)
        {
            int    flag     = 1;
            string account  = userinf.Account;
            string password = userinf.Password;
            string name     = userinf.Name;
            string phone    = userinf.Phone;
            int    sex      = userinf.Sex;

            using (MySqlConnection connection = new MySqlConnection(connectionString))
            {
                connection.Open();
                if (account != currentacc)
                {
                    string checkString1 = "SELECT 账号ID,昵称 FROM 用户 WHERE 账号ID!='" + currentacc + "'";
                    string queryString1 = "START TRANSACTION;" +
                                          "SET foreign_key_checks = 0;" +
                                          "UPDATE 用户 SET 账号ID='" + account + "' WHERE 账号ID='" + currentacc + "';" +
                                          "UPDATE 账号 SET 账号ID='" + account + "' WHERE 账号ID='" + currentacc + "';" +
                                          "UPDATE 反馈记录 SET 账号ID='" + account + "' WHERE 账号ID='" + currentacc + "';" +
                                          "UPDATE 回复内容 SET 反馈账号ID='" + account + "' WHERE 反馈账号ID='" + currentacc + "';" +
                                          "UPDATE 评分记录 SET 账号ID='" + account + "' WHERE 账号ID='" + currentacc + "';" +
                                          "UPDATE 收藏记录 SET 账号ID='" + account + "' WHERE 账号ID='" + currentacc + "';" +
                                          "UPDATE 影票 SET 拥有者账号ID='" + account + "' WHERE 拥有者账号ID='" + currentacc + "';" +
                                          "SET foreign_key_checks = 1;COMMIT;";
                    using (MySqlCommand check1 = new MySqlCommand())
                    {
                        check1.Connection  = connection;
                        check1.CommandText = checkString1;
                        MySqlDataReader reader = check1.ExecuteReader();
                        while (reader.Read())
                        {
                            if (account == reader["账号ID"].ToString() || name == reader["昵称"].ToString())
                            {
                                reader.Close();
                                connection.Close();
                                flag = 2; //flag=2 账号id或昵称重复
                                return(flag);
                            }
                        }
                        reader.Close();
                    }

                    using (MySqlCommand command1 = new MySqlCommand())
                    {
                        command1.Connection  = connection;
                        command1.CommandText = queryString1;
                        command1.ExecuteNonQuery();
                    }
                }
                else
                {
                    string checkString2 = "SELECT 昵称 FROM 用户 WHERE 账号ID!='" + currentacc + "'";
                    using (MySqlCommand check2 = new MySqlCommand())
                    {
                        check2.Connection  = connection;
                        check2.CommandText = checkString2;
                        MySqlDataReader reader = check2.ExecuteReader();
                        while (reader.Read())
                        {
                            if (name == reader["昵称"].ToString())
                            {
                                reader.Close();
                                connection.Close();
                                flag = 3; //昵称重复
                                return(flag);
                            }
                        }
                        reader.Close();
                    }
                }
                string queryString2 = "UPDATE 账号 SET 密码='" + password + "' WHERE 账号ID='" + account + "';" +
                                      "UPDATE 用户 SET 昵称='" + name + "',电话='" + phone + "',性别='" + sex + "' WHERE 账号ID='" + account + "';";
                using (MySqlCommand command2 = new MySqlCommand())
                {
                    command2.Connection  = connection;
                    command2.CommandText = queryString2;
                    command2.ExecuteNonQuery();
                }
                connection.Close();
            }
            return(flag);
        }
예제 #12
0
파일: Manager_cwb.cs 프로젝트: bzl337/CMS
 public Userinf SearchUser(Userinf userinf)
 {
     userinf = repository.SearchUserinfs(userinf);
     return(userinf);
 }