Exemplo n.º 1
0
Arquivo: MainForm.cs Projeto: Gqqq/-
        private void  除DToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //if (this.lvwStudent.SelectedItems.Count > 0)
            //{
            //    int count = 0, ch = 0, er = 0;
            //    count = this.lvwStudent.SelectedItems.Count;//总行

            //    foreach (ListViewItem it in this.lvwStudent.SelectedItems)
            //    {
            //        stumodel.Student_ID = Convert.ToInt32(it.Tag);
            //        int i = student.DelStudents(stumodel);
            //        if (i > 0)
            //        {
            //            ch++;
            //        }
            //        else
            //        {
            //            er++;
            //        }
            //    }
            //    string s = string.Format("总共删除{0}行,成功{}行,失败{}行", count, ch, er);
            //    MessageBox.Show(s);
            //}
            //else
            //{
            //    MessageBox.Show("你还没选中要删除的项");
            //    return;
            //}
            stumodel.Student_ID = Convert.ToInt32(this.lvwStudent.SelectedItems[0].Tag);
            try
            {
                student.DelStudents(stumodel);
                BindListView();
            }
            catch
            {
                MessageBox.Show("请谨慎删除学生信息");
            }
        }