📄 form_st.cs
字号:
case "难":
dif = '3';
this.sqlcmd_st.Parameters.Add("@que_difficulty",System.Data.SqlDbType.Char);
this.sqlcmd_st.Parameters["@que_difficulty"].Value = dif;
break;
}
//if(txt_gtfz.Text !="")
//{
try
{
this.sqlcmd_st.Parameters.Add("@que_score",System.Data.SqlDbType.Float);
this.sqlcmd_st.Parameters["@que_score"].Value = System.Single.Parse(this.txt_gtfz.Text);
}
catch
{
MessageBox.Show("分值不能为字符","阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
txt_gtfz.Text = "";
}
//}
//else
//{
//MessageBox.Show("分值不能为空","阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
//}
//if(txt_stnr.Text !="")
//{
this.sqlcmd_st.Parameters.Add("@que_content",System.Data.SqlDbType.Text);
this.sqlcmd_st.Parameters["@que_content"].Value = this.txt_stnr.Text;
//}
//else
//{
//MessageBox.Show("试题内容不能为空","阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
//}
if(ofd_fjtp.FileName != "")
{
System.IO.FileStream fs = new System.IO.FileStream(ofd_fjtp.FileName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
byte[] by = new byte[fs.Length];
fs.Read(by,0,(int)fs.Length);
fs.Close();
this.sqlcmd_st.Parameters.Add("@que_picture",System.Data.SqlDbType.Image);
this.sqlcmd_st.Parameters["@que_picture"].Value = by;
}
else
{
byte[] by = new byte[0];
this.sqlcmd_st.Parameters.Add("@que_picture",System.Data.SqlDbType.Image);
this.sqlcmd_st.Parameters["@que_picture"].Value = by;
}
try
{
sqlcmd_stc.CommandText = "SELECT getdate()";
sqldpt_st.SelectCommand = sqlcmd_stc;
if(dst_st.Tables.IndexOf("mdate") !=-1)
{
dst_st.Tables["mdate"].Clear();
}
this.sqlcnt_st.Open();
sqldpt_st.Fill(dst_st,"mdata");
this.sqlcnt_st.Close();
this.sqlcmd_st.Parameters.Add("@que_modifytime",System.Data.SqlDbType.DateTime);
string mdata = this.dst_st.Tables["mdata"].Rows[0][0].ToString();
this.sqlcmd_st.Parameters["@que_modifytime"].Value = System.Convert.ToDateTime(mdata);
}
catch(System.Exception mess)
{
MessageBox.Show(mess.Message,"阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
//this.sqlcnt_st.Close();
}
this.sqlcmd_st.Parameters.Add("@que_no",System.Data.SqlDbType.Int);
this.sqlcmd_st.Parameters["@que_no"].Value = this.dst_st.Tables["Question"].Rows[this.dgd_st.CurrentRowIndex]["que_no"];
this.sqlcnt_st.Open();
this.sqlcmd_st.ExecuteNonQuery();
this.sqlcnt_st.Close();
if(this.dst_st.Tables.IndexOf("Question") != -1)
{
this.dst_st.Tables["Question"].Clear();
}
sqlcmd_stc = sqlcnt_st.CreateCommand();
sqlcmd_stc.CommandText = "SELECT cou_no,teau_no,que_no,que_type=(case que_type when 1 then '单选' " +
"when 2 then '多选' end),que_score,que_difficulty=(case que_difficulty when 1 then '易' when 2 then '中' "+
"when 3 then '难' end),que_picture,que_content,que_createtime,que_modifytime,que_memo FROM Question WHERE teau_no =" + tno;
sqldpt_st.SelectCommand = sqlcmd_stc;
sqlcnt_st.Open();
sqldpt_st.Fill(dst_st,"Question");
sqlcnt_st.Close();
//this.dgd_st.UnSelect(this.dgd_st.CurrentRowIndex);
//this.dgd_st.CurrentRowIndex = 0;
//this.dgd_st.Select(0);
bl_qx = 0;
}
catch(System.Exception mess)
{
MessageBox.Show(mess.Message,"阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
sqlcnt_st.Close();
}
this.cbb_nd.Enabled = false;
this.cbb_stlx.Enabled = false;
this.txt_gtfz.Enabled = false;
this.txt_stnr.Enabled = false;
this.btn_tj.Enabled = true;
this.btn_xg.Enabled = true;
this.btn_sc.Enabled = true;
this.btn_fjtp.Enabled = false;
bl_qx = 0;
}
}
private void btn_sc_Click(object sender, System.EventArgs e)
{
DialogResult result=MessageBox.Show("确定要删除记录吗?","阜和教育课程体系试题库系统提示",MessageBoxButtons.YesNo,MessageBoxIcon.Question);
if(result == DialogResult.Yes)
{
try
{
sqlcmd_stc = sqlcnt_st.CreateCommand();
sqlcmd_stc.CommandText = "DELETE FROM Question WHERE que_no = @que_no";
this.sqlcmd_stc.Parameters.Add("@que_no",System.Data.SqlDbType.Int);
this.sqlcmd_stc.Parameters["@que_no"].Value = this.dst_st.Tables["Question"].Rows[this.dgd_st.CurrentRowIndex]["que_no"];
this.sqlcnt_st.Open();
this.sqlcmd_stc.ExecuteNonQuery();
this.sqlcnt_st.Close();
if(this.dst_st.Tables.IndexOf("Question") != -1)
{
this.dst_st.Tables["Question"].Clear();
}
sqlcmd_stc.CommandText = "SELECT cou_no,teau_no,que_no,que_type=(case que_type when 1 then '单选' " +
"when 2 then '多选' end),que_score,que_difficulty=(case que_difficulty when 1 then '易' when 2 then '中' "+
"when 3 then '难' end),que_picture,que_content,que_createtime,que_modifytime,que_memo FROM Question WHERE teau_no =" + tno;
sqldpt_st.SelectCommand = sqlcmd_stc;
sqlcnt_st.Open();
sqldpt_st.Fill(dst_st,"Question");
sqlcnt_st.Close();
//this.dgd_st.UnSelect(this.dgd_st.CurrentRowIndex);
//this.dgd_st.CurrentRowIndex = 0;
//this.dgd_st.Select(0);
}
catch//(System.Exception mass)
{
MessageBox.Show("答案有相关联的数据,请确认后删除","阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
sqlcnt_st.Close();
if(this.dst_st.Tables.IndexOf("Question") != -1)
{
this.dst_st.Tables["Question"].RejectChanges();
}
}
}
}
private void btn_xg_Click(object sender, System.EventArgs e)
{
try
{
if(bl_qx == 0)
{
this.txt_gtfz.Enabled = true;
this.txt_stnr.Enabled = true;
this.cbb_nd.Enabled = true;
this.cbb_stlx.Enabled = true;
this.btn_tj.Enabled = false;
this.btn_fjtp.Enabled = true;
this.btn_xg.Enabled = false;
bl_qx = 2;
}
else
{
this.sqlcmd_st = this.sqlcnt_st.CreateCommand();
this.sqlcmd_st.CommandType = System.Data.CommandType.StoredProcedure;
this.sqlcmd_st.CommandText = "UpdateQuestion";
if(cbb_stlx.Text == "单选")
{
char typ = '1';
this.sqlcmd_st.Parameters.Add("@que_type",System.Data.SqlDbType.Char);
this.sqlcmd_st.Parameters["@que_type"].Value = typ;
}
else
{
char typ = '2';
this.sqlcmd_st.Parameters.Add("@que_type",System.Data.SqlDbType.Char);
this.sqlcmd_st.Parameters["@que_type"].Value = typ;
}
switch (cbb_nd.Text)
{
case "易":
char dif = '1';
this.sqlcmd_st.Parameters.Add("@que_difficulty",System.Data.SqlDbType.Char);
this.sqlcmd_st.Parameters["@que_difficulty"].Value = dif;
break;
case "中":
dif = '2';
this.sqlcmd_st.Parameters.Add("@que_difficulty",System.Data.SqlDbType.Char);
this.sqlcmd_st.Parameters["@que_difficulty"].Value = dif;
break;
case "难":
dif = '3';
this.sqlcmd_st.Parameters.Add("@que_difficulty",System.Data.SqlDbType.Char);
this.sqlcmd_st.Parameters["@que_difficulty"].Value = dif;
break;
}
//if(txt_gtfz.Text !="")
//{
//try
//{
this.sqlcmd_st.Parameters.Add("@que_score",System.Data.SqlDbType.Float);
this.sqlcmd_st.Parameters["@que_score"].Value = System.Single.Parse(this.txt_gtfz.Text);
//}
//catch
//{
//MessageBox.Show("分值不能为字符","阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
//txt_gtfz.Text = "";
//}
//}
//else
//{
//MessageBox.Show("分值不能为空","阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
//}
//if(txt_stnr.Text !="")
//{
this.sqlcmd_st.Parameters.Add("@que_content",System.Data.SqlDbType.Text);
this.sqlcmd_st.Parameters["@que_content"].Value = this.txt_stnr.Text;
//}
//else
//{
MessageBox.Show("试题内容不能为空","阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
//}
if(ofd_fjtp.FileName != "")
{
System.IO.FileStream fs = new System.IO.FileStream(ofd_fjtp.FileName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
byte[] by = new byte[fs.Length];
fs.Read(by,0,(int)fs.Length);
fs.Close();
this.sqlcmd_st.Parameters.Add("@que_picture",System.Data.SqlDbType.Image);
this.sqlcmd_st.Parameters["@que_picture"].Value = by;
}
else
{
byte[] by = new byte[0];
this.sqlcmd_st.Parameters.Add("@que_picture",System.Data.SqlDbType.Image);
this.sqlcmd_st.Parameters["@que_picture"].Value = by;
}
try
{
sqlcmd_stc.CommandText = "SELECT getdate()";
sqldpt_st.SelectCommand = sqlcmd_stc;
if(dst_st.Tables.IndexOf("mdate") !=-1)
{
dst_st.Tables["mdate"].Clear();
}
this.sqlcnt_st.Open();
sqldpt_st.Fill(dst_st,"mdata");
this.sqlcnt_st.Close();
this.sqlcmd_st.Parameters.Add("@que_modifytime",System.Data.SqlDbType.DateTime);
string mdata = this.dst_st.Tables["mdata"].Rows[0][0].ToString();
this.sqlcmd_st.Parameters["@que_modifytime"].Value = System.Convert.ToDateTime(mdata);
}
catch(System.Exception mess)
{
MessageBox.Show(mess.Message,"阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
//this.sqlcnt_st.Close();
}
this.sqlcmd_st.Parameters.Add("@que_no",System.Data.SqlDbType.Int);
this.sqlcmd_st.Parameters["@que_no"].Value = this.dst_st.Tables["Question"].Rows[this.dgd_st.CurrentRowIndex]["que_no"];
this.sqlcnt_st.Open();
this.sqlcmd_st.ExecuteNonQuery();
this.sqlcnt_st.Close();
if(this.dst_st.Tables.IndexOf("Question") != -1)
{
this.dst_st.Tables["Question"].Clear();
}
sqlcmd_stc = sqlcnt_st.CreateCommand();
sqlcmd_stc.CommandText = "SELECT cou_no,teau_no,que_no,que_type=(case que_type when 1 then '单选' " +
"when 2 then '多选' end),que_score,que_difficulty=(case que_difficulty when 1 then '易' when 2 then '中' "+
"when 3 then '难' end),que_picture,que_content,que_createtime,que_modifytime,que_memo FROM Question WHERE teau_no =" + tno;
sqldpt_st.SelectCommand = sqlcmd_stc;
sqlcnt_st.Open();
sqldpt_st.Fill(dst_st,"Question");
sqlcnt_st.Close();
//this.dgd_st.UnSelect(this.dgd_st.CurrentRowIndex);
//this.dgd_st.CurrentRowIndex = 0;
//this.dgd_st.Select(0);
//this.dst_st.Tables["Question"].AcceptChanges();
this.txt_gtfz.Enabled = true;
this.txt_stnr.Enabled = true;
}
}
catch(System.Exception mess)
{
MessageBox.Show(mess.Message,"阜和教育课程体系试题库系统提示",MessageBoxButtons.OK);
sqlcnt_st.Close();
}
}
private void cbb_jxdy_SelectionChange(object sender, System.EventArgs e)
{
if(dst_st.Tables.IndexOf("Question") !=-1)
{
dst_st.Tables["Question"].Clear();
this.btn_tj.Enabled = false;
this.btn_sc.Enabled = false;
this.cbb_nd.Enabled = false;
this.cbb_stlx.Enabled = false;
this.txt_gtfz.Enabled = false;
this.txt_stnr.Enabled = false;
this.btn_xg.Enabled = false;
this.btn_fjtp.Enabled = false;
this.btn_qyjl.Enabled = false;
this.btn_hyjl.Enabled = false;
this.btn_sjl.Enabled = false;
this.btn_mjl.Enabled = false;
this.btn_qrtj.Enabled = false;
this.btn_qx.Enabled = false;
}
string jname = cbb_jxdy.GetItemText(cbb_jxdy.SelectedItem);
foreach(DataRow datar in dst_st.Tables["teachingUnit"].Rows)
{
if(datar["teau_name"].ToString() == jname)
{
jno = datar["teau_no"].ToString();
break;
}
}
this.btn_cx.Enabled = true;
bl_qx = 0;
}
private void dgd_st_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
//Point pt = new Point(e.X,e.Y);
//DataGrid.HitTestInfo hit = dgd_st.HitTest(pt);
//if(hit.Type == DataGrid.HitTestType.Cell)
//{
//this.dgd_st.UnSelect(0);
if(e.Button == System.Windows.Forms.MouseButtons.Left)
{
if(this.dgd_st.CurrentRowIndex != -1)
{
dgd_st.Select(this.dgd_st.CurrentRowIndex);
//this.dgd_st.CurrentRowIndex = hit.Row;
try
{
byte[] by = (byte[])this.dst_st.Tables["Question"].Rows[this.dgd_st.CurrentRowIndex]["que_picture"];
System.IO.MemoryStream ms = new System.IO.MemoryStream(by);
//ofd_fjtp.ShowDialog();
Image img = Image.FromStream(ms); //Image.FromFile(ofd_fjtp.FileName);
this.pcb_yltp.Image = img.GetThumbnailImage(this.pcb_yltp.Width,this.pcb_yltp.Height,null,IntPtr.Zero);
}
catch
{
this.pcb_yltp.Image = null;
}
//}
if(bl_qx != 0)
{
if(this.dst_st.Tables.IndexOf("Question") != -1)
{
this.dst_st.Tables["Question"].RejectChanges();
}
this.btn_tj.Enabled = true;
this.btn_sc.Enabled = true;
this.cbb_nd.Enabled = false;
this.cbb_stlx.Enabled = false;
this.txt_gtfz.Enabled = false;
this.txt_stnr.Enabled = false;
this.btn_sc.Enabled = true;
this.btn_fjtp.Enabled = false;
bl_qx = 0;
}
}
}
}
private void dgd_st_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
{
}
/// <summary>
/// 应用程序的主入口点。
/// </summary>
//[STAThread]
//static void Main()
//{
// Application.Run(new Form_st());
//}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -