Example #1
0
        public static void Users_Delete(ref DB_USERS Users) // Model Delete 메소드
        {
            conn.Open();
            string       Users_Delete_Sql     = "delete from users where user_id = '" + Users.User_Id + "';";
            MySqlCommand Command_Users_Delete = new MySqlCommand(Users_Delete_Sql, conn);

            Command_Users_Delete.ExecuteNonQuery();
            conn.Close();
        }
Example #2
0
        ///
        public static void Users_Insert(ref DB_USERS Users)                                                                                                                                                                     // Model Insert 메소드
        {
            conn.Open();                                                                                                                                                                                                        // Mysql Open
            string       Users_Insert_Sql     = "INSERT INTO users VALUES('" + Users.User_Id + "','" + Users.Pass_Word + "'," + Users.Level + ",'" + Users.E_Mail + "','" + Users.First_Name + "','" + Users.Last_Name + "');"; // Insert 쿼리문
            MySqlCommand Command_Users_Insert = new MySqlCommand(Users_Insert_Sql, conn);                                                                                                                                       // Insert Command문

            Command_Users_Insert.ExecuteNonQuery();                                                                                                                                                                             // Insert 실행
            conn.Close();                                                                                                                                                                                                       // mysql Close
        }
Example #3
0
        public static void Users_Update(ref DB_USERS Users) // Model Update 메소드
        {
            conn.Open();
            string Users_Update_Sql = "update users set pass_word = '" + Users.Pass_Word + "', Level = "
                                      + Users.Level + ", e_mail = '" + Users.E_Mail + "', first_name = '" + Users.First_Name + "', last_name = '" + Users.Last_Name + "' where user_id = '" + Users.User_Id + "';"; // update sql문을 담을 string 변수
            MySqlCommand Command_Users_Update = new MySqlCommand(Users_Update_Sql, conn);

            Command_Users_Update.ExecuteNonQuery();
            conn.Close();
        }
Example #4
0
        } // user 전체 삭제

        public void Proc_req_user_delete(string[] receive_data_division, ref NetworkStream stream)
        {
            DB_USERS use = new DB_USERS(receive_data_division[2], receive_data_division[3], receive_data_division[4], receive_data_division[5], receive_data_division[6], receive_data_division[7]);

            DB_MGR.Users_Delete(ref use);

            string send_data = "유저 부분삭제";

            byte[] Response_Data = Encoding.Default.GetBytes(send_data);
            stream.Write(Response_Data, 0, Response_Data.Length);
        } // user 선택 삭제
Example #5
0
        } // user 선택 검색

        public void Proc_req_user_create(string[] receive_data_division, ref NetworkStream stream)
        {
            DB_USERS User = new DB_USERS(receive_data_division[2], receive_data_division[3], receive_data_division[4], receive_data_division[5], receive_data_division[6], receive_data_division[7]);

            DB_MGR.Users_Insert(ref User);

            string send_data = "유저생성 완료";

            byte[] Response_Data = Encoding.Default.GetBytes(send_data);
            stream.Write(Response_Data, 0, Response_Data.Length);
        } // user 생성
Example #6
0
        public static void Users_Select(ref List <DB_USERS> Users)
        {
            conn.Open();
            string          Users_Select_Sql     = "SELECT * FROM users;";               //본인의 DB이름
            MySqlCommand    Command_Users_Select = new MySqlCommand(Users_Select_Sql, conn);
            MySqlDataReader Reader_Users_Select  = Command_Users_Select.ExecuteReader(); // Sql문 Reader하는 Class

            while (Reader_Users_Select.Read())                                           // TBL_MODEL의 컬럼 내용 모두 읽을 때 까지 반복
            {
                DB_USERS users = new DB_USERS();

                users.User_Id    = Reader_Users_Select["user_id"].ToString();
                users.Pass_Word  = Reader_Users_Select["pass_word"].ToString();
                users.Level      = Reader_Users_Select["level"].ToString();
                users.E_Mail     = Reader_Users_Select["e_mail"].ToString();
                users.First_Name = Reader_Users_Select["first_name"].ToString();
                users.Last_Name  = Reader_Users_Select["last_name"].ToString();

                Users.Add(users); // 모든 정보 ArrayList 담기
            }
            conn.Close();
        }
Example #7
0
        public void Server_Open()
        {
            server.Start();
            fm.textBox1.Text = "Aria Project Server Open";

            while (true)
            {
                TcpClient client = server.AcceptTcpClient();

                ((IPEndPoint)client.Client.RemoteEndPoint).ToString();

                NetworkStream stream = client.GetStream();

                int    length;
                string receive_data = null; // 클라이언트로부터 수신되는 값이 저장 될 변수
                string send_data    = null; // 클라이언트에게 송신할 값이 저장 될 변수
                byte[] bytes        = new byte[256];
                length = stream.Read(bytes, 0, bytes.Length);

                receive_data     = Encoding.Default.GetString(bytes, 0, length);// 데이터 수신
                fm.textBox2.Text = fm.textBox2.Text + receive_data;

                string[] receive_data_division = receive_data.Split(new char[] { ',' });

                if (receive_data_division[0] == "{{$00")
                {
                    if (receive_data_division[1] == "req_user_log_in") // user_login 프로토콜
                    {
                        List <DB_USERS> List_Users = new List <DB_USERS>();
                        DB_MGR.Users_Select(ref List_Users);

                        for (int i = 0; i < List_Users.Count; i++)
                        {
                            if (receive_data_division[2] == List_Users[i].User_Id && receive_data_division[3] == List_Users[i].Pass_Word) // 아이디 비밀번호 일치 판단문
                            {
                                Req_User_Log_In.result = "OK";

                                Req_User_Log_In.level = List_Users[i].Level;
                                if (Req_User_Log_In.level == "1")
                                {
                                    Req_User_Log_In.right = "OPER";
                                }
                                else if (Req_User_Log_In.level == "2")
                                {
                                    Req_User_Log_In.right = "ADMIN";
                                }
                                break;
                            }
                            else
                            {
                                Req_User_Log_In.result = "NG";
                            }
                        }
                        if (Req_User_Log_In.result == "NG")
                        {
                            Req_User_Log_In.nak_reason = "오류남";
                        }
                        send_data = "{{$00,login_req_ack," + Req_User_Log_In.result + "," + Req_User_Log_In.right + "," + Req_User_Log_In.nak_reason + ",#}}";
                        byte[] Response_Data = Encoding.Default.GetBytes(send_data);
                        stream.Write(Response_Data, 0, Response_Data.Length);
                        fm.textBox3.Text = send_data + Req_User_Log_In.level;
                    }
                }
                else if (receive_data_division[0] == "{{$01")
                {
                    if (receive_data_division[1] == "req_new_user_create")
                    {
                        DB_USERS User = new DB_USERS(receive_data_division[2], receive_data_division[3], receive_data_division[4], receive_data_division[5], receive_data_division[6], receive_data_division[7]);
                        DB_MGR.Users_Insert(ref User);

                        send_data = "{{$01,req_new_user_create_ack,result,ng_reasondddddddddddddddddddddddd$}}";
                        byte[] Response_Data = Encoding.Default.GetBytes(send_data);
                        stream.Write(Response_Data, 0, Response_Data.Length);
                        fm.textBox3.Text = send_data + Req_User_Log_In.level;
                    }
                    else if (receive_data_division[1] == "req_user_delete")
                    {
                        DB_USERS User2 = new DB_USERS();
                        User2.User_Id = receive_data_division[2];
                        DB_MGR.Users_Delete(ref User2);

                        send_data = "{{$01,req_user_delete,딜리트했슴요,ng_reason,$}}";
                        byte[] Response_Data = Encoding.Default.GetBytes(send_data);
                        stream.Write(Response_Data, 0, Response_Data.Length);
                        fm.textBox3.Text = send_data + Req_User_Log_In.level;
                    }
                    else if (receive_data_division[1] == "req_user_update")
                    {
                        //DB_MGR.Users_Update(ref User);

                        send_data = "{{$01,req_user_update,result,ng_reason$}}";
                    }
                    else if (receive_data_division[1] == "req_user_select")
                    {
                        List <DB_USERS> User = new List <DB_USERS>();
                        DB_MGR.Users_Select(ref User);
                        int a = 0;
                        foreach (DB_USERS ee in User)
                        {
                            send_data = send_data + ee.User_Id + "\n";
                            a++;
                        }

                        byte[] Response_Data = Encoding.Default.GetBytes(send_data);
                        stream.Write(Response_Data, 0, Response_Data.Length);
                        fm.textBox3.Text = send_data + Req_User_Log_In.level;
                    }
                }
            }
        }