private void BtnList_Click(object sender, EventArgs e) { this.Visible = false; // 추가 Bbs showForm = new Bbs(); showForm.Passvalue = lbUser.Text; showForm.ShowDialog(); }
private void BtnCancel_Click(object sender, EventArgs e) { MessageBox.Show("글 작성이 취소됩니다."); this.Visible = false; // 추가 Bbs showForm = new Bbs(); showForm.Passvalue = tbWriter.Text; showForm.ShowDialog(); }
// 로그인 private void button1_Click(object sender, EventArgs e) { string sql = "select * from user where id = '" + tb_id.Text + "'"; try { conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader reader = cmd.ExecuteReader(); string[] user = new string[2] { "-1", "-1" }; while (reader.Read()) { // 복호화 user[0] = reader["id"].ToString(); user[1] = crypto.Decrypt(reader["pw"].ToString()); } if (!user[0].Equals(tb_id.Text)) { MessageBox.Show("아이디가 존재하지 않습니다."); } else if (user[0].Equals(tb_id.Text) && !user[1].Equals(tb_pw.Text)) { MessageBox.Show("비밀번호가 일치하지 않습니다."); } else if (user[0].Equals(tb_id.Text) && user[1].Equals(tb_pw.Text)) { this.Visible = false; Bbs form = new Bbs(); form.Passvalue = tb_id.Text; form.ShowDialog(); } conn.Close(); } catch (Exception e1) { Console.WriteLine(e1.ToString()); } }
private void NewWrite() { try { string sTitle = tbTitle.Text.ToString(); string sContent = rtbContent.Text.ToString(); // 데이터 공간 생성 ds = new DataSet(); // 접속하기 MySqlConnection conn = new MySqlConnection(mySqlConnStr); // 오픈 conn.Open(); // 데이터 가져오기 쿼리 StringBuilder sb = new StringBuilder(); sb.Append(" insert into bbs "); sb.Append(" values ( "); sb.Append(" NULL, "); sb.Append(" '"); sb.Append(tbTitle.Text); sb.Append("', "); sb.Append(" '"); sb.Append(rtbContent.Text); sb.Append("', "); sb.Append(" '"); sb.Append(tbWriter.Text); sb.Append("'"); sb.Append(" ) "); string sql = sb.ToString(); // sql 실행 MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); MessageBox.Show("글 작성이 완료되었습니다."); this.Visible = false; // 추가 Bbs showForm = new Bbs(); showForm.Passvalue = tbWriter.Text; showForm.ShowDialog(); } catch (Exception) { MessageBox.Show("오류"); } }
private void BtnDelete_Click(object sender, EventArgs e) { MySqlConnection conn = new MySqlConnection(mySqlConnStr); // 오픈 conn.Open(); // 데이터 가져오기 쿼리 StringBuilder sb = new StringBuilder(); sb.Append(" delete from bbs where no = '" + lbNo.Text + "'"); MySqlCommand cmd = new MySqlCommand(sb.ToString(), conn); cmd.ExecuteNonQuery(); conn.Close(); MessageBox.Show("성공적으로 삭제되었습니다."); this.Visible = false; // 추가 Bbs showForm = new Bbs(); showForm.Passvalue = lbUser.Text; showForm.ShowDialog(); }
private void SuJung() { try { string sTitle = tbTitle.Text.ToString(); string sContent = rtbContent.Text.ToString(); // 데이터 공간 생성 ds = new DataSet(); // 접속하기 MySqlConnection conn = new MySqlConnection(mySqlConnStr); // 오픈 conn.Open(); // 데이터 가져오기 쿼리 StringBuilder sb = new StringBuilder(); sb.Append(" update bbs set "); sb.Append(" title = '"); sb.Append(tbTitle.Text); sb.Append("', "); sb.Append(" content ='"); sb.Append(rtbContent.Text); sb.Append("' "); sb.Append(" where no ='"); sb.Append(tbNo.Text); sb.Append("'"); string sql = sb.ToString(); // sql 실행 MySqlCommand cmd = new MySqlCommand(sql, conn); cmd.ExecuteNonQuery(); MessageBox.Show("글 수정이 되었습니다."); this.Visible = false; // 추가 Bbs showForm = new Bbs(); showForm.Passvalue = tbWriter.Text; showForm.ShowDialog(); } catch (Exception ex) { MessageBox.Show("잘못작성되었습니다."); } }