public void checkadmin(string user, string pass) { string connstr = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\umair\source\repos\Lib Mang Sys\Lib Mang Sys\Database1.mdf;Integrated Security=True"; using (SqlConnection conn = new SqlConnection(connstr)) { try { conn.Open(); string query = "Select * from dbo.Admin"; SqlCommand command = new SqlCommand(query, conn); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { string username = reader.GetString(reader.GetOrdinal("Name")); string password = reader.GetString(reader.GetOrdinal("Password")); if (user == username && pass == password) { Admin_Login a = new Admin_Login(); a.Hide(); Admin_Panel b = new Admin_Panel(); b.Show(); } else { MessageBox.Show("wrong"); } } } catch (Exception) { } } }
/// <summary> /// calling nest pannel by making object /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNewUser_Click(object sender, EventArgs e) { Admin_Panel newUser = new Admin_Panel(); newUser.Show(); this.Hide(); }
public void MyFillAll(Admin_Panel adminPanel) { using (var lobo = new GymProEntities()) { _adminPanelArgs.ADMIN_PANEL = lobo.ADMIN_PANEL.ToList(); OnOnFillCompleteHandler(_adminPanelArgs); } }
private void Admin_Logout_ToolStripMenuItem_Click(object sender, EventArgs e) // 관리자 로그아웃 { Admin_Panel.Hide(); Main_Panel.Show(); }
private void login_button_Click(object sender, EventArgs e) // 로그인 버튼 { // 어떤 항목이 입력되지 않았다면 if (loginid_textBox.Text == "" || loginpw_textBox.Text == "") { MessageBox.Show("아이디와 비밀번호를 입력해 주세요!", "로그인 오류"); } // 로그인 성공 else { string loginQuery = "SELECT user_id, user_pw FROM user_register WHERE (user_id = '" + loginid_textBox.Text + "' and user_pw = '" + loginpw_textBox.Text + "')"; // 이름, 아이디, 비밀번호, 연락처를 DB에 저장 connection.Open(); MySqlCommand command = new MySqlCommand(loginQuery, connection); MySqlDataReader reader = command.ExecuteReader(); try//예외 처리 { // 아이디가 없거나 비밀번호가 틀렸다면 if (!reader.Read()) { MessageBox.Show("아이디가 없거나 비밀번호가 틀렸습니다!", "로그인 실패"); } // 로그인 성공시 else { LoginID = loginid_textBox.Text; if (LoginID == "admin") { MessageBox.Show("관리자 접속", "관리자 모드"); loginid_textBox.Clear(); loginpw_textBox.Clear(); connection.Close(); Main_Panel.Hide(); Admin_Panel.Show(); try { // book_register 테이블을 register_listView에 출력 connection.Open(); Admin_book_register_listview(); // 현재 보유 도서 리스트뷰 갱신 // book_retnal 테이블을 rental-listView에 출력 string book_rental_Querry = "SELECT * FROM book_rental"; MySqlCommand com = new MySqlCommand(book_rental_Querry, connection); MySqlDataAdapter dap = new MySqlDataAdapter(book_rental_Querry, connection); DataTable dtp = new DataTable(); dap.Fill(dtp); Admin_Book_Rental_List_listView.Items.Clear(); // View가 중복조회 되는것을 방지한다. for (int i = 0; i < dtp.Rows.Count; i++) { DataRow drp = dtp.Rows[i]; ListViewItem listitem = new ListViewItem(drp["book_name"].ToString()); listitem.SubItems.Add(drp["book_author"].ToString()); listitem.SubItems.Add(drp["book_publisher"].ToString()); listitem.SubItems.Add(drp["book_code"].ToString()); listitem.SubItems.Add(drp["book_userid"].ToString()); listitem.SubItems.Add(drp["book_userhp"].ToString()); listitem.SubItems.Add(drp["book_deadline"].ToString()); Admin_Book_Rental_List_listView.Items.Add(listitem); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { connection.Close(); } Admin_Panel.Show(); } else { MessageBox.Show(LoginID + "님 환영합니다.", "로그인 성공"); loginid_textBox.Clear(); loginpw_textBox.Clear(); connection.Close(); Book_Rental_List_View("SELECT * FROM book_register"); Main_Panel.Hide(); Book_Rental_List_Panel.Show(); Notice(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "예기치 못한 오류 발생"); connection.Close(); } } }
//function for database calling /// <summary> /// database calling /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnLogin_Click(object sender, EventArgs e) { DBConnection dc = new DBConnection(); String sql_login = "******" + txtUserName.Text + "' AND Password= '******'"; MySqlCommand cmd = new MySqlCommand(sql_login, dc.Db_Connect()); MySqlDataReader r = cmd.ExecuteReader(); if (r.Read()) { //retrieveing value from column and sending value to the top declare variable(line 18) for Bug Entry Form. String idpass = r.GetString("User_Id"); usridpass = idpass; String unamepass = r.GetString("UserName"); usrnamepass = unamepass; String usertype = r.GetString("Usr_Type"); usrtypepass = usertype; //Checking User Types switch (usertype) { case "Developer": MessageBox.Show("welcome to Bug Tracking System (Developer)"); BugSolutionForm pp = new BugSolutionForm(); pp.Show(); break; case "Admin": MessageBox.Show("welcome to Bug Tracking System (Admin)"); Admin_Panel ap = new Admin_Panel(); ap.Show(); break; case "Tester": MessageBox.Show("welcome to Bug Tracking System (Tester)"); BugEntryForm tp = new BugEntryForm(); tp.Show(); // tp.lbl_Usershow.Text = idpass; break; default: MessageBox.Show(usertype); MessageBox.Show("welcome to BugTracking System (error!!!!!!)"); BugEntryForm err = new BugEntryForm(); err.Show(); break; } //for hiding loginpanel this.Hide(); //for closing database connection dc.CloseConnection(); } else { MessageBox.Show("Username or Password incorrect!!!"); } }