private void btnDel_Click(object sender, EventArgs e) { tbl.tblTeacher tc = new tbl.tblTeacher(txtTeacherID.Text, txtUsername.Text, txtPassword.Text); if (teacher.DeleteTeacher(tc) == false) { MessageBox.Show("Can not delete this teacher !!!", "Error"); } else { MessageBox.Show("Successfully Deleted !!!"); } dgvTeacher.DataSource = teacher.getAllTeachers(); dgvTeacher.Show(); Binding(); }
private void btnUp_Click(object sender, EventArgs e) { int index = dgvTeacher.CurrentRow.Index; string ID = dgvTeacher.Rows[index].Cells["TEACHER_ID"].Value.ToString(); tbl.tblTeacher tc = new tbl.tblTeacher(txtTeacherID.Text, txtUsername.Text, txtPassword.Text); if (teacher.UpdateTeacher(tc, ID) == false) { MessageBox.Show("Can not update this teacher !!!", "Error"); } else { MessageBox.Show("Successfully Updated !!!"); } dgvTeacher.DataSource = teacher.getAllTeachers(); dgvTeacher.Show(); }
private void btnCreate_Click(object sender, EventArgs e) { if (Check_Fill()) { tbl.tblTeacher tc = new tbl.tblTeacher(txtTeacherID.Text, txtUsername.Text, txtPassword.Text); if (teacher.InsertTeacher(tc) == false) { MessageBox.Show("Can not insert this teacher", "Error"); } else { MessageBox.Show("Inserted Successfully"); dgvTeacher.DataSource = teacher.getAllTeachers(); dgvTeacher.Show(); Binding(); } } }
public bool DeleteTeacher(tbl.tblTeacher tc) { string sql = "DELETE TEACHERS WHERE TEACHER_ID = @TEACHER_ID COLLATE SQL_Latin1_General_CP1_CS_AS "; SqlConnection con = dc.getConnect(); try { cmd = new SqlCommand(sql, con); con.Open(); cmd.Parameters.Add("@TEACHER_ID", SqlDbType.VarChar).Value = tc.TEACHER_ID; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool InsertTeacher(tbl.tblTeacher tc) { string sql = "INSERT INTO TEACHERS VALUES(@TEACHER_ID,@USERNAME,@PASSWORD)"; SqlConnection con = dc.getConnect(); try { cmd = new SqlCommand(sql, con); con.Open(); cmd.Parameters.Add("@TEACHER_ID", SqlDbType.VarChar).Value = tc.TEACHER_ID; cmd.Parameters.Add("@USERNAME", SqlDbType.VarChar).Value = tc.USERNAME; cmd.Parameters.Add("@PASSWORD", SqlDbType.VarChar).Value = tc.PASSWORD; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool UpdateTeacher(tbl.tblTeacher tc, string ID) { string sql = "UPDATE TEACHERS SET TEACHER_ID = @TEACHER_ID,USERNAME = @USERNAME,PASSWORD = @PASSWORD " + " WHERE TEACHER_ID = '" + ID + "' COLLATE SQL_Latin1_General_CP1_CS_AS "; SqlConnection con = dc.getConnect(); try { cmd = new SqlCommand(sql, con); con.Open(); cmd.Parameters.Add("@TEACHER_ID", SqlDbType.VarChar).Value = tc.TEACHER_ID; cmd.Parameters.Add("@USERNAME", SqlDbType.VarChar).Value = tc.USERNAME; cmd.Parameters.Add("@PASSWORD", SqlDbType.VarChar).Value = tc.PASSWORD; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool DeleteTeacher(tbl.tblTeacher tc) { return(dalTC.DeleteTeacher(tc)); }
public bool UpdateTeacher(tbl.tblTeacher tc, string ID) { return(dalTC.UpdateTeacher(tc, ID)); }
public bool InsertTeacher(tbl.tblTeacher tc) { return(dalTC.InsertTeacher(tc)); }