private void BT_login_Click(object sender, EventArgs e) { Database.Model.Member_tbl memberTbl = new Database.Model.Member_tbl(); memberTbl.id = TB_id.Text; memberTbl.password = TB_pw.Text; memberTbl.Member_No = dbuse.Login(memberTbl); if (memberTbl.Member_No != 0) { if (memberTbl.id.Equals("admin") && memberTbl.password.Equals("admin")) { AdminForm adminForm = new AdminForm(); adminForm.Show(); Program.ac.MainForm = adminForm; this.Close(); } else { MainForm mainForm = new MainForm(memberTbl); mainForm.Show(); Program.ac.MainForm = mainForm; this.Close(); } } }
// Member_tbl 모델 복사 public void CopyData(Member_tbl param) { this.Member_No = param.Member_No; this.id = param.id; this.password = param.password; this.name = param.name; this.phone = param.phone; this.grade = param.grade; this.address = param.address; }
public void SignUp(Model.Member_tbl memberTbl) { String sql = "INSERT INTO Member_tbl (Member_No, id, password, name, phone, grade, address) VALUES (Member_TBL_SEQ.NEXTVAL, '" + memberTbl.id + "', '" + memberTbl.password + "', '" + memberTbl.name + "', '" + memberTbl.phone + "', '일반', '" + memberTbl.address + "')"; try { con.Open(); cmd.Connection = con; cmd.CommandText = sql; cmd.ExecuteNonQuery(); MessageBox.Show("회원가입 성공"); }catch (Exception e) { Console.WriteLine(e); MessageBox.Show("회원가입 실패"); } finally { con.Close(); } }
public int Login(Model.Member_tbl memberTbl) { String sql = "SELECT Member_No FROM Member_TBL WHERE id='" + memberTbl.id + "' AND password='******'"; int Member_No = 0; try { con.Open(); cmd.Connection = con; cmd.CommandText = sql; reader = cmd.ExecuteReader(); if (reader.Read()) { MessageBox.Show("로그인 성공!"); Member_No = Convert.ToInt32(reader.GetValue(0)); } else { MessageBox.Show("로그인 실패"); } }catch (Exception e) { MessageBox.Show(e + ""); } finally { if (!reader.IsClosed) { reader.Close(); } con.Close(); } return(Member_No); }