Esempio n. 1
0
 private void deleteStudent()
 {
     try
     {
         if (!txtStudentId.Text.Trim().Equals(string.Empty))
         {
             DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete?", "Warning", MessageBoxButtons.YesNo);
             if (dialogResult == DialogResult.Yes)
             {
                 if (oStudentBL.DeleteStudent(txtStudentId.Text))
                 {
                     ClearControls();
                     LoadStudents();
                     MessageBox.Show("Record deleted successfully.!");
                 }
             }
         }
         else
         {
             txtStudentId.Focus();
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 2
0
        private void btnKaydet_Click(object sender, EventArgs e)
        {
            Student s = new Student();

            foreach (DataRow item in dt.Rows)
            {
                switch (item.RowState)
                {
                case DataRowState.Added:
                    s.Name         = item["Name"].ToString();
                    s.Surname      = item["Surname"].ToString();
                    s.NationId     = item["NationId"].ToString();
                    s.SchoolNumber = item["Schoolnumber"].ToString();
                    StudentBL.InsertStudent(s);
                    break;

                case DataRowState.Deleted:
                    s.StudentId = Convert.ToInt32(item["StudentId", DataRowVersion.Original]);
                    StudentBL.DeleteStudent(s.StudentId);
                    break;

                case DataRowState.Modified:
                    s.Name         = item["Name"].ToString();
                    s.Surname      = item["Surname"].ToString();
                    s.NationId     = item["NationId"].ToString();
                    s.SchoolNumber = item["Schoolnumber"].ToString();
                    s.StudentId    = Convert.ToInt32(item["StudentId"]);
                    StudentBL.UpdateStudent(s);
                    break;

                default:
                    break;
                }
            }
        }
Esempio n. 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtStudentSearchId.Text == string.Empty && txtStudentSearchName.Text == string.Empty)
                {
                    MessageBox.Show("You  must retrieve a record first.", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                if (MessageBox.Show("Are you sure you want to delete the current record?", "Warning",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                {
                    txtStudentSearchName.Focus();
                    return;
                }

                StudentBL stuBL = new StudentBL();

                if (stuBL.DeleteStudent(stu.StudentId))
                {
                    ClearData();
                    MessageBox.Show("Delete Successful");
                }
                else
                {
                    string msg = string.Empty;

                    foreach (ValidationError error in stuBL.Errors)
                    {
                        msg += error.Description + Environment.NewLine;
                    }

                    MessageBox.Show(msg);
                    MessageBox.Show("Delete Failed");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 4
0
 public ActionResult DeleteConfirmed(int id)
 {
     _studentBl.DeleteStudent(id);
     return(RedirectToAction("Index"));
 }
Esempio n. 5
0
        public ActionResult <bool> DeleteStudent(int id)
        {
            bool result = studentBL.DeleteStudent(id);

            return(result);
        }