private void btnDel_Click(object sender, EventArgs e) { tbl.tblAllocation al = new tbl.tblAllocation(txtCourseID.Text, txtTeacherID.Text); if (allocation.DeleteAllocation(al) == false) { MessageBox.Show("Can not delete this allocation !!!", "Error"); } else { MessageBox.Show("Successfully Deleted !!!"); } dgvAllocation.DataSource = allocation.getAllAllocations(); dgvAllocation.Show(); Binding(); }
private void btnUp_Click(object sender, EventArgs e) { int index = dgvAllocation.CurrentRow.Index; string tid = dgvAllocation.Rows[index].Cells["TEACHER_ID"].Value.ToString(); string cid = dgvAllocation.Rows[index].Cells["COURSE_ID"].Value.ToString(); tbl.tblAllocation al = new tbl.tblAllocation(txtCourseID.Text, txtTeacherID.Text); if (allocation.UpdateAllocation(al, cid, tid) == false) { MessageBox.Show("Can not update this allocation !!!", "Error"); } else { MessageBox.Show("Successfully !!!"); } dgvAllocation.DataSource = allocation.getAllAllocations(); dgvAllocation.Show(); }
private void btnCreate_Click(object sender, EventArgs e) { if (Check_Fill()) { tbl.tblAllocation al = new tbl.tblAllocation(txtCourseID.Text, txtTeacherID.Text); if (allocation.InsertAllocation(al) == false) { MessageBox.Show("Can not insert this allocation !!!", "Error"); } else { MessageBox.Show("Successfully !!!"); } dgvAllocation.DataSource = allocation.getAllAllocations(); dgvAllocation.Show(); Binding(); } }
public bool DeleteAllocation(tbl.tblAllocation c) { string sql = "DELETE TEACHING WHERE TEACHER_ID = @TEACHER_ID COLLATE SQL_Latin1_General_CP1_CS_AS AND COURSE_ID = @COURSE_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 = c.TEACHER_ID; cmd.Parameters.Add("@COURSE_ID", SqlDbType.VarChar).Value = c.COURSE_ID; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool InsertAllocation(tbl.tblAllocation c) { string sql = "INSERT INTO TEACHING VALUES(@TEACHER_ID,@COURSE_ID)"; SqlConnection con = dc.getConnect(); try { cmd = new SqlCommand(sql, con); con.Open(); cmd.Parameters.Add("@TEACHER_ID", SqlDbType.VarChar).Value = c.TEACHER_ID; cmd.Parameters.Add("@COURSE_ID", SqlDbType.NVarChar).Value = c.COURSE_ID; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool UpdateAllocation(tbl.tblAllocation c, string cid, string tid) { string sql = "UPDATE TEACHING SET TEACHER_ID = @TEACHER_ID, COURSE_ID = @COURSE_ID " + "WHERE COURSE_ID = '" + cid + "' COLLATE SQL_Latin1_General_CP1_CS_AS " + "AND TEACHER_ID ='" + tid + "' 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 = c.TEACHER_ID; cmd.Parameters.Add("@COURSE_ID", SqlDbType.VarChar).Value = c.COURSE_ID; cmd.ExecuteNonQuery(); con.Close(); } catch (Exception e) { return(false); } return(true); }
public bool DeleteAllocation(tbl.tblAllocation c) { return(dalC.DeleteAllocation(c)); }
public bool UpdateAllocation(tbl.tblAllocation c, string cid, string tid) { return(dalC.UpdateAllocation(c, cid, tid)); }
public bool InsertAllocation(tbl.tblAllocation c) { return(dalC.InsertAllocation(c)); }