예제 #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            site = new DBSite();
            StudentBll stBll = new StudentBll();

            List <string> student_id_list = new List <string>();

            try
            {
                foreach (GridViewRow gr in gridView1.Rows)
                {
                    CheckBox cb = (CheckBox)gr.Cells[0].FindControl("myCheckBox");
                    if (cb.Checked)
                    {
                        //if (stBll.IsStudentPresentInAttendance(site, util.CheckNullInt(gr.Cells[2].Text)))
                        //{
                        //    lblError.Text = "Can't Delete Record:'" + gr.Cells[4].Text + "' This Student is being entered in Attendance Entry.";
                        //    lblError.Visible = true;
                        //    ClearSuccessMessage();
                        //    return;
                        //}

                        student_id_list.Add(gr.Cells[3].Text);
                    }
                }


                if (student_id_list.Count < 1)
                {
                    lblError.Text    = "Can't Delete Records. Select at least one Record  ";
                    lblError.Visible = true;
                    ClearSuccessMessage();
                    return;
                }

                string st_ids = util.ConvertListToCommaSeparatedString(student_id_list);


                site.BeginTrans();
                stBll.DeleteStudent(site, st_ids);
                site.Commit();

                lblMessage.Text    = " [ " + student_id_list.Count + "] Record Deleted ";
                lblMessage.Visible = true;
                ClearErrorMessage();
            }
            catch (Exception del_exception)
            {
                site.RollBack();
                util.HandleExpception(del_exception, Response);
            }
            finally
            {
                site.Close();
            }
            GetStudents();
        }
        public void DeleteStudent(Student student)
        {
            _studentBll.DeleteStudent(student);

            UpdateForm();
        }
예제 #3
0
        /// <summary>
        /// 删除学生的方法
        /// </summary>
        /// <param name="studentNo"></param>
        /// <returns></returns>
        public ActionResult DeleteStudent(string studentNo)
        {
            int count = sb.DeleteStudent(studentNo);

            return(Content(count.ToString()));
        }