Ejemplo n.º 1
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        try
        {
            string   del_list = hdfCheck.Value;
            string[] sp_list  = del_list.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < sp_list.Length; i++)
            {
                try
                {
                    DataTable db = objSubject.GetDataByID(Convert.ToInt32(sp_list[i]));
                    bool      kt = File.Exists(Server.MapPath("~/Images/subject/") + db.Rows[0]["IMAGE"]);
                    if (kt)
                    {
                        File.Delete(Server.MapPath("~/Images/subject/") + db.Rows[0]["IMAGE"]);
                    }
                }
                catch (Exception)
                {
                    throw;
                }

                objSubject.Delete(sp_list[i]);
            }
            Response.Redirect(Request.RawUrl);
        }
        catch (Exception ex)
        {
            divMessage.InnerHtml = O2S_Message.Error("Cảnh Báo", "Phát hiện lỗi! " + ex.Message);
        }
    }
        /// <summary>
        /// Occurs when the Button control is clicked. Deletes an extisting Subject.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Weet je het zeker?", "Vak Verwijderen", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                int          result             = 0;
                List <Grade> subjectGradesQuery = (from grade in grades
                                                   where grade.RowIndex == model.RowIndex
                                                   select grade).ToList();

                List <Grade> gradeQuery = (from grade in grades
                                           where grade.RowIndex > model.RowIndex
                                           select grade).ToList();

                List <Subject> subjectQuery = (from subject in subjects
                                               where subject.RowIndex > model.RowIndex
                                               select subject).ToList();

                if (subjectGradesQuery.Count != 0)
                {
                    for (int i = 0; i < subjectGradesQuery.Count; i++)
                    {
                        gradeController.Delete(grades[i]);
                    }

                    for (int i = 0; i < subjectQuery.Count; i++)
                    {
                        gradeQuery[i].RowIndex -= 1;
                        gradeController.Edit(gradeQuery[i]);
                    }
                }

                if (subjectQuery.Count != 0)
                {
                    for (int i = 0; i < subjectQuery.Count; i++)
                    {
                        subjectQuery[i].RowIndex -= 1;
                        subjectController.Edit(subjectQuery[i]);
                    }
                }

                result = subjectController.Delete(model);

                if (result != 0)
                {
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Onbekend probleem bij het verwijderen van het vak.");
                }
            }
        }
Ejemplo n.º 3
0
        public void Delete_ReturnsOk()
        {
            //Arrange
            _subjectService.Setup(s => s.DeleteEntityByIdAsync(_subject.Id));

            //Act
            var actionResult = _subjectController.Delete(_subject.Id).Result as OkResult;

            //Assert
            actionResult.StatusCode.Equals(200);
        }
Ejemplo n.º 4
0
        public void DeleteSubject()
        {
            var res = controller.Delete(1);

            Assert.IsInstanceOfType(res, typeof(RedirectToRouteResult));
            var redirectRes = res as RedirectToRouteResult;

            Assert.IsNull(redirectRes.RouteValues["controller"]);
            Assert.AreEqual("List", redirectRes.RouteValues["action"]);

            sMockRepository.Verify(r => r.Delete(subjects[0]));
            sMockRepository.Verify(r => r.Save());
        }
Ejemplo n.º 5
0
        private void btnDelSubject_Click(object sender, EventArgs e)
        {
            if (this.cbSubject.SelectedIndex == 0 || this.cbSubject.SelectedIndex == -1)
            {
                return;
            }
            Subject s = new Subject();

            s.id      = this.cbSubject.SelectedIndex;
            s.subject = this.cbSubject.Text.Trim();
            SubjectController.Delete(s);

            this.cbSubject.Items.Remove(this.cbSubject.Text.Trim());
        }
Ejemplo n.º 6
0
 private void DeclineButton_Click(object sender, EventArgs e)
 {
     if (New)
     {
         NameTextbox.Text     = "";
         CodenameTextbox.Text = "";
     }
     else if (CustomMessages.YesNoDelete(this))
     {
         Deleted = controller.Delete(subject);
         if (!Deleted)
         {
             CustomMessages.DeleteFail(this, "subject");
         }
         Close();
     }
 }
Ejemplo n.º 7
0
        public void Delete_Removes_Subject()
        {
            var subjectId      = 1;
            var deletedSubject = new Subject(subjectId, "First subject");
            var subjectList    = new List <Subject>()
            {
                deletedSubject,
                new Subject(2, "Second subject")
            };

            subjectRepo.GetById(subjectId).Returns(deletedSubject);
            subjectRepo.When(d => d.Delete(deletedSubject))
            .Do(d => subjectList.Remove(deletedSubject));

            subjectRepo.GetAll().Returns(subjectList);
            var result = underTest.Delete(subjectId);

            Assert.DoesNotContain(deletedSubject, result);
            //Assert.All(result, item => Assert.Contains("second item", item.Name));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Occurs when the value of a cell changes. Adds a new Appointment if there wasn't no value. Edit an existing Appointment if the value changed. Deletes an existing Appointment if the value is empty.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="DataGridViewCellEventArgs"/> instance containing the event data.</param>
        private void dgvUsers_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            dgvUsers.CellValueChanged -= dgvUsers_CellValueChanged;
            dgvUsers[e.ColumnIndex, e.RowIndex].Value = false;
            dgvUsers.CellValueChanged += dgvUsers_CellValueChanged;

            if (e.ColumnIndex == 1)
            {
                DialogResult dialogResult = MessageBox.Show("U staat op het punt om deze gebruiker te verwijderen.\nAlle taken, vakken, cijfers en afspraken zullen van deze gebruiker verwijderd worden.", "Gebruiker verwijderen", MessageBoxButtons.YesNo);

                if (dialogResult == DialogResult.Yes)
                {
                    int  result = 0;
                    User query  = null;
                    uint?id     = null;

                    List <DataGridViewRow> rows = (from row in dgvUsers.Rows.Cast <DataGridViewRow>()
                                                   select row).ToList();

                    id = (from row in rows
                          where Convert.ToBoolean(row.Cells["verwijderen?"].Value) == true
                          select Convert.ToUInt32(row.Cells[dgvUsers.ColumnCount - 1].Value)).FirstOrDefault();

                    query = (from user in users
                             where user.Id == id
                             select user).FirstOrDefault();

                    if (query != null)
                    {
                        tasks          = taskController.Details(id);
                        repeatingTasks = repeatingTaskController.Details(id);
                        grades         = gradeController.Details(id);
                        subjects       = subjectController.Details(id);
                        appointments   = appointmentController.Details(id);

                        for (int i = 0; i < tasks.Count; i++)
                        {
                            taskController.Delete(tasks[i]);
                        }

                        for (int i = 0; i < repeatingTasks.Count; i++)
                        {
                            repeatingTaskController.Delete(repeatingTasks[i]);
                        }

                        for (int i = 0; i < grades.Count; i++)
                        {
                            gradeController.Delete(grades[i]);
                        }

                        for (int i = 0; i < subjects.Count; i++)
                        {
                            subjectController.Delete(subjects[i]);
                        }

                        for (int i = 0; i < appointments.Count; i++)
                        {
                            appointmentController.Delete(appointments[i]);
                        }

                        result = userController.Delete(query);

                        if (result == 0)
                        {
                            MessageBox.Show("Kon de gebruiker niet verwijderen.");
                        }
                        else
                        {
                            MessageBox.Show("De gebruiker is succesvol verwijderd.");
                        }
                    }

                    LoadToGrid();
                }
            }
        }