Exemple #1
0
 /// <summary>
 /// 添加老师
 /// </summary>
 /// <param name="teacherInf">老师实体</param>
 /// <returns></returns>
 public int AddTeacher(TeacherInf teacherInf)
 {
     SqlParameter[] parms =
     {
         MakeInParm(TE_ID,          SqlDbType.VarChar,   20, teacherInf.Te_Id),
         MakeInParm(DP_ID,          SqlDbType.Char,       2, teacherInf.Dp_Id),
         MakeInParm(LG_NAME,        SqlDbType.VarChar,   10, teacherInf.Te_Learngrade),
         MakeInParm(ZC_NAME,        SqlDbType.VarChar,   10, teacherInf.Te_ZhiCheng),
         MakeInParm(TE_NAME,        SqlDbType.VarChar,   10, teacherInf.Te_Name),
         MakeInParm(TE_SEX,         SqlDbType.Char,       2, teacherInf.Te_Sex),
         MakeInParm(TE_IDENTITY,    SqlDbType.Char,      18, teacherInf.Te_Identity),
         MakeInParm(TE_SPECIALITY,  SqlDbType.VarChar,   20, teacherInf.Te_Speciality),
         MakeInParm(TE_ADDRESS,     SqlDbType.VarChar,   50, teacherInf.Te_Address),
         MakeInParm(TE_ZZFACE,      SqlDbType.Char,      20, teacherInf.Te_ZZFace),
         MakeInParm(TE_MINZU,       SqlDbType.Char,      16, teacherInf.Te_MinZu),
         MakeInParm(TE_TEL,         SqlDbType.Char,      11, teacherInf.Te_Tel),
         MakeInParm(TE_BIRTIDAY,    SqlDbType.DateTime,   0, teacherInf.Te_Birthday),
         MakeInParm(TE_TEACHERTIME, SqlDbType.DateTime,   0, teacherInf.Te_Teachtime),
         MakeInParm(TE_PROVINCE,    SqlDbType.VarChar,   16, teacherInf.Te_Province),
         MakeInParm(TE_REMARK,      SqlDbType.VarChar,  600, teacherInf.Te_Remark)
     };
     try
     {
         return(ExecProc("AddTeacer", parms));
     }
     catch
     {
         return(0);
     }
 }
    protected void btnAddTeacher_Click(object sender, EventArgs e)
    {
        DateTime te_Birthday;
        DateTime te_Teachtime;

        try
        {
            te_Birthday  = Convert.ToDateTime(txtBirthday.Text);
            te_Teachtime = Convert.ToDateTime(txtWorkTime.Text);
            TeacherInf teacherInf = new TeacherInf(txtTeacherNumber.Text, txtTeacherName.Text, ddlDepartment.SelectedValue, ddlSex.SelectedValue, txtIdentity.Text, txtSpeciality.Text, ddlXueLi.SelectedItem.Text, ddlZhiCheng.SelectedItem.Text, ddlFace.SelectedItem.Text, txtTel.Text, te_Birthday, te_Teachtime, txtHomeAddress.Text, ddlProvince.SelectedItem.Text, ddlMingZu.SelectedItem.Text, txtRemark.Text);
            teacher.AddTeacher(teacherInf);
        }
        catch
        {
            JScript.AlertAndRedirect("时间格式错误!请重新输入", "AddTeacher.aspx");
        }
    }
Exemple #3
0
        public void AddTeacher(TeacherInf teacherInf)
        {
            int result = teacher.AddTeacher(teacherInf);

            switch (result)
            {
            case 1: JScript.AlertAndRedirect("添加成功!", "AddTeacher.aspx");
                break;

            case 0: JScript.Alert("添加失败!请重试!");
                JScript.GoHistory(-1);
                break;

            case -2: JScript.Alert("教师编号已存在,请换其他编号");
                JScript.GoHistory(-1);
                break;
            }
        }