예제 #1
0
 private void 个人信息修改ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (common.ID == "0")
     {
         Form_information_admin frm = new Form_information_admin();
         frm.MdiParent = this;
         frm.Show();
     }
     else
     {
         if (common.ID == "1")
         {
             Form_information_teacher frm = new Form_information_teacher();
             string            sql        = "select tno,tname,tposition,tsalary,pwd from teacher where tno like :tno";
             OracleParameter[] para       = new OracleParameter[] { new OracleParameter(":cname", OracleDbType.Char, 40) };
             para[0].Value = common.Name;
             //创建链接,打开连接,创建命令对象,执行命令,关闭连接
             OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["strCon"].ConnectionString);
             try
             {
                 con.Open();
                 OracleCommand cmd = new OracleCommand(sql, con);
                 cmd.Parameters.AddRange(para);
                 OracleDataReader odr = cmd.ExecuteReader();
                 while (odr.Read())
                 {
                     teacher t = new teacher();
                     //c.Cno = odr.GetString(0); //ord["cno'].
                     t.tno   = odr["tno"].ToString();
                     t.tname = odr.GetString(1);
                     //c.Cpno = odr.GetString(2);
                     t.tposition = odr.GetString(2);
                     t.tsalary   = odr.GetInt32(3);
                     t.pwd       = odr.GetString(4);
                     //
                     frm.tbtno.Text       = t.tno;
                     frm.tbtname.Text     = t.tname;
                     frm.tbtposition.Text = t.tposition;
                     frm.tbtsalary.Text   = t.tsalary.ToString();
                     frm.tbpwd.Text       = t.pwd;
                     frm.ShowDialog();
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 con.Close();
             }
         }
         else
         {
             //MessageBox.Show("123");
             Form_information_student frm = new Form_information_student();
             string            sql        = "select sno,sname,ssex,sage,pwd from student where sno like :sno";
             OracleParameter[] para       = new OracleParameter[] { new OracleParameter(":cname", OracleDbType.Char, 40) };
             para[0].Value = common.Name;
             //创建链接,打开连接,创建命令对象,执行命令,关闭连接
             OracleConnection con = new OracleConnection(ConfigurationManager.ConnectionStrings["strCon"].ConnectionString);
             try
             {
                 con.Open();
                 OracleCommand cmd = new OracleCommand(sql, con);
                 cmd.Parameters.AddRange(para);
                 OracleDataReader odr = cmd.ExecuteReader();
                 while (odr.Read())
                 {
                     student s = new student();
                     //c.Cno = odr.GetString(0); //ord["cno'].
                     s.sno   = odr["sno"].ToString();
                     s.sname = odr.GetString(1);
                     //c.Cpno = odr.GetString(2);
                     s.ssex = odr.GetString(2);
                     s.sage = odr.GetInt32(3);
                     s.pwd  = odr.GetString(4);
                     //
                     frm.tbsno.Text   = s.sno;
                     frm.tbsname.Text = s.sname;
                     frm.tbssex.Text  = s.ssex;
                     frm.tbsage.Text  = s.sage.ToString();
                     frm.tbpwd.Text   = s.pwd;
                     frm.ShowDialog();
                 }
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 con.Close();
             }
         }
     }
 }