private void login_btn_Click(object sender, EventArgs e) { if (!ID_Box.Text.Equals("") && !PW_Box.Text.Equals("")) { string loginResult = loginReceive.loginReveiveToServer("userLogin", ID_Box.Text, PW_Box.Text); if (loginResult.Equals("true")) { loginStausLabel.Text = ""; UserInfo.userId = ID_Box.Text; UserIP = UserGetIP.GetLocalIP(); UserInfo.userIP = UserIP; contextmenustripform.IconVisiblefalse(); loginformCheck = false; Mainform mainform = new Mainform(contextmenustripform); mainform.Show(); ID_Box.Clear(); PW_Box.Clear(); ID_Box.Focus(); this.Hide(); //서버로 로그인 id에 맞는 값을 받아와야 함. } else { //MessageBox.Show("ID 혹은 PW가 일치하지 않습니다.", "로그인실패", MessageBoxButtons.OK, MessageBoxIcon.Error); loginStausLabel.Text = "ID 또는 PW가 일치하지 않습니다."; loginStausLabel.ForeColor = Color.Red; ID_Box.Clear(); //PW_Box.Clear(); PW_Box.Text = "Password"; PW_Box.ForeColor = Color.Gray; PW_Box.PasswordChar = '\0'; login_btn.BackColor = Color.White; login_btn.ForeColor = Color.Gray; login_btn.Enabled = false; ID_Box.Focus(); } } else { loginStausLabel.Text = "ID 또는 PW를 적어주세요."; loginStausLabel.ForeColor = Color.Red; ID_Box.Focus(); //MessageBox.Show("ID 혹은 PW를 적어주세요.", "로그인실패", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ID_Box_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData == Keys.Enter) { if (!PW_Box.Text.Equals("") && !(PW_Box.Text.Equals("Password") && PW_Box.ForeColor == Color.Gray)) { string loginCheck = loginReceive.loginReveiveToServer("userLogin", ID_Box.Text, PW_Box.Text); if (loginCheck.Equals("true")) { loginStausLabel.Text = ""; UserInfo.userId = ID_Box.Text; UserIP = UserGetIP.GetLocalIP(); UserInfo.userIP = UserIP; contextmenustripform.IconVisiblefalse(); loginformCheck = false; Mainform mainform = new Mainform(contextmenustripform); mainform.Show(); ID_Box.Clear(); PW_Box.Clear(); ID_Box.Focus(); this.Hide(); } else { loginStausLabel.Text = "ID 또는 PW가 일치하지 않습니다."; loginStausLabel.ForeColor = Color.Red; ID_Box.Clear(); //PW_Box.Clear(); PW_Box.Text = "Password"; PW_Box.ForeColor = Color.Gray; PW_Box.PasswordChar = '\0'; login_btn.BackColor = Color.White; login_btn.ForeColor = Color.Gray; login_btn.Enabled = false; ID_Box.Focus(); } } else { PW_Box.Focus(); } } }