コード例 #1
0
 private void DeleteBtn_Click(object sender, EventArgs e)
 {
     using (var db = new AssignmentModel())
     {
         db.Tables.RemoveRange(db.Tables.Where(item => item.Nama_Tugas == lblNama.Text));
         db.SaveChanges();
         lblNama.Text          = "-";
         lblMatkul.Text        = "-";
         dateTimePicker1.Value = DateTime.Now;
         lblDeskripsi.Text     = "-";
         EditBtn.Enabled       = false;
         DeleteBtn.Enabled     = false;
     }
 }
コード例 #2
0
 private void EditData()
 {
     using (var db = new AssignmentModel())
     {
         var result = db.Tables.SingleOrDefault(k => k.Nama_Tugas == Assignment.Nama_Tugas);
         if (result != null)
         {
             result.Nama_Tugas = NamaTb.Text;
             result.Matkul     = MatKulTb.Text;
             result.Deadline   = dateTimePicker1.Value;
             result.Deskripsi  = DeskripsiTb.Text;
             db.SaveChanges();
             MessageBox.Show("Assignment updated");
             Close();
         }
     }
 }
コード例 #3
0
 private void TambahData()
 {
     if (NamaTb.Text != "" && MatKulTb.Text != "")
     {
         using (var db = new AssignmentModel())
         {
             var Assignment = new Table()
             {
                 Nama_Tugas = NamaTb.Text,
                 Matkul     = MatKulTb.Text,
                 Deskripsi  = DeskripsiTb.Text,
                 Deadline   = dateTimePicker1.Value,
             };
             db.Tables.Add(Assignment);
             db.SaveChanges();
             MessageBox.Show("Assignment added");
             Close();
         }
     }
 }
コード例 #4
0
 private void SearchBtn_Click(object sender, EventArgs e)
 {
     lblNama.Text          = "-";
     lblMatkul.Text        = "-";
     dateTimePicker1.Value = DateTime.Now;
     lblDeskripsi.Text     = "-";
     EditBtn.Enabled       = false;
     DeleteBtn.Enabled     = false;
     using (var db = new AssignmentModel())
     {
         var query = from Table in db.Tables where Table.Nama_Tugas == tbSearch.Text select Table;
         foreach (var item in query)
         {
             lblNama.Text          = item.Nama_Tugas;
             lblMatkul.Text        = item.Matkul;
             dateTimePicker1.Value = (DateTime)item.Deadline;
             lblDeskripsi.Text     = item.Deskripsi;
             EditBtn.Enabled       = true;
             DeleteBtn.Enabled     = true;
         }
     }
 }