Example #1
0
 private void butAccept_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要提交所选实验吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) //判断是否在弹出的对话框中单击"确定"按钮
     {
         for (int i = 0; i < dataGridView1.Rows.Count; i++)                                                            //循环遍历DataGridView控件中的每一行
         {
             try
             {
                 if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时
                 {
                     //当该行处于选定状态时
                     if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true)
                     {
                         string id = dataGridView1.Rows[i].Cells[1].Value.ToString();
                         //int id = Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value);
                         MyClass.getsqlcom("Update tb_Report set flagSubmit = 'true' where IDR='" + id.ToString() + "'");   //执行SQL语句
                     }
                 }
             }
             catch (Exception ex)             //捕获异常
             {
                 MessageBox.Show(ex.Message); //弹出异常提示信息
             }
         }
         MessageBox.Show("提交成功!", "操作", MessageBoxButtons.OK, MessageBoxIcon.Information); //显示消息
         Showall();
     }
 }
Example #2
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("确定要删除所选实验吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) //判断是否在弹出的对话框中单击"确定"按钮
     {
         for (int i = 0; i < dataGridView1.Rows.Count; i++)                                                            //循环遍历DataGridView控件中的每一行
         {
             try
             {
                 if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时
                 {
                     //当该行处于选定状态时
                     if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true)
                     {
                         string id = dataGridView1.Rows[i].Cells[1].Value.ToString();
                         dataGridView1.Rows.RemoveAt(i);                                                  //移除处于选定状态的记录
                         MyClass.getsqlcom("Delete from tb_Experiment where ID='" + id.ToString() + "'"); //执行SQL语句
                         i--;                                                                             //不改变循环变量的i的值
                     }
                 }
             }
             catch (Exception ex)             //捕获异常
             {
                 MessageBox.Show(ex.Message); //弹出异常提示信息
             }
         }
         MessageBox.Show("删除成功!", "操作", MessageBoxButtons.OK, MessageBoxIcon.Information); //显示消息
         Showall();
     }
 }
        /*private void butSaveAsWord_Click(object sender, EventArgs e)
         * {
         *  if (CreateWordFile(""))
         *  {
         *      MessageBox.Show("创建成功!请查看");
         *  }
         * }*/

        private void butAccept_Click(object sender, EventArgs e)
        {
            if (txtALG.Text != null && txtDescription.Text != null && txtRunning.Text != null && txtQuestion.Text != null)
            {
                if (this.Tag.Equals(0))//如果是学生新建模式
                {
                    SqlDataReader temDR = MyClass.getcom("select * from tb_Student where IDS ='" + DataClass.MyMeans.Login_ID.ToString() + "'");
                    if (temDR.Read())
                    {
                        try
                        {
                            MyClass.getsqlcom("insert into tb_Report (IDE,IDS,date,title,description,ALG,running,question,IDC,class,mark,evaluation,flagSubmit,flagCorrect) values('" + DataClass.Experiment.Experiment_ID_forStudent + "','" + txtStudentNum.Text.Trim() + "','" + txtTime.Text.Trim() + "','" + txtTitle.Text.Trim() + "','" + txtDescription.Text.Trim() + "','" + txtALG.Text.Trim() + "','" + txtRunning.Text.Trim() + "','" + txtQuestion.Text.Trim() + "','" + cb_ChapterName.SelectedValue + "','" + temDR.GetString(temDR.GetOrdinal("class")) + "','无','无','false','false')");
                            MessageBox.Show("保存成功,请在报告管理中查改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.butClose_Click(null, null);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "警告");
                        }
                    }
                }
                else
                {
                    if (this.Tag.Equals(2))//如果是学生修改模式
                    {
                        try
                        {
                            MyClass.getsqlcom("update tb_Report set description='" + txtDescription.Text.Trim() + "',ALG='" + txtALG.Text.Trim() + "',running='" + txtRunning.Text.Trim() + "',question='" + txtQuestion.Text.Trim() + "' where IDR='" + DataClass.Report.Report_ID_forStudent + "'");
                            MessageBox.Show("保存成功,请在报告管理中查改!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.butClose_Click(null, null);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message, "警告");
                        }
                    }
                    else
                    {
                        if (this.Tag.Equals(4))//如果是学生重做模式
                        {
                            try
                            {
                                MyClass.getsqlcom("update tb_Report set description='" + txtDescription.Text.Trim() + "',ALG='" + txtALG.Text.Trim() + "',running='" + txtRunning.Text.Trim() + "',question='" + txtQuestion.Text.Trim() + "',flagSubmit='true' where IDR='" + DataClass.Report.Report_ID_forStudent + "'");
                                MessageBox.Show("重做成功,并且已经自动帮您提交!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.butClose_Click(null, null);
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message, "警告");
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("请将实验报告填写完整!", "提示");
            }
        }
 private void butOK_Click(object sender, EventArgs e)
 {
     if (this.Tag.Equals(0))//如果是修改操作
     {
         try
         {
             MyClass.getsqlcom("update tb_Chapter set name='" + txtChapterName.Text.Trim() + "' where IDC='" + idc + "'"); //更新数据库中信息
             MessageBox.Show("修改成功!");
             txtChapterName.ReadOnly = true;                                                                               //改回只读
             butCancel.Enabled       = false;
             butOK.Enabled           = false;
             DataInit();//初始化数据空间
             //激活前三个功能按钮
             butAmend.Enabled  = true;
             butDelete.Enabled = true;
             butAdd.Enabled    = true;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         if (this.Tag.Equals(1))//如果是增加操作
         {
             try
             {
                 MyClass.getsqlcom("insert into tb_Chapter (IDC,name) values('" + txtChapNum.Text.Trim() + "','" + txtChapterName.Text.Trim() + "')"); //更新数据库中信息
                 MessageBox.Show("新增章节成功!");
                 txtChapterName.ReadOnly = true;                                                                                                       //改回只读
                 txtChapNum.ReadOnly     = true;
                 txtChapterName.Clear();                                                                                                               //清空输入控件
                 txtChapNum.Clear();
                 butCancel.Enabled = false;
                 butOK.Enabled     = false;
                 DataInit();//初始化数据空间
                 //激活前三个功能按钮
                 butAmend.Enabled  = true;
                 butDelete.Enabled = true;
                 butAdd.Enabled    = true;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
Example #5
0
        private void  除文件夹ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string sqlDelete = "delete from tbl_folder where foldername='" + treeViewFolder.SelectedNode.Text + "'";

            treeViewFolder.SelectedNode.Remove();
            MyMeans.getsqlcom(sqlDelete);
        }
Example #6
0
        private void Sta_Save_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTab.Name == "tabPage1")//如果当前是职工基本信息选项卡
            {
                System.Byte[] Photo = oto;
                string        ID = S_0.Text, StaffName = S_1.Text, Folk = S_2.Text, Culture = S_5.Text, Marriage = S_6.Text, Sex = S_7.Text;
                string        Visage = S_8.Text, Employee = S_12.Text, IDCard = S_9.Text, Business = S_13.Text, Laborage = S_14.Text, Branch = S_15.Text;
                string        Duthcall = S_16.Text, Phone = S_17.Text, Handset = S_18.Text, School = S_19.Text, Speciality = S_20.Text, Address = S_22.Text;
                string        Age = S_4.Text, WorkLength = S_11.Text, M_Pay = S_25.Text, Pact_Y = S_29.Text;
                string        BeAware = S_23.Text, City = S_24.Text, Bank = S_26.Text;

                DateTime Birthday, Workdate, GraduateDate, Pact_B, Pact_E;
                Birthday     = Convert.ToDateTime(this.S_3.Text.Trim());;
                Workdate     = Convert.ToDateTime(this.S_10.Text.Trim());;
                GraduateDate = Convert.ToDateTime(this.S_21.Text.Trim());
                Pact_B       = Convert.ToDateTime(this.S_27.Text.Trim());;
                Pact_E       = Convert.ToDateTime(this.S_28.Text.Trim());;



                string s = string.Format(@"INSERT INTO tb_Staffbasic  VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}')"
                                         , ID, StaffName, Folk, Birthday, Age, Culture, Marriage, Sex, Visage, IDCard, WorkLength, Workdate, Employee, Business, Laborage, Branch, Duthcall, Phone, Handset, School, Speciality, GraduateDate, Address, oto, BeAware, City, M_Pay, Bank,
                                         Pact_B, Pact_E, Pact_Y);

                MyMeans.getsqlcom(s);
                Sta_Save.Enabled = false;


                button6_Click(sender, e);
            }
        }
Example #7
0
        //右击彻底删除回收站信息
        private void 彻底删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OnOperatorClick1(this);
            string sqlDelete = "delete from tbl_rabbish where rtime='" + this.textBoxtime.Text.Trim() + "'";

            MyMeans.getsqlcom(sqlDelete);
        }
Example #8
0
        private void buttonfinish_Click(object sender, EventArgs e)
        {
            string sqlDelete = "delete from tbl_user where username='******'";

            MyMeans.getsqlcom(sqlDelete);
            Application.Exit();
        }
Example #9
0
        //bug:修改好密码后应该回到登录窗口
        private void buttonfinish_Click(object sender, EventArgs e)
        {
            string sqlAlter = "update tbl_user set password='******' where username='******'";

            MyMeans.getsqlcom(sqlAlter);
            this.Close();
        }
Example #10
0
        public void getsqlcomTest()
        {
            MyMeans target = new MyMeans(); // TODO: 初始化为适当的值
            string  SQLstr = string.Empty;  // TODO: 初始化为适当的值

            target.getsqlcom(SQLstr);
            Assert.Inconclusive("无法验证不返回值的方法。");
        }
 private void butOK_Click(object sender, EventArgs e)
 {
     if (txtEvaluation.Text != "")
     {
         if (txtMark.Text != "")
         {
             if (Convert.ToInt32(txtMark.Text.Trim()) < 60)//如果不及格,则让学生退回重做
             {
                 try
                 {
                     MyClass.getsqlcom("update tb_Report set mark='" + txtMark.Text.Trim() + "',evaluation='" + txtEvaluation.Text.Trim() + "',flagCorrect='true',flagSubmit='false' where IDR='" + DataClass.Report.Report_ID_forTeacher + "'");
                     MessageBox.Show("保存成功,欢迎继续使用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.butClose_Click(null, null);
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message, "警告");
                 }
             }
             else//如果学生及格,则不用重做
             {
                 try
                 {
                     MyClass.getsqlcom("update tb_Report set mark='" + txtMark.Text.Trim() + "',evaluation='" + txtEvaluation.Text.Trim() + "',flagCorrect='true',flagSubmit='true' where IDR='" + DataClass.Report.Report_ID_forTeacher + "'");
                     MessageBox.Show("保存成功,欢迎继续使用!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.butClose_Click(null, null);
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message, "警告");
                 }
             }
         }
         else
         {
             MessageBox.Show("请输入完整评分后再次按确认!", "提示");
         }
     }
     else
     {
         MessageBox.Show("请输入完整评语后再次按确认!", "提示");
     }
 }
Example #12
0
        //主窗体加载
        private void FormMain_Load(object sender, EventArgs e)
        {
            panelTop.BackColor     = ColorTranslator.FromHtml("#398dee");
            panelNewFile.BackColor = ColorTranslator.FromHtml("#398dee");

            uc1 = new UserControl1();
            uc3 = new UserControl3();


            //默认UC1控件显示
            uc1.Show();
            textBoxgroup.Controls.Clear();
            textBoxgroup.Controls.Add(uc1);

            //委托点击按钮新建笔记
            this.uc1.button1.Click += userControl11_button1_Click;

            string str  = "delete from tbl_note";
            string str1 = "delete from tbl_rabbish";

            MyMeans.getsqlcom(str);
            MyMeans.getsqlcom(str1);

            //显示所有的文件夹
            String        SQLstr = "select * from tbl_folder";
            SqlConnection My_con;
            string        M_str_sqlcon = "Integrated Security=SSPI;Database=notebook;Server=.";

            My_con = new SqlConnection(M_str_sqlcon);
            My_con.Open();
            SqlCommand     cmd = new SqlCommand(SQLstr, My_con);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);
            DataSet        ds  = new DataSet();

            da.Fill(ds, "tbl_folder");
            //获取表中有多少条记录,循环显示文件夹
            SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Database=notebook;Server=.");

            conn.Open();
            SqlCommand comm = new SqlCommand();

            comm.CommandText = "select count(*) from tbl_folder";
            comm.Connection  = conn;
            int count = (int)comm.ExecuteScalar();

            for (int i = 0; i < count; i++)
            {
                string foldername = ds.Tables["tbl_folder"].Rows[i]["foldername"].ToString();
                newnode = new TreeNode(foldername, 0, 0);
                treeViewFolder.Nodes.Add(newnode);
            }
        }
Example #13
0
        public void buttondelete_Click_1(object sender, EventArgs e)
        {
            // 从note表中移除笔记
            string sqlDelete = "delete from tbl_note where time='" + this.textBoxtime.Text.Trim() + "'";

            MyMeans.getsqlcom(sqlDelete);

            OnOperatorClick(this);

            //将该数据插入到让rabbish表中
            MyMeans.getsqlcom("insert into tbl_rabbish(rtitle,rcontent,rtime) values('" + this.textBoxtitle.Text + "','" + this.textBoxcontent.Text + "','" + this.textBoxtime.Text + "')");
            //一点删除让回收站加载删除的控件
            fm.uc3.AddControl();
        }
Example #14
0
        private void   文件夹ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderBrowserDialog1 = new FolderBrowserDialog();

            folderBrowserDialog1.ShowNewFolderButton = true;
            folderBrowserDialog1.RootFolder          = Environment.SpecialFolder.Desktop;
            DialogResult result = folderBrowserDialog1.ShowDialog();

            if (result == DialogResult.OK)
            {
                folderpath = folderBrowserDialog1.SelectedPath;
                string folderName = new System.IO.DirectoryInfo(folderpath).Name;
                if (folderName != "")
                {
                    newnode = new TreeNode(folderName, 0, 0);
                    treeViewFolder.Nodes.Add(newnode);
                    string time = DateTime.Now.ToString();
                    MyMeans.getsqlcom("insert into tbl_folder(foldername,buildtime) values('" + folderName + "','" + time + "')");

                    //获取该文件夹下面的所有文件名
                    System.IO.DirectoryInfo dir = new DirectoryInfo(folderpath);
                    if (dir.Exists)
                    {
                        FileInfo[] fiList = dir.GetFiles();
                        foreach (var item in fiList)
                        {
                            var    FileName = item.Name;
                            string content  = "";
                            using (StreamReader sr = item.OpenText())
                            {
                                content += sr.ReadToEnd();
                            }
                            string filetime = DateTime.Now.ToString();
                            MyMeans.getsqlcom("insert into tbl_note(title,content,time,foldername) values('" + FileName + "','" + content + "','" + filetime + "','" + folderName + "')");

                            newnode = new TreeNode(FileName, 1, 1);

                            SqlConnection conn = new SqlConnection("Integrated Security=SSPI;Database=notebook;Server=.");
                            conn.Open();
                            SqlCommand comm = new SqlCommand();
                            comm.CommandText = "select count(*) from tbl_folder";
                            comm.Connection  = conn;
                            int count = (int)comm.ExecuteScalar();

                            treeViewFolder.Nodes[count - 1].Nodes.Add(newnode);
                        }
                    }
                }
            }
        }
Example #15
0
 //点击注册
 private void buttonRegister_Click_1(object sender, EventArgs e)
 {
     if (textRusername.Text != null & textRpassword.Text != null & textRpassword.Text == textRcomfirm.Text)
     {
         string time = DateTime.Now.ToString();
         MyMeans.getsqlcom("insert into tbl_user(username,password,logintime) values('" + textRusername.Text.Trim() + "','" + textRpassword.Text.Trim() + "','" + time + "')");
         this.Hide();
         FormLogin formLogin = new FormLogin();
         formLogin.ShowDialog();
     }
     else
     {
         textError.Text = "请输入完整注册信息!";
     }
 }
Example #16
0
        private void Sta_Delete_Click(object sender, EventArgs e) //删除人事档案信息
        {
            if (MyDS_Grid.RowCount < 2)                           //判断控件中是否有记录
            {
                MessageBox.Show("数据表为空,不可以删除!");
                return;
            }

            MyMeans.getsqlcom("Delete tb_Staffbasic where = ID'" + S_0.Text.Trim() + "'");
            MyMeans.getsqlcom("Delete tb_WorkResume where = Stu_ID'" + S_0.Text.Trim() + "'");
            MyMeans.getsqlcom("Delete tb_Family where = Sta_ID'" + S_0.Text.Trim() + "'");
            MyMeans.getsqlcom("Delete tb_TrainNote where = Sta_ID '" + S_0.Text.Trim() + "'");
            MyMeans.getsqlcom("Delete tb_RANDP where = Sta_ID'" + S_0.Text.Trim() + "'");
            MyMeans.getsqlcom("Delete tb_WorkResume where = Sta_ID'" + S_0.Text.Trim() + "'");
            MyMeans.getsqlcom("Delete tb_Individual where = ID'" + S_0.Text.Trim() + "'");

            button6_Click(sender, e);
        }
Example #17
0
        private void buttonsave_Click(object sender, EventArgs e)
        {
            string sqltitle = "select count(*) from tbl_person_info where username='******'";

            MyMeans.My_con = new SqlConnection(MyMeans.M_str_sqlcon);
            SqlCommand cmd = new SqlCommand(sqltitle, MyMeans.My_con);

            MyMeans.My_con.Open();
            int num = Convert.ToInt32(cmd.ExecuteScalar());

            if (num > 0)
            {
                sqltitle = "update  tbl_person_info set realname='" + this.textrealname.Text + "',phone='" + this.textphone.Text + "',deacription='" + this.textdeacription.Text + "',province='" + this.textprovince.Text + "',county='" + this.textcounty.Text + "'";
                MyMeans.getsqlcom(sqltitle);
            }
            else
            {
                string sqlinstert = "insert into tbl_person_info(username,realname,phone,deacription,province,county) values('" + textBoxname.Text + "','" + textrealname.Text + "','" + textphone.Text + "','" + textdeacription.Text + "','" + textprovince.Text + "','" + textcounty.Text + "')";
                MyMeans.getsqlcom(sqlinstert);
            }
            this.Hide();
        }
 private void updata_button_Click(object sender, EventArgs e)
 {
     if (oldpwd_text.Text.Trim() == DataClass.MyMeans.User_Pwd) //判断旧密码是否正确
     {
         if (newpwd_text1.Text == newpwd_text2.Text)            //判断新密码两次输入
         {
             try
             {
                 MyClass.getsqlcom("update tb_UserLogin set password='******' where IDU=" + DataClass.MyMeans.User_ID.ToString() + "");
                 DataClass.MyMeans.User_Pwd = newpwd_text1.Text.Trim(); //将新密码赋值给系统变量
                 this.DialogResult          = DialogResult.OK;
                 this.Close();                                          //模式退出
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
         else
         {
             MessageBox.Show("新密码两次输入不一样!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             oldpwd_text.Text  = "";
             newpwd_text1.Text = "";
             newpwd_text2.Text = "";
             oldpwd_text.Focus();
         }
     }
     else
     {
         MessageBox.Show("密码错误!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         oldpwd_text.Text  = "";
         newpwd_text1.Text = "";
         newpwd_text2.Text = "";
         oldpwd_text.Focus();
     }
 }
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (radioButton_Class.Checked == true)
     {
         #region 班级删除操作
         int select_n = 0;
         for (int i = 0; i < dataGridView1.Rows.Count; i++)    //循环遍历DataGridView控件中的每一行
         {
             if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时
             {
                 //当该行处于选定状态时
                 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true)
                 {
                     select_n++;
                 }
             }
         }
         if (select_n == 0)
         {
             MessageBox.Show("请勾选操作项!");
         }
         else
         {
             if (MessageBox.Show("确定要删除所选班级和班级内的实验报告吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) //判断是否在弹出的对话框中单击"确定"按钮
             {
                 for (int i = 0; i < dataGridView1.Rows.Count; i++)                                                                     //循环遍历DataGridView控件中的每一行
                 {
                     try
                     {
                         if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时
                         {
                             //当该行处于选定状态时
                             if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true)
                             {
                                 string classname = dataGridView1.Rows[i].Cells[2].Value.ToString();                    //获取操作的班级名
                                 dataGridView1.Rows.RemoveAt(i);                                                        //移除处于选定状态的记录
                                 MyClass.getsqlcom("Delete from tb_Report where class='" + classname.ToString() + "'"); //执行SQL语句,删除班级内的报告
                                 MyClass.getsqlcom("Delete from tb_Class where name='" + classname.ToString() + "'");   //执行SQL语句,删除班级
                                 //MyClass.getsqlcom("Delete from tb_Picture AS e INNER JOIN tb_Experiment AS s ON e.IDE=s.IDE where (s.IDC='" + idc.ToString() + "')");   //执行SQL语句,删除章节内报告的图片
                                 i--;                                                                                   //不改变循环变量的i的值
                             }
                         }
                     }
                     catch (Exception ex)             //捕获异常
                     {
                         MessageBox.Show(ex.Message); //弹出异常提示信息
                     }
                 }
                 MessageBox.Show("删除成功!", "操作", MessageBoxButtons.OK, MessageBoxIcon.Information); //显示消息
                 DataInit_Class();                                                                 //刷新页面
             }
         }
         #endregion
     }
     else
     {
         if (radioButton_Stu.Checked == true)
         {
             #region 学生删除操作
             int select_n = 0;
             for (int i = 0; i < dataGridView1.Rows.Count; i++)    //循环遍历DataGridView控件中的每一行
             {
                 if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时
                 {
                     //当该行处于选定状态时
                     if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true)
                     {
                         select_n++;
                     }
                 }
             }
             if (select_n == 0)
             {
                 MessageBox.Show("请勾选操作项!");
             }
             else
             {
                 if (MessageBox.Show("确定要删除所选学生和该学生的实验报告吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) //判断是否在弹出的对话框中单击"确定"按钮
                 {
                     for (int i = 0; i < dataGridView1.Rows.Count; i++)                                                                     //循环遍历DataGridView控件中的每一行
                     {
                         try
                         {
                             if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时
                             {
                                 //当该行处于选定状态时
                                 if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true)
                                 {
                                     string ids = dataGridView1.Rows[i].Cells[1].Value.ToString();                   //获取操作的学生号
                                     dataGridView1.Rows.RemoveAt(i);                                                 //移除处于选定状态的记录
                                     MyClass.getsqlcom("Delete from tb_Report where IDS='" + ids.ToString() + "'");  //执行SQL语句,删除学生的报告
                                     MyClass.getsqlcom("Delete from tb_Picture IDS='" + ids.ToString() + "')");      //执行SQL语句,删除学生报告内的图片
                                     MyClass.getsqlcom("Delete from tb_Student where IDS='" + ids.ToString() + "'"); //执行SQL语句,删除学生
                                     i--;                                                                            //不改变循环变量的i的值
                                 }
                             }
                         }
                         catch (Exception ex)             //捕获异常
                         {
                             MessageBox.Show(ex.Message); //弹出异常提示信息
                         }
                     }
                     MessageBox.Show("删除成功!", "操作", MessageBoxButtons.OK, MessageBoxIcon.Information); //显示消息
                     DataInit_Stu();                                                                   //刷新页面
                 }
             }
             #endregion
         }
         else
         {
             if (radioButton_Tea.Checked == true)
             {
                 #region 教师删除操作
                 int select_n = 0;
                 for (int i = 0; i < dataGridView1.Rows.Count; i++)    //循环遍历DataGridView控件中的每一行
                 {
                     if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时
                     {
                         //当该行处于选定状态时
                         if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true)
                         {
                             select_n++;
                         }
                     }
                 }
                 if (select_n == 0)
                 {
                     MessageBox.Show("请勾选操作项!");
                 }
                 else
                 {
                     if (MessageBox.Show("确定要删除所选教师和该教师的实验吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) //判断是否在弹出的对话框中单击"确定"按钮
                     {
                         for (int i = 0; i < dataGridView1.Rows.Count; i++)                                                                   //循环遍历DataGridView控件中的每一行
                         {
                             try
                             {
                                 if (dataGridView1.Rows[i].Cells[0].Value != null) //当当前单元格的内容不为空时
                                 {
                                     //当该行处于选定状态时
                                     if (bool.Parse(dataGridView1.Rows[i].Cells[0].Value.ToString()) == true)
                                     {
                                         string idt = dataGridView1.Rows[i].Cells[1].Value.ToString();                      //获取操作的学生号
                                         dataGridView1.Rows.RemoveAt(i);                                                    //移除处于选定状态的记录
                                         MyClass.getsqlcom("Delete from tb_Experiment where IDT='" + idt.ToString() + "'"); //执行SQL语句,删除教师的实验
                                         MyClass.getsqlcom("Delete from tb_Teacher where IDT='" + idt.ToString() + "'");    //执行SQL语句,删除教师
                                         i--;                                                                               //不改变循环变量的i的值
                                     }
                                 }
                             }
                             catch (Exception ex)             //捕获异常
                             {
                                 MessageBox.Show(ex.Message); //弹出异常提示信息
                             }
                         }
                         MessageBox.Show("删除成功!", "操作", MessageBoxButtons.OK, MessageBoxIcon.Information); //显示消息
                         DataInit_Tea();                                                                   //刷新页面
                     }
                 }
                 #endregion
             }
         }
     }
 }
Example #20
0
        //bug:好像必须改名字才能存到数据库,且不能重名
        private void treeViewFolder_AfterLabelEdit(object sender, NodeLabelEditEventArgs e)
        {
            string time = DateTime.Now.ToString();

            MyMeans.getsqlcom("insert into tbl_folder(foldername,buildtime) values('" + e.Label + "','" + time + "')");
        }