private void btnRemove_Click(object sender, EventArgs e) { using (var dbn = new DBNormalTaskModel()) { dgTaskListNormal.Rows.Clear(); var query = from x in dbn.NormalTaskDBs where x.userID == lblName.Text select x; foreach (var item in query) { if (item.TaskName == dgTaskListNormal.CurrentCell.ToString()) { dbn.NormalTaskDBs.Remove(item); } } } using (var dbi = new DBImportantTaskModel()) { dgTaskListNormal.Rows.Clear(); var query = from y in dbi.ImportantTaskDBs where y.userID == lblName.Text select y; foreach (var item in query) { if (item.TaskName == dgTaskListImportant.CurrentCell.ToString()) { dbi.ImportantTaskDBs.Remove(item); } } } }
private void btnRemoveImportant_Click(object sender, EventArgs e) { using (var db = new DBNormalTaskModel()) { db.NormalTaskDBs.RemoveRange(db.NormalTaskDBs.Where(item => item.TaskName == tbTaskName.Text)); db.SaveChanges(); MessageBox.Show("Tugas normal berhasil dihapus"); this.Close(); } }
private void Update() { using (var dbn = new DBNormalTaskModel()) { var query = from x in dbn.NormalTaskDBs where x.userID == lblName.Text select x; foreach (var item in query) { dgTaskListNormal.Rows.Add(item.TaskName, item.Deadline, item.PriorityLevel, item.IsDone); } } using (var dbi = new DBImportantTaskModel()) { var query = from y in dbi.ImportantTaskDBs where y.userID == lblName.Text select y; foreach (var item in query) { dgTaskListImportant.Rows.Add(item.TaskName, item.Deadline, item.PriorityLevel, item.IsDone); } } }
private void TambahNormalTask() { using (var db = new DBNormalTaskModel()) if (tbTaskName.Text != "" && dtpDeadline.Text != "") { DateTime deadline = DateTime.Parse(dtpDeadline.Text); NormalTaskDB newNormalTask = new NormalTaskDB { TaskName = tbTaskName.Text, Deadline = deadline, PriorityLevel = cbPriorityLevel.Text, PrioLev = 0, userID = lblName.Text }; db.NormalTaskDBs.Add(newNormalTask); db.SaveChanges(); MessageBox.Show("Normal task baru sudah dibuat!"); Close(); } else { MessageBox.Show("Masukkan nama task!"); } }