Пример #1
0
 public TeacherAdd(Teacher th)
 {
     InitializeComponent();
     currentTeacher = th;
     radioUser.Checked = true;
     if (currentTeacher != null)
     {
         textUserName.Text = currentTeacher.UserName;
         textName.Text = currentTeacher.TeacherName;
         if (currentTeacher.permission == 0)
             radioUser.Checked = true;
         else
             radioAdmin.Checked = true;
         btnAdd.Text = "保存修改";
         labelPW.Text = "(若不修改密码,此项请留空)";
     }
 }
Пример #2
0
 //-- Description:	查找Teacher的所有信息,通过Teacher的LoginName
 public Teacher FindTeacherByLoginName(string UserName)
 {
     Teacher teacher = new Teacher();
     List<SqlParameter> ddlparam = new List<SqlParameter>();
     ddlparam.Add(CreateParam("@UserName", SqlDbType.VarChar, 50, UserName, ParameterDirection.Input));
     Ds = new DataSet();
     RunProc("FindTeacherByLoginName", ddlparam, Ds);
     teacher = DataSetToTeacher(Ds);
     return teacher;
 }
Пример #3
0
        private List<Teacher> DataSetToTeacherList(DataSet p_DataSet)
        {
            List<Teacher> result = new List<Teacher>();
            DataTable p_Data = p_DataSet.Tables[0];

            for (int j = 0; j < p_Data.Rows.Count; j++)
            {
                Teacher th = new Teacher();
                for (int i = 0; i < p_Data.Columns.Count; i++)
                {
                    // 数据库NULL值单独处理
                    if (p_Data.Columns[i].ToString() == "TeacherId")
                        th.Id = Convert.ToInt32(p_Data.Rows[j][i]);
                    if (p_Data.Columns[i].ToString() == "TeacherName")
                        th.TeacherName = (string)p_Data.Rows[j][i];
                    if (p_Data.Columns[i].ToString() == "Password")
                        th.password = (string)p_Data.Rows[j][i];
                    if (p_Data.Columns[i].ToString() == "Permission")
                        th.permission = (int)p_Data.Rows[j][i];
                    if (p_Data.Columns[i].ToString() == "UserName")
                        th.UserName = (string)p_Data.Rows[j][i];

                }

                result.Add(th);
            }
            return result;
        }
Пример #4
0
        //private List<Paper> DataSetToListPaper2(DataSet p_DataSet)
        //{
        //    List<Paper> result = new List<Paper>();
        //    DataTable p_Data = p_DataSet.Tables[0];
        //    for (int j = 0; j < p_Data.Rows.Count; j++)
        //    {
        //        Paper problem = new Paper();
        //        for (int i = 0; i < p_Data.Columns.Count; i++)
        //        {
        //            // 数据库NULL值单独处理
        //            if (p_Data.Columns[i].ToString() == "Id")
        //                problem.paperID = (int)p_Data.Rows[j][i];
        //            if (p_Data.Columns[i].ToString() == "Title")
        //                problem.paperName = (string)p_Data.Rows[j][i];
        //        }
        //        result.Add(problem);
        //    }
        //    return result;
        //}
        private Teacher DataSetToTeacher(DataSet p_DataSet)
        {
            Teacher problem = new Teacher();
            DataTable p_Data = p_DataSet.Tables[0];
            if (p_Data.Rows.Count < 1)
            {
                return null;
            }
            for (int i = 0; i < p_Data.Columns.Count; i++)
            {
                // 数据库NULL值单独处理
                if (p_Data.Columns[i].ToString() == "Id")
                    problem.Id = Convert.ToInt32(p_Data.Rows[0][i]);
                if (p_Data.Columns[i].ToString() == "TeacherName")
                    problem.TeacherName = (string)p_Data.Rows[0][i];
                if (p_Data.Columns[i].ToString() == "Password")
                    problem.password = p_Data.Rows[0][i].ToString();
                if (p_Data.Columns[i].ToString() == "Permission")
                    problem.permission = (int)p_Data.Rows[0][i];
                if (p_Data.Columns[i].ToString() == "UserName")
                    problem.UserName = (string)p_Data.Rows[0][i];

            }
            return problem;
        }
Пример #5
0
 private void btnEdit_Click(object sender, EventArgs e)
 {
     int cr = teacherInfoDGV.CurrentRow.Index;
     if (cr <= -1)  { return; }
     changeBtnEnable(false);
     teacherInfoDGV.Visible = false;
     teacherInfoGroup.Text = "修改教师";
     int permission = dt.Rows[cr][5].ToString().Equals("超级管理员") ? 1 : 0;
     Teacher th = new Teacher(Convert.ToInt32(dt.Rows[cr][1]), dt.Rows[cr][2].ToString(),
         dt.Rows[cr][3].ToString(), dt.Rows[cr][4].ToString(), permission);
     teaAdd = new TeacherAdd(th);
     teaAdd.Disposed += new EventHandler(teacherOperation_Disposed);
     teacherInfoGroup.Controls.Add(teaAdd);
     teaAdd.Dock = DockStyle.Fill;
 }