private void OK_Click(object sender, EventArgs e) { try { OleDbConnection myConnection = default(OleDbConnection); myConnection = new OleDbConnection(lblpath.Text); OleDbCommand myCommand = default(OleDbCommand); myCommand = new OleDbCommand("SELECT USERNAME,PASSWORD FROM LOGIN WHERE USERNAME = @username AND PASSWORD = @UserPassword", myConnection); OleDbParameter uName = new OleDbParameter("@username", OleDbType.VarChar); OleDbParameter uPassword = new OleDbParameter("@UserPassword", OleDbType.VarChar); uName.Value = UserID.Text; uPassword.Value = Password.Text; myCommand.Parameters.Add(uName); myCommand.Parameters.Add(uPassword); myCommand.Connection.Open(); OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); if (myReader.Read() == true) { this.Hide(); MAINFORM frm = new MAINFORM(); frm.lblcompanypath.Text = lblpath.Text; frm.lblcompanyname.Text = lblcompanyname.Text; frm.Show(); this.Hide(); Check_Expiry(); } else { MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Clear(); Password.Clear(); UserID.Focus(); } if (myConnection.State == ConnectionState.Open) { myConnection.Dispose(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnOK_Click(object sender, EventArgs e) { if (UserID.Text == "") { MessageBox.Show("Please enter user ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Focus(); return; } if (Password.Text == "") { MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Password.Focus(); return; } }
//사용자로부터 입력받는 ID,PW칸이 비어있는지 확인 private bool ControlCheck() { if (String.IsNullOrEmpty(UserID.Text)) { MessageBox.Show("Please enter your ID and password.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); UserID.Focus(); return(false); } else if (String.IsNullOrEmpty(UserPW.Text)) { MessageBox.Show("Please enter your username and password.", "Notice", MessageBoxButtons.OK, MessageBoxIcon.Warning); UserPW.Focus(); return(false); } return(true); }
private void toggleSSO(bool useIt) { PasswordLabel.Visibility = Password.Visibility = useIt? Visibility.Hidden : Visibility.Visible; if (useIt) { UserID.Text = ssoID; } else if (UserID.Text == ssoID) { UserID.Text = ""; UserID.Focus(); } else { Password.Focus(); } }
private void User_Login_Click(object sender, EventArgs e) { if (eunSock.Connected) { MessageBox.Show("이미 연결되어 있습니다..", "확인", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ID = UserID.Text.Trim(); //ID, Trim은 공백제거 PW = UserPw.Text.Trim(); int port = 15000; //포트 고정 if (string.IsNullOrEmpty(ID)) { MessageBox.Show("입력(ID)이 안된 부분이 있습니다.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Information); UserID.Focus(); return; } else if (string.IsNullOrEmpty(PW)) { MessageBox.Show("입력(PW)이 안된 부분이 있습니다.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } //서버에 연결 try { eunSock.Connect(eunAddress, port); } catch (Exception) { eunSock.Close(); MessageBox.Show("연결에 실패했습니다.", "확인", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } SendID(); //서버로 ID, password 묶어서 전송 // 연결 완료, 서버에서 데이터가 올 수 있으므로 수신 대기한다. AsyncObject obj = new AsyncObject(4096); obj.WorkingSocket = eunSock; eunSock.BeginReceive(obj.Buffer, 0, obj.BufferSize, 0, DataReceived, obj); }
private void LoginB_Click(object sender, EventArgs e) { if ((UserID.Text == "Admin" && Password.Text == "Admin@23") || (UserID.Text == "User1" && Password.Text == "User1@23") || (UserID.Text == "User2" && Password.Text == "User2@23") || (UserID.Text == username && Password.Text == password)) { MessageBox.Show("Successfully Logged In"); Form1 form = new Form1(UserID.Text, this); this.Hide(); form.Show(); UserID.Text = ""; Password.Text = ""; } else { MessageBox.Show("Invalid Credentials"); UserID.Text = ""; Password.Text = ""; UserID.Focus(); } }
private void btnCheckAvailability_Click(object sender, EventArgs e) { try { if (UserID.Text == "") { MessageBox.Show("Please enter username", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Focus(); return; } con = new SqlConnection(cs.DBcon); con.Open(); string ct = "select username from user_registration where userID=@find"; cmd = new SqlCommand(ct); cmd.Connection = con; cmd.Parameters.Add(new SqlParameter("@find", System.Data.SqlDbType.NChar, 150, "userid")); cmd.Parameters["@find"].Value = UserID.Text; rdr = cmd.ExecuteReader(); if (rdr.Read()) { MessageBox.Show("UserID not available", "", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (!rdr.Read()) { MessageBox.Show("UserID available", "", MessageBoxButtons.OK, MessageBoxIcon.Information); UserID.Focus(); } if ((rdr != null)) { rdr.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnOK_Click(object sender, EventArgs e) { if (cmbUsertype.Text == "") { MessageBox.Show("Please select user type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cmbUsertype.Focus(); return; } if (UserID.Text == "") { MessageBox.Show("Please enter user ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Focus(); return; } if (Password.Text == "") { MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Password.Focus(); return; } try { con = new SqlConnection(cs.DBcon); con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(Password) FROM User_Registration where UserID = @d1 and Password=@d2"; cmd.Parameters.AddWithValue("@d1", UserID.Text); cmd.Parameters.AddWithValue("@d2", Password.Text); rdr = cmd.ExecuteReader(); if (rdr.Read()) { con = new SqlConnection(cs.DBcon); con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "SELECT usertype FROM User_Registration where UserID=@d3 and Password=@d4"; cmd.Parameters.AddWithValue("@d3", UserID.Text); cmd.Parameters.AddWithValue("@d4", Password.Text); rdr = cmd.ExecuteReader(); if (rdr.Read()) { cmbUsertype.Text = rdr.GetValue(0).ToString().Trim(); } if ((rdr != null)) { rdr.Close(); } if (con.State == ConnectionState.Open) { con.Close(); } if (cmbUsertype.Text == "Librarian") { this.Hide(); Librarian_Window frm = new Librarian_Window(); frm.User.Text = UserID.Text; frm.UserType.Text = cmbUsertype.Text; frm.Show(); ProgressBar1.Visible = true; ProgressBar1.Maximum = 5000; ProgressBar1.Minimum = 0; ProgressBar1.Value = 4; ProgressBar1.Step = 1; for (int i = 0; i <= 5000; i++) { ProgressBar1.PerformStep(); } } if (cmbUsertype.Text == "Account Officer") { this.Hide(); Account_Officer_Window frm = new Account_Officer_Window(); frm.User.Text = UserID.Text; frm.UserType.Text = cmbUsertype.Text; frm.Show(); ProgressBar1.Visible = true; ProgressBar1.Maximum = 5000; ProgressBar1.Minimum = 0; ProgressBar1.Value = 4; ProgressBar1.Step = 1; for (int i = 0; i <= 5000; i++) { ProgressBar1.PerformStep(); } /*st1 = UserID.Text; * st2 = "Successfully logged in"; * cf.LogFunc(st1, System.DateTime.Now, st2); * this.Hide(); * frm.Show();*/ } if (cmbUsertype.Text == "Admin") { this.Hide(); frm_Main_Menu frm = new frm_Main_Menu(); //frm.User.Text = txtUserName.Text; frm.User.Text = UserID.Text; frm.UserType.Text = cmbUsertype.Text; frm.Show(); // frm.registrationToolStripMenuItem2.Enabled = true; frm.studentDetailsToolStripMenuItem.Enabled = true; frm.hostelersToolStripMenuItem.Enabled = true; frm.busHoldersToolStripMenuItem.Enabled = true; frm.Master_entryMenu.Enabled = true; frm.usersToolStripMenuItem.Enabled = true; frm.studentToolStripMenuItem.Enabled = true; frm.employeeToolStripMenuItem.Enabled = true; frm.transactionToolStripMenuItem.Enabled = true; frm.searchToolStripMenuItem.Enabled = true; frm.reportToolStripMenuItem.Enabled = true; frm.busFeePaymentToolStripMenuItem2.Enabled = true; frm.feePaymentToolStripMenuItem.Enabled = true; frm.employeeSalaryToolStripMenuItem.Enabled = true; frm.hostelFeesPaymentToolStripMenuItem.Enabled = true; frm.scholarshipPaymentToolStripMenuItem.Enabled = true; ProgressBar1.Visible = true; ProgressBar1.Maximum = 5000; ProgressBar1.Minimum = 0; ProgressBar1.Value = 4; ProgressBar1.Step = 1; for (int i = 0; i <= 5000; i++) { ProgressBar1.PerformStep(); } st1 = UserID.Text; st2 = "Successfully logged in"; cf.LogFunc(st1, System.DateTime.Now, st2); this.Hide(); frm.Show(); } } else { MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Clear(); Password.Clear(); UserID.Focus(); } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ResestB_Click(object sender, EventArgs e) { UserID.Text = ""; Password.Text = ""; UserID.Focus(); }
public Login() { InitializeComponent(); LoginP.BringToFront(); UserID.Focus(); }
private void btnOK_Click(object sender, EventArgs e) { if (UserID.Text == "") { MessageBox.Show("Please enter user id", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); UserID.Focus(); return; } if (Password.Text == "") { MessageBox.Show("Please enter password", "", MessageBoxButtons.OK, MessageBoxIcon.Warning); Password.Focus(); return; } try { cc.con = new SqlConnection(cs.DBConn); cc.con.Open(); cc.cmd = cc.con.CreateCommand(); cc.cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(Password) FROM Registration where UserID = @d1 and Password=@d2"; cc.cmd.Parameters.AddWithValue("@d1", UserID.Text); cc.cmd.Parameters.AddWithValue("@d2", Password.Text); cc.rdr = cc.cmd.ExecuteReader(); if (cc.rdr.Read()) { cc.con = new SqlConnection(cs.DBConn); cc.con.Open(); cc.cmd = cc.con.CreateCommand(); cc.cmd.CommandText = "SELECT usertype FROM Registration where UserID=@d3 and Password=@d4"; cc.cmd.Parameters.AddWithValue("@d3", UserID.Text); cc.cmd.Parameters.AddWithValue("@d4", Password.Text); cc.rdr = cc.cmd.ExecuteReader(); if (cc.rdr.Read()) { UserType.Text = cc.rdr.GetValue(0).ToString().Trim(); } if ((cc.rdr != null)) { cc.rdr.Close(); } if (cc.con.State == ConnectionState.Open) { cc.con.Close(); } if ((UserType.Text == "Admin")) { frm.masterEntryToolStripMenuItem.Enabled = true; frm.usersToolStripMenuItem.Enabled = true; frm.databaseToolStripMenuItem.Enabled = true; frm.lblUser.Text = UserID.Text; frm.lblUserType.Text = UserType.Text; ProgressBar1.Visible = true; ProgressBar1.Maximum = 5000; ProgressBar1.Minimum = 0; ProgressBar1.Value = 4; ProgressBar1.Step = 1; for (int i = 0; i <= 5000; i++) { ProgressBar1.PerformStep(); } st1 = UserID.Text; st2 = "Successfully logged in"; cf.LogFunc(st1, System.DateTime.Now, st2); this.Hide(); frm.Show(); } if ((UserType.Text == "Operator")) { frm.masterEntryToolStripMenuItem.Enabled = false; frm.usersToolStripMenuItem.Enabled = false; frm.databaseToolStripMenuItem.Enabled = false; frm.lblUser.Text = UserID.Text; frm.lblUserType.Text = UserType.Text; ProgressBar1.Visible = true; ProgressBar1.Maximum = 5000; ProgressBar1.Minimum = 0; ProgressBar1.Value = 4; ProgressBar1.Step = 1; for (int i = 0; i <= 5000; i++) { ProgressBar1.PerformStep(); } st1 = UserID.Text; st2 = "Successfully logged in"; cf.LogFunc(st1, System.DateTime.Now, st2); this.Hide(); frm.Show(); } } else { MessageBox.Show("Login is Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Text = ""; Password.Text = ""; UserID.Focus(); } cc.cmd.Dispose(); cc.con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnRegister_Click(object sender, EventArgs e) { if (UserID.Text == "") { MessageBox.Show("Please enter userID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Focus(); return; } if (cmbUsertype.Text == "") { MessageBox.Show("Please select user type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Focus(); return; } if (txtPassword.Text == "") { MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtPassword.Focus(); return; } if (txtUserName.Text == "") { MessageBox.Show("Please enter name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtUserName.Focus(); return; } if (txtContact_no.Text == "") { MessageBox.Show("Please enter contact no.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtContact_no.Focus(); return; } if (txtEmail_Address.Text == "") { MessageBox.Show("Please enter email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail_Address.Focus(); return; } try { con = new SqlConnection(cs.DBcon); con.Open(); string ct = "select userID from user_registration where userID=@find"; cmd = new SqlCommand(ct); cmd.Connection = con; cmd.Parameters.Add(new SqlParameter("@find", System.Data.SqlDbType.NChar, 150, "userID")); cmd.Parameters["@find"].Value = UserID.Text; rdr = cmd.ExecuteReader(); if (rdr.Read()) { MessageBox.Show("UserID Already Exists", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Text = ""; UserID.Focus(); if ((rdr != null)) { rdr.Close(); } return; } con = new SqlConnection(cs.DBcon); con.Open(); string cb = "insert into user_registration(UserID,password,contact_no,email,name,date_of_joining,usertype,ID) VALUES (@d1,@d2,@d3,@d4,@d5,@d6,@d7,@d9)"; cmd = new SqlCommand(cb); cmd.Connection = con; cmd.Parameters.AddWithValue("@d1", UserID.Text); cmd.Parameters.AddWithValue("@d9", txtID.Text); cmd.Parameters.AddWithValue("@d7", cmbUsertype.Text); cmd.Parameters.AddWithValue("@d2", txtPassword.Text); cmd.Parameters.AddWithValue("@d5", txtUserName.Text); cmd.Parameters.AddWithValue("@d3", txtContact_no.Text); cmd.Parameters.AddWithValue("@d4", txtEmail_Address.Text); cmd.Parameters.AddWithValue("@d6", System.DateTime.Now); cmd.ExecuteReader(); con.Close(); btnRegister.Enabled = false; MessageBox.Show("Successfully Registered", "User", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_ok_Click(object sender, EventArgs e) { if (UserID.Text == "") { MessageBox.Show("Please enter user ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Focus(); return; } if (Password.Text == "") { MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Password.Focus(); return; } try { SQLConn.ConnOpen(); SQLConn.cmd = SQLConn.conn.CreateCommand(); SQLConn.cmd.CommandText = "SELECT userid,password,name, usertype FROM user_registration where userid = @d1 and password=@d2"; SQLConn.cmd.Parameters.AddWithValue("@d1", UserID.Text); SQLConn.cmd.Parameters.AddWithValue("@d2", Password.Text); SQLConn.dr = SQLConn.cmd.ExecuteReader(); if (SQLConn.dr.Read()) { SQLConn.USERNAME = SQLConn.dr["name"].ToString(); SQLConn.USERID = SQLConn.dr["userid"].ToString(); SQLConn.USERTYPE = SQLConn.dr["usertype"].ToString(); if ((SQLConn.dr != null)) { SQLConn.dr.Close(); } SQLConn.ConnClose(); switch (SQLConn.USERTYPE) { case "Librarian": Librarian_Window frm = new Librarian_Window(); frm.UserType.Text = SQLConn.USERTYPE; frm.Show(); // } // if (cmbUsertype.Text == "Account Officer") // { // this.Hide(); // Account_Officer_Window frm = new Account_Officer_Window(); // frm.User.Text = UserID.Text; // frm.UserType.Text = cmbUsertype.Text; // frm.Show(); // ProgressBar1.Visible = true; // ProgressBar1.Maximum = 5000; // ProgressBar1.Minimum = 0; // ProgressBar1.Value = 4; // ProgressBar1.Step = 1; // for (int i = 0; i <= 5000; i++) // { // ProgressBar1.PerformStep(); // } // /*st1 = UserID.Text; // st2 = "Successfully logged in"; // cf.LogFunc(st1, System.DateTime.Now, st2); // this.Hide(); // frm.Show();*/ // } break; case "Admin": this.Hide(); frmMain frmadmin = new frmMain(); frmadmin.Show(); //// //frm.User.Text = txtUserName.Text; //// frm.User.Text = UserID.Text; //// frm.UserType.Text = cmbUsertype.Text; //// frm.Show(); //// // frm.registrationToolStripMenuItem2.Enabled = true; //// frm.studentDetailsToolStripMenuItem.Enabled = true; //// frm.hostelersToolStripMenuItem.Enabled = true; //// frm.busHoldersToolStripMenuItem.Enabled = true; //// frm.Master_entryMenu.Enabled = true; //// frm.usersToolStripMenuItem.Enabled = true; //// frm.studentToolStripMenuItem.Enabled = true; //// frm.employeeToolStripMenuItem.Enabled = true; //// frm.transactionToolStripMenuItem.Enabled = true; //// frm.searchToolStripMenuItem.Enabled = true; //// frm.reportToolStripMenuItem.Enabled = true; //// frm.busFeePaymentToolStripMenuItem2.Enabled = true; //// frm.feePaymentToolStripMenuItem.Enabled = true; //// frm.employeeSalaryToolStripMenuItem.Enabled = true; //// frm.hostelFeesPaymentToolStripMenuItem.Enabled = true; //// frm.scholarshipPaymentToolStripMenuItem.Enabled = true; //// st1 = UserID.Text; //// st2 = "Successfully logged in"; //// // cf.LogFunc(st1, System.DateTime.Now, st2); break; } } else { MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Clear(); UserID.BackColor = Color.MidnightBlue; Password.Clear(); Password.BackColor = Color.MidnightBlue; UserID.Focus(); } } catch (NpgsqlException ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { SQLConn.cmd.Dispose(); SQLConn.ConnClose(); } }
private void completeLoad() { toggleWaitMessage(false); UserID.Focus(); PleaseWaitLabel.Content = (pageMode == PageFunctions.PassChange)? "Attempting password change - please wait..." : "Attempting login - please wait..."; }
private void btnOK_Click(object sender, EventArgs e) { if (UserID.Text == "") { MessageBox.Show("Please enter user ID", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Focus(); return; } if (Password.Text == "") { MessageBox.Show("Please enter password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Password.Focus(); return; } try { con = new SqlConnection(cs.DBcon); con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "SELECT RTRIM(UserID),RTRIM(Password) FROM User_Registration where UserID=@d1 and Password=@d2 union Select RTRIM(UserID),RTRIM(Password) from Client where UserID = @d1 and Password=@d2"; cmd.Parameters.AddWithValue("@d1", UserID.Text); cmd.Parameters.AddWithValue("@d2", Password.Text); rdr = cmd.ExecuteReader(); if (rdr.Read()) { con = new SqlConnection(cs.DBcon); con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "SELECT usertype FROM User_Registration where UserID=@d3 and Password=@d4"; cmd.Parameters.AddWithValue("@d3", UserID.Text); cmd.Parameters.AddWithValue("@d4", Password.Text); rdr = cmd.ExecuteReader(); if (rdr.Read()) { cmbUsertype.Text = rdr.GetValue(0).ToString().Trim(); } if ((rdr != null)) { rdr.Close(); } if (con.State == ConnectionState.Open) { con.Close(); } progressBar1.Visible = true; progressBar1.Maximum = 5000; progressBar1.Minimum = 0; progressBar1.Value = 4; progressBar1.Step = 1; for (int i = 0; i <= 5000; i++) { progressBar1.PerformStep(); } this.Hide(); frmMainMenu frm1 = new frmMainMenu(); frm1.User.Text = UserID.Text; frm1.Show(); st1 = UserID.Text; st2 = "Successfully logged in"; cf.LogFunc(st1, System.DateTime.Now, st2); } else { MessageBox.Show("Login Failed...Try again !", "Login Denied", MessageBoxButtons.OK, MessageBoxIcon.Error); UserID.Clear(); Password.Clear(); UserID.Focus(); } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }