private void loginbtn_Click(object sender, EventArgs e) { if (!IDBox.Text.Equals("") && !PWBox.Text.Equals("")) { string loginResult = loginReceive.loginReveiveToServer("userLogin", IDBox.Text, PWBox.Text); if (loginResult.Equals("true")) { if (enterRoomCheck.enterRoomformCheck == true) { contextMenuStripForm.LockIconVisiblefalse(); sbloginformCheck = false; mainform.Show(); enterRoomcheck.Show(); enterRoomcheck.Focus(); enterRoomCheck.enterRoomformCheck = true; contextMenuStripForm.IconVisibletrue(); PWBox.Clear(); this.Dispose(); } else if (Chat_Form.ChatFormCheck == true) { contextMenuStripForm.LockIconVisiblefalse(); chatform.Show(); chatform.Focus(); sbloginformCheck = false; Chat_Form.ChatFormCheck = true; contextMenuStripForm.IconVisibletrue(); PWBox.Clear(); this.Dispose(); } else if (CreateRoom_Form.createRoomCheck == true) { contextMenuStripForm.LockIconVisiblefalse(); mainform.Show(); createroom.Show(); createroom.Focus(); sbloginformCheck = false; CreateRoom_Form.createRoomCheck = true; contextMenuStripForm.IconVisibletrue(); PWBox.Clear(); this.Dispose(); } else if (UserList_Form.userlistformCheck == true) { contextMenuStripForm.LockIconVisiblefalse(); mainform.Show(); createroom.Show(); userlistform.Show(); userlistform.Focus(); sbloginformCheck = false; UserList_Form.userlistformCheck = true; contextMenuStripForm.IconVisibletrue(); PWBox.Clear(); this.Dispose(); } else { contextMenuStripForm.LockIconVisiblefalse(); mainform.Show(); mainform.Focus(); sbloginformCheck = false; Mainform.mainformCheck = true; contextMenuStripForm.IconVisibletrue(); PWBox.Clear(); this.Dispose(); } //서버로 로그인 id에 맞는 값을 받아와야 함. } else { //MessageBox.Show("비밀번호가 일치하지 않습니다.", "로그인실패", MessageBoxButtons.OK, MessageBoxIcon.Error); sbLoginStatus.Text = "비밀번호가 일치하지 않습니다."; sbLoginStatus.ForeColor = Color.Red; PWBox.Clear(); } } else { sbLoginStatus.Text = "비밀번호를 적어주세요."; sbLoginStatus.ForeColor = Color.Red; //MessageBox.Show("비밀번호를 적어주세요.", "로그인실패", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Create_btn_Click(object sender, EventArgs e) { int userCount = 0; if (!Room_ID.Text.Equals("") && !Room_PW.Text.Equals("")) { try { string result = ""; string Check_resultPostRoomID = userlistreceive.userListReceivetoServer("roomListCheck", Room_ID.Text); if (Check_resultPostRoomID.Equals("false")) { /////////////////////////////////////////////////////////////////////////////////////// byte[] _key = Key.make_key(Room_ID.Text); String AESPW = Convert.ToBase64String(Key.DataToAes(Encoding.UTF8.GetBytes(Room_PW.Text), _key)); //////////////////////////////////////////////////////////////////////////////////////////// string resultPostCreate = userlistreceive.createRoomReceivetoServer("createRoom", Room_ID.Text, AESPW, UserInfo.userId); if (resultPostCreate.Equals("1")) //!!!!!!!!!!!!중복이 안되면 방생성 되게하게 { MessageBox.Show("방생성이 완료되었습니다.", "성공", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); userCount = listBox.Items.Count; listBox.Items.Add(UserInfo.userId.ToString()); string url = UserInfo.serverUrl + "approvalUserRoom"; JsonObjectCollection jsonObjectCollectionData = new JsonObjectCollection(); jsonObjectCollectionData.Add(new JsonStringValue("roomID", Room_ID.Text)); JsonArrayCollection jsonArrayCollection = new JsonArrayCollection(); for (int i = 0; i < listBox.Items.Count; i++) { jsonArrayCollection.Add(new JsonStringValue(null, listBox.Items[i].ToString())); } //jsonArrayCollection.Add(new JsonStringValue(null, UserInfo.userId.ToString())); jsonObjectCollectionData.Add(new JsonArrayCollection("approvalUser", jsonArrayCollection)); jsonObjectCollectionData.Add(new JsonStringValue("count", (listBox.Items.Count).ToString())); listBox.Items.Remove(UserInfo.userId); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); HttpWebResponse response; byte[] aaa = Encoding.UTF8.GetBytes(jsonObjectCollectionData.ToString()); request.Method = "POST"; request.ContentType = "application/json"; request.ContentLength = aaa.Length; request.Timeout = 5000; Stream dataStream = request.GetRequestStream(); dataStream.Write(aaa, 0, aaa.Length); dataStream.Close(); response = (HttpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8); result = streamReader.ReadToEnd(); //result가 1이면 가입 성공!!! streamReader.Close(); responseStream.Close(); response.Close(); JArray obj = JArray.Parse(result); List <String> address = new List <String>(); List <String> id = new List <String>(); foreach (JObject itemObj in obj) { id.Add(itemObj["name"].ToString()); address.Add(itemObj["email"].ToString()); } MailSystem.SendMail(Room_ID.Text, id, address); afterCrateRoom.Enabled = true; afterCrateRoom.public_reset(sender, e); afterCrateRoom.Focus(); this.Dispose(); //리스트뷰에 } else { MessageBox.Show("ㄴㄴ방생성안됨.", "에러", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("방 제목 중복입니다.", "에러", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show("에러메세지", "에러", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("방 제목과 비밀번호를 써주세요.", "방 생성 불가", MessageBoxButtons.OK, MessageBoxIcon.Error); } }