//保存按钮(老师) private void btn_keep_tea_Click(object sender, EventArgs e) { if (TB_tea_ID.Text.Trim() == "" || TB_tea_name.Text.Trim() == "" || TB_tea_pay.Text.Trim() == "" || TB_tea_phone.Text.Trim() == "") { MessageBox.Show("请将信息填写完整", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (TB_tea_phone.Text.Length != 11) { MessageBox.Show("手机号码为11位"); return; } else { try { string strsql = "update [dbo].[Teacher] set [Tea_Name]='" + TB_tea_name.Text.ToString() + "',[Tea_Sex]='" + CBB_tea_sex.Text.ToString() + "',[Tea_Dept]='" + CBB_tea_dept.Text.ToString() + "',[Tea_Birthday]='" + Time_tea_birth.Value.ToString("yyyy年MM月d日") + "',[Tea_Nation]='" + CBB_tea_nation.Text.ToString() + "',[Tea_Marriage]='" + CBB_tea_marry.Text.ToString() + "',[Tea_MCCP]='" + CBB_tea_MCCP.Text.ToString() + "',[Tea_Phone]='" + TB_tea_phone.Text.ToString() + "',[Tea_Accession]='" + Time_tea_enter.Value.ToString("yyyy年MM月d日") + "',[Tea_Pay]='" + TB_tea_pay.Text.ToString() + "' where [Tea_Id]='" + TB_tea_ID.Text.ToString() + "' "; int num = operate.OperateData(strsql); operate.TeaSaveImages(this.TB_tea_ID.Text.Trim(), openFileDialog1); if (num > 0) { MessageBox.Show("教师信息修改成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception) { MessageBox.Show("你的输入有误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }
//保存按钮(老师) private void btn_keep_tea_Click(object sender, EventArgs e) { if (TB_tea_ID.Text.Trim() == "" || TB_tea_name.Text.Trim() == "" || TB_tea_pay.Text.Trim() == "" || TB_tea_phone.Text.Trim() == "") { MessageBox.Show("请将信息填写完整", "警告", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { if (TB_tea_phone.Text.Length != 11) { MessageBox.Show("手机号码为11位"); return; } else { try { string strsql = "INSERT INTO [dbo].[Teacher] ([Tea_Id],[Tea_Name],[Tea_Sex],[Tea_Dept],[Tea_Birthday],[Tea_Nation],[Tea_Marriage],[Tea_MCCP],[Tea_Phone],[Tea_Accession],[Tea_Pay]) VALUES ('" + TB_tea_ID.Text.ToString() + "','" + TB_tea_name.Text.ToString() + "','" + CBB_tea_sex.Text.ToString() + "','" + CBB_tea_dept.Text.ToString() + "','" + Time_tea_birth.Value.ToString("yyyy年MM月d日") + "','" + CBB_tea_nation.Text.ToString() + "','" + CBB_tea_marry.Text.ToString() + "','" + CBB_tea_MCCP.Text.ToString() + "','" + TB_tea_phone.Text.ToString() + "','" + Time_tea_enter.Value.ToString("yyyy年MM月d日") + "','" + TB_tea_pay.Text.ToString() + "')"; int num = operate.OperateData(strsql); operate.TeaSaveImages(this.TB_tea_ID.Text.Trim(), openFileDialog1); //同时创建一个新的教师登录账户(密码默认为123456) string time = DateTime.Now.ToString(); //获取当前系统事件字符串 string sql = "insert into wang_User values('" + TB_tea_ID.Text.ToString() + "','" + password + "','" + "教师" + "','" + time + "')"; operate.OperateData(sql); //更新数据库内容 if (num > 0) { MessageBox.Show("教师信息添加成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } } catch (Exception) { MessageBox.Show("填写信息有误", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } }