示例#1
0
 //保存按钮(学生)--差导入成绩
 private void btn_keep_stu_Click(object sender, EventArgs e)
 {
     if (TB_stu_ID.Text.Trim() == "" || TB_stu_name.Text.Trim() == "" || TB_stu_enter.Text.Trim() == "")
     {
         MessageBox.Show("请将信息填写完整", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     else
     {
         string str = "select count(*) from student where stu_ID='" + TB_stu_ID.Text.Trim() + "'";
         int    i   = operate.HumanNum(str);
         try
         {
             string strsql = "INSERT INTO [dbo].[student] ([stu_id],[stu_class],[stu_name],[stu_sex],[stu_birthday],[stu_MCCP],[stu_Enterscore],[stu_nativeplace]) VALUES ('" + TB_stu_ID.Text.ToString() + "','" + CBB_stu_class.Text.ToString() + "','" + TB_stu_name.Text.ToString() + "','" + CBB_stu_sex.Text.ToString() + "','" + Time_stu_birth.Value.ToString("yyyy年MM月d日") + "','" + CBB_stu_MCCP.Text.ToString() + "','" + TB_stu_enter.Text.ToString() + "','" + CBB_stu_nation.Text.ToString() + "')";
             int    num    = operate.OperateData(strsql);
             operate.StuSaveImages(TB_stu_ID.Text.Trim(), openFileDialog1);
             string time = DateTime.Now.ToString(); //获取当前系统事件字符串
             string sql  = "insert into wang_User values('" + TB_stu_ID.Text.ToString() + "','" + password + "','" + "学生" + "','" + time + "')";
             operate.OperateData(sql);              //更新数据库内容
             if (num > 0)
             {
                 //添加控的成绩信息
                 string sqlstr = "INSERT into [dbo].[SC_result] ([Stu_Id],[Cour_Id],[Cour_Name]) select distinct '" + TB_stu_ID.Text.ToString() + "',Coures.Cour_Id,Coures.Cour_Name from Student join SC_result on SC_result.Stu_Id=Student.stu_id join Coures on Coures.Cour_Id=Coures.Cour_Id where Student.stu_class='" + CBB_stu_class.Text.ToString() + "'";
                 operate.OperateData(sqlstr);         //更新数据库内容
                 FormCheckuser_Z_score ee = new FormCheckuser_Z_score();
                 ee.XTID = TB_stu_ID.Text.ToString(); //传值给成绩录入表
                 ee.ShowDialog();
                 //打开成绩录入对话框
             }
         }
         catch
         {
             MessageBox.Show("填写信息有误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
 }