public async Task <IActionResult> Edit(int id, [Bind("id,user_id,salary")] teachers teachers)
        {
            if (id != teachers.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(teachers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!teachersExists(teachers.id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(teachers));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var manager = Context.GetOwinContext().GetUserManager <ApplicationUserManager>();

            if (!IsPostBack)
            {
                // Presentar mensaje de operación correcta
                var message = Request.QueryString["m"];
                if (message != null)
                {
                    // Seccionar la cadena de consulta desde la acción
                    Form.Action = ResolveUrl("~/Account/Manage");
                }

                using (Model1 _db = new Model1())
                {
                    string   id      = User.Identity.GetUserId();
                    teachers teacher = (from Teachers in _db.teachers where Teachers.UserID == id select Teachers).FirstOrDefault();
                    if (teacher != null)
                    {
                        update.Visible   = true;
                        Position.Text    = teacher.Position;
                        Contact.Text     = teacher.Contact;
                        SpanishRole.Text = teacher.SpanishRole;
                        OtherRole.Text   = teacher.OtherRole;
                        SpanishCV.Text   = teacher.SpanishCV;
                        OtherCV.Text     = teacher.OtherRole;
                    }
                    else
                    {
                        create.Visible = true;
                    }
                }
            }
        }
Exemple #3
0
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            using (var db = new CstwebEntities())
            {
                int      id  = Convert.ToInt32(e.CommandArgument);
                teachers tea = db.teachers.FirstOrDefault(a => a.id == id);
                accounts ac  = db.accounts.FirstOrDefault(a => a.teacherid == id);
                db.teachers.Remove(tea);
                db.accounts.Remove(ac);
                db.SaveChanges();
                Response.Write("<script>alert('删除成功');window.location = 'teachers.aspx';</script>");
            }
        }
        else if (e.CommandName == "res")
        {
            using (var db = new CstwebEntities())
            {
                int id = Convert.ToInt32(e.CommandArgument);

                accounts ac = db.accounts.FirstOrDefault(a => a.teacherid == id);
                ac.password = PasswordHash.PasswordHash.CreateHash(ac.account);

                db.SaveChanges();
                Response.Write("<script>alert('重置成功');window.location = 'teachers.aspx';</script>");
            }
        }
    }
 protected void TeacherProfile_Click(object sender, EventArgs e)
 {
     if (IsValid)
     {
         teachers teacher = new teachers
         {
             Position    = Position.Text,
             Contact     = Contact.Text,
             SpanishRole = SpanishRole.Text,
             OtherRole   = OtherRole.Text,
             SpanishCV   = SpanishCV.Text,
             OtherCV     = OtherCV.Text,
             UserID      = User.Identity.GetUserId(),
             TeacherName = User.Identity.GetName() + User.Identity.GetSurname1() + User.Identity.GetSurname2()
         };
         if (Image.HasFile)
         {
             try
             {
                 string fileName = System.IO.Path.GetFileName(Image.FileName);
                 Image.SaveAs(Server.MapPath("Subjects/Images/") + fileName);
                 teacher.Image = fileName;
             }
             catch (Exception ex)
             {
             }
         }
         using (Model1 _db = new Model1())
         {
             _db.teachers.Add(teacher);
             _db.SaveChanges();
             Response.Redirect("~/Account/Manage.aspx?m=TeacherProfSuccess");
         }
     }
 }
Exemple #5
0
        public JsonResult EditCourse(FormCollection collection)
        {
            var teacherArr = JsonConvert.DeserializeObject <List <int> >(collection["teachers"]);

            //If we get sent a course id that doesn't excist we send a Json response saying that the request failed
            if (collection["id"] == null && teacherArr.Count <= 0)
            {
                return(Json(new { status = "failed" }, JsonRequestBehavior.AllowGet));
            }
            int courseid = Convert.ToInt32(collection["id"]);

            var edit = db.courses.Find(courseid);

            db.teachers.RemoveRange(db.teachers.Where(a => a.courseId.Equals(courseid)));

            foreach (int i in teacherArr)
            {
                teachers neu = new teachers {
                    courseId = courseid, userId = i
                };
                db.teachers.Add(neu);
            }



            edit.name            = collection["name"];
            edit.description     = collection["description"];
            db.Entry(edit).State = EntityState.Modified;
            db.SaveChanges();

            return(Json(new { status = "SuccessEdit", userId = courseid }, JsonRequestBehavior.AllowGet));
        }
Exemple #6
0
        public JsonResult AddCourse(FormCollection collection)
        {
            var teacherArr = JsonConvert.DeserializeObject <List <int> >(collection["teachers"]);

            if (teacherArr.Count <= 0 || collection["name"] == null)
            {
                return(Json(new { status = "failed" }, JsonRequestBehavior.AllowGet));
            }

            courses newCourse = new courses {
                name = collection["name"], description = collection["description"]
            };

            db.courses.Add(newCourse);
            db.SaveChanges();
            int courseId = db.courses.Max(a => a.id);

            //here we take all the teachers assigned to this class form a list within the form and add them to the course
            foreach (int i in teacherArr)
            {
                teachers neu = new teachers {
                    courseId = courseId, userId = i
                };
                db.teachers.Add(neu);
            }
            db.SaveChanges();

            account firstTeach = db.account.Find(teacherArr[0]);

            return(Json(new { status = "SuccessAdd", courseid = courseId, teacherImgPath = firstTeach.imagePath, courseName = newCourse.name, courseDesc = newCourse.description, teacherName = firstTeach.name }, JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="effect"></param>
        /// <returns></returns>
        public BaseResult Update(teachers teachers)
        {
            result.code = 0;
            if (teachers.id != 0)
            {
                if (dalTeachers.Update(teachers) == 0)
                {
                    result.code = -1;
                    result.msg  = "修改失败";
                }
                else
                {
                }
            }
            else
            {
                if (dalTeachers.Add(teachers) == 0)
                {
                    result.code = -1;
                    result.msg  = "添加失败";
                }
                else
                {
                }
            }

            return(result);
        }
Exemple #8
0
        private void PopulateMultiview(int id)
        {
            var _db = new Model1();
            //List<Teacher> teachers = _db.Teachers.ToList();
            //foreach (Teacher teacher in teachers)
            //{
            //    View view = new View { ID = "Tab" + (teacher.TeacherID - 1).ToString(), };

            teachers teacher = (from Teachers in _db.teachers where Teachers.TeacherID == id select Teachers).FirstOrDefault();

            content.Text =
                "<h2>" + teacher.Position + "</h2>";
            if (teacher.Image != null)
            {
                content.Text += "<br><div style='float: left;'><img src='Subjects/Images/" + teacher.Image + "' style=' margin-right: 10px'><img></div>";
            }
            content.Text +=
                "<div><h3>Función en el grupo</h3>" +
                "<br><p style='text-align:justify; white - space: pre'>" + teacher.SpanishRole + "</p>" +
                "<p style='text-align:justify; white - space: pre'><i>" + teacher.OtherRole + "</i></p></div>" +
                "<div><h3>CV</h3>" +
                "<br><p style='text-align:justify; white - space: pre'>" + teacher.SpanishCV + "</p>" +
                "<p style='text-align:justify; white - space: pre'><i>" + teacher.OtherCV + "</i></p></div>" +
                "<div><h3>Contacto</h3>" +
                "<br><p style='text-align:justify; white - space: pre'>" + teacher.Contact + "</p></div>";
            //Multiview.Views.Add(view);
            //}
            //Multiview.ActiveViewIndex = 0;
        }
Exemple #9
0
 /// <summary>
 /// 新增
 /// </summary>
 /// <param name="classes"></param>
 /// <returns></returns>
 public int Add(teachers teachers)
 {
     return((int)dbContext.Insert <teachers>(() => new teachers()
     {
         name = teachers.name,
         collegeid = teachers.collegeid
     }));
 }
Exemple #10
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="classes"></param>
 /// <returns></returns>
 public int Update(teachers teachers)
 {
     return(dbContext.Update <teachers>(p => p.id == teachers.id, p => new teachers()
     {
         name = teachers.name,
         collegeid = teachers.collegeid
     }));
 }
 public void DeleteTeacherProfile_Click(object sender, EventArgs e)
 {
     using (Model1 _db = new Model1())
     {
         string   id      = User.Identity.GetUserId();
         teachers teacher = (from Teachers in _db.teachers where Teachers.UserID == id select Teachers).FirstOrDefault();
         _db.teachers.Remove(teacher);
         _db.SaveChanges();
     }
 }
        public async Task <IActionResult> Create([Bind("id,user_id,salary")] teachers teachers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(teachers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(teachers));
        }
        public EditTeacherDataPage(DispatcherWindow ownerWindow, teachers teacher)
        {
            InitializeComponent();

            this.dispatcherWindow = ownerWindow;

            CurrentTeacher       = (teachers)teacher.Clone();
            EditTeacherReference = teacher;

            Positions   = Connection.Database.positions.ToList();
            Ranks       = Connection.Database.ranks.ToList();
            Departments = Connection.Database.departments.ToList();

            DataContext = this;
        }
    protected void btn3_Click(object sender, EventArgs e)
    {
        TeachersManage tm = new TeachersManage();
        teachers       n  = new teachers();

        n.Name      = lbl2.Text;
        n.Post      = Label2.Text;
        n.College   = Label1.Text;
        n.Phone     = txt2.Text;
        n.Email     = txt3.Text;
        n.Modifier  = Session["teacherId"].ToString();
        n.TeacherId = Session["teacherId"].ToString();
        tm.Update(n);
        teacherbind();
    }
        public EditTeacherDataPage(DispatcherWindow ownerWindow)
        {
            InitializeComponent();

            this.dispatcherWindow = ownerWindow;

            CurrentTeacher = new teachers {
                name = "Иванов Иван Иванович"
            };

            Positions   = Connection.Database.positions.ToList();
            Ranks       = Connection.Database.ranks.ToList();
            Departments = Connection.Database.departments.ToList();

            DataContext = this;
        }
    //触发gridview行的更新事件
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridView1.EditIndex = -1;
        teachers    n   = new teachers();
        GridViewRow gvr = GridView1.Rows[e.RowIndex];

        n.TeacherId = GridView1.DataKeys[e.RowIndex].Value.ToString();         //获取当前行主键id
        n.Name      = ((TextBox)gvr.FindControl("txtname")).Text.Trim();
        n.Phone     = ((TextBox)gvr.FindControl("txtphone")).Text.Trim();
        n.College   = ((DropDownList)gvr.FindControl("drppost")).SelectedValue.ToString();
        n.Email     = ((TextBox)gvr.FindControl("txtemail")).Text.Trim();
        n.Post      = ((TextBox)gvr.FindControl("txtpost")).Text.Trim();
        n.Modifier  = Session["adminId"].ToString();
        tm.Update(n);
        gridviewBind();
    }
    protected void btn5_Click(object sender, EventArgs e)
    {
        DataTable dt     = tm.SelectByValue(Session["teacherId"].ToString());
        string    oldPwd = dt.Rows[0]["pwd"].ToString();
        int       tmp    = PwdLevel(txt5.Text);

        if (txt4.Text == oldPwd && tmp >= 2)
        {
            teachers n = new teachers();
            n.TeacherId = Session["teacherId"].ToString();
            n.Modifier  = Session["teacherId"].ToString();
            n.Pwd       = txt6.Text.Trim();
            tm.UpdatePwd(n);
            ScriptManager.RegisterStartupScript(this, this.GetType(), "updateScript", "alert(\"修改成功\");", true);
        }
    }
 public ActionResult Eliminar(int id)
 {
     try
     {
         using (Models.universityEntities db = new Models.universityEntities())
         {
             teachers prof = db.teachers.Find(id);
             db.teachers.Remove(prof);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Se ha producido un error - ", ex.Message);
         return(View());
     }
 }
Exemple #19
0
        static void Main(string[] args)
        {
            CodeAcademy academy = new CodeAcademy();

            teachers teacher_inform = new teachers();

            students student_inform = new students();

            reqtangel req = new reqtangel();

            teacher_inform.old = 35;

            //academy.group_name = "P502";

            academy.type = "development";

            teacher_inform.first_last_name = "Ismayil Ismayilov";

            academy.student_count = 15;

            student_inform.student_group = "P502";

            student_inform.student_name = "Leyla";

            academy.t("test message");

            // Console.WriteLine(academy.t);

            academy.all_inform();


            Console.Write("Eni:");
            req.width = int.Parse(Console.ReadLine());
            Console.WriteLine();
            Console.Write("hundurluyu:");
            req.height = int.Parse(Console.ReadLine());
            req.sahe();
            req.per();


            Console.ReadLine();
        }
        public ActionResult Agregar(teachers a)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (Models.universityEntities db = new Models.universityEntities())
                {
                    db.teachers.Add(a);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Error al agregar profesor - " + ex.Message);
                return(View());
            }
        }
 //新增教师信息
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (!tm.Check(txt1.Text.Trim()))
     {
         teachers n = new teachers();
         n.TeacherId = txt1.Text.Trim();
         n.Pwd       = txt1.Text.Trim();
         n.Name      = txt2.Text.Trim();
         n.Phone     = txt3.Text.Trim();
         n.Email     = txt4.Text.Trim();
         n.Post      = DropDownList1.SelectedValue;
         n.College   = DropDownList2.SelectedValue;
         n.Creater   = Session["adminId"].ToString();
         tm.Insert(n);
         string path = Server.MapPath("~/upload/" + txt1.Text.Trim());
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         ScriptManager.RegisterStartupScript(this, this.GetType(), "updateScript", "alert(\"新增成功\");", true);
     }
 }
        public ActionResult Editar(int id)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (Models.universityEntities db = new Models.universityEntities())
                {
                    //teachers prof = db.teachers.Where(a => a.id_teacher == id).FirstOrDefault();
                    teachers prof = db.teachers.Find(id);
                    return(View(prof));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Se ha producido un error - ", ex.Message);
                return(View());
            }
        }
        public ActionResult Editar(teachers a)
        {
            try
            {
                using (Models.universityEntities db = new Models.universityEntities())
                {
                    teachers prof = db.teachers.Find(a.id_teacher);

                    prof.teacher_dni       = a.teacher_dni;
                    prof.teacher_name      = a.teacher_name;
                    prof.teacher_last_name = a.teacher_last_name;
                    prof.active            = a.active;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Se ha producido un error - ", ex.Message);
                return(View());
            }
        }
        protected void UpdateTeacherProfile_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                using (Model1 _db = new Model1())
                {
                    string   id      = User.Identity.GetUserId();
                    teachers teacher = (from Teachers in _db.teachers where Teachers.UserID == id select Teachers).FirstOrDefault();

                    teacher.Position    = Position.Text;
                    teacher.Contact     = Contact.Text;
                    teacher.SpanishRole = SpanishRole.Text;
                    teacher.OtherRole   = OtherRole.Text;
                    teacher.SpanishCV   = SpanishCV.Text;
                    teacher.OtherCV     = OtherCV.Text;
                    teacher.UserID      = User.Identity.GetUserId();
                    teacher.TeacherName = User.Identity.GetName() + User.Identity.GetSurname1() + User.Identity.GetSurname2();

                    if (Image.HasFile)
                    {
                        try
                        {
                            string fileName = System.IO.Path.GetFileName(Image.FileName);
                            Image.SaveAs(Server.MapPath("Subjects/Images/") + fileName);
                            teacher.Image = fileName;
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    _db.SaveChanges();
                    Response.Redirect("~/Account/Manage.aspx?m=TeacherProfSuccess");
                }
            }
        }
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        if (Txtname.Text.Trim() == "") Response.Write("<script>alert('姓名不能为空')</script>");
        else if (TxtMail.Text.Trim() == "") Response.Write("<script>alert('邮箱不能为空')</script>");
        else if (TxtOffice.Text.Trim() == "") Response.Write("<script>alert('办公室地址不能为空')</script>");
        else if (TxtPhone.Text.Trim() == "") Response.Write("<script>alert('办公室电话不能为空')</script>");
        else if (Txtfield.Text.Trim() == "") Response.Write("<script>alert('研究领域不能为空')</script>");
        else if (TxtCourse.Text.Trim() == "") Response.Write("<script>alert('教授课程不能为空')</script>");
        else if (TxtID.Text.Trim() == "") Response.Write("<script>alert('教工号不能为空')</script>");
        else
            using (var db = new CstwebEntities())
            {
                try
                {
                    if (teaid == 0)
                    {
                        var tea = new teachers();
                        tea.name = Txtname.Text.Trim();
                        tea.mail = TxtMail.Text.Trim();
                        tea.office = TxtOffice.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        tea.field = Txtfield.Text.Trim();
                        tea.course = TxtCourse.Text.Trim();
                        int i = Convert.ToInt32(DDLLevel.SelectedValue);
                        tea.teacherlevel = i;
                        i = Convert.ToInt32(DDLTitle.SelectedValue);
                        tea.title = i;
                        if (Txtetc.Text.Trim() != "") tea.etc = strp(Txtetc.Text.Trim());
                        if (TxtHome.Text.Trim() != "") tea.home = TxtHome.Text.Trim();
                        if (TxtStudy.Text.Trim() != "") tea.education = strp(TxtStudy.Text.Trim());
                        if (TxtReward.Text.Trim() != "") tea.reward = strp(TxtReward.Text.Trim());
                        if (TxtPartjob.Text.Trim() != "") tea.parttimejob = strp(TxtPartjob.Text.Trim());
                        if (TxtPaper.Text.Trim() != "") tea.paper = strp(TxtPaper.Text.Trim());
                        if (TxtProject.Text.Trim() != "") tea.project = strp(TxtProject.Text.Trim());
                        tea.time = System.DateTime.Now;
                        db.teachers.Add(tea);
                        db.SaveChanges();

                        var id1 = db.teachers.FirstOrDefault(a => a.name == Txtname.Text.Trim()).id;
                        accounts ac = new accounts();
                        ac.account = TxtID.Text.Trim();
                        ac.password = PasswordHash.PasswordHash.CreateHash(TxtID.Text.Trim());
                        ac.teacherid = id1;
                        ac.accountlevel = 1;
                        db.accounts.Add(ac);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'teachers.aspx';</script>");

                    }
                    else
                    {
                        teachers tea = db.teachers.First<teachers>(a => a.id == teaid);
                        tea.name = Txtname.Text.Trim();
                        tea.mail = TxtMail.Text.Trim();
                        tea.office = TxtOffice.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        tea.field = Txtfield.Text.Trim();
                        tea.course = TxtCourse.Text.Trim();
                        int i = Convert.ToInt32(DDLLevel.SelectedValue);
                        tea.teacherlevel = i;
                        i = Convert.ToInt32(DDLTitle.SelectedValue);
                        tea.title = i;
                        if (Txtetc.Text.Trim() != "") tea.etc = strp(Txtetc.Text.Trim());
                        //else tea.etc = null;
                        if (TxtHome.Text.Trim() != "") tea.home = TxtHome.Text.Trim();
                        //else tea.home = null;
                        if (TxtStudy.Text.Trim() != "") tea.education = strp(TxtStudy.Text.Trim());
                        //else tea.education = null;
                        if (TxtReward.Text.Trim() != "") tea.reward = strp(TxtReward.Text.Trim());
                        //else tea.reward = null;
                        if (TxtPartjob.Text.Trim() != "") tea.parttimejob = strp(TxtPartjob.Text.Trim());
                        //else tea.parttimejob = null;
                        if (TxtPaper.Text.Trim() != "") tea.paper = strp(TxtPaper.Text.Trim());
                        //else tea.paper = null;
                        if (TxtProject.Text.Trim() != "") tea.project = strp(TxtProject.Text.Trim());
                        //else tea.project = null;
                        tea.time = System.DateTime.Now;
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'teachers.aspx';</script>");
                    }


                }
                catch
                {
                    Response.Write("<script>alert('失败')</script>");
                }

            }
    }
Exemple #26
0
 public JsonResult UpdateTeachers(teachers teachers)
 {
     return(Json(bllTeachers.Update(teachers)));
 }
Exemple #27
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        if (Txtname.Text.Trim() == "")
        {
            Response.Write("<script>alert('姓名不能为空')</script>");
        }
        else if (TxtMail.Text.Trim() == "")
        {
            Response.Write("<script>alert('邮箱不能为空')</script>");
        }
        else if (TxtOffice.Text.Trim() == "")
        {
            Response.Write("<script>alert('办公室地址不能为空')</script>");
        }
        else if (TxtPhone.Text.Trim() == "")
        {
            Response.Write("<script>alert('办公室电话不能为空')</script>");
        }
        else if (Txtfield.Text.Trim() == "")
        {
            Response.Write("<script>alert('研究领域不能为空')</script>");
        }
        else if (TxtCourse.Text.Trim() == "")
        {
            Response.Write("<script>alert('教授课程不能为空')</script>");
        }
        else if (TxtID.Text.Trim() == "")
        {
            Response.Write("<script>alert('教工号不能为空')</script>");
        }
        else
        {
            using (var db = new CstwebEntities())
            {
                try
                {
                    if (teaid == 0)
                    {
                        var tea = new teachers();
                        tea.name   = Txtname.Text.Trim();
                        tea.mail   = TxtMail.Text.Trim();
                        tea.office = TxtOffice.Text.Trim();
                        tea.photo  = ImgIco.ImageUrl.ToString();
                        tea.phone  = TxtPhone.Text.Trim();
                        tea.field  = Txtfield.Text.Trim();
                        tea.course = TxtCourse.Text.Trim();
                        int i = Convert.ToInt32(DDLLevel.SelectedValue);
                        tea.teacherlevel = i;
                        i         = Convert.ToInt32(DDLTitle.SelectedValue);
                        tea.title = i;
                        if (Txtetc.Text.Trim() != "")
                        {
                            tea.etc = strp(Txtetc.Text.Trim());
                        }
                        if (TxtHome.Text.Trim() != "")
                        {
                            tea.home = TxtHome.Text.Trim();
                        }
                        if (TxtStudy.Text.Trim() != "")
                        {
                            tea.education = strp(TxtStudy.Text.Trim());
                        }
                        if (TxtReward.Text.Trim() != "")
                        {
                            tea.reward = strp(TxtReward.Text.Trim());
                        }
                        if (TxtPartjob.Text.Trim() != "")
                        {
                            tea.parttimejob = strp(TxtPartjob.Text.Trim());
                        }
                        if (TxtPaper.Text.Trim() != "")
                        {
                            tea.paper = strp(TxtPaper.Text.Trim());
                        }
                        if (TxtProject.Text.Trim() != "")
                        {
                            tea.project = strp(TxtProject.Text.Trim());
                        }
                        tea.time = System.DateTime.Now;
                        db.teachers.Add(tea);
                        db.SaveChanges();

                        var      id1 = db.teachers.FirstOrDefault(a => a.name == Txtname.Text.Trim()).id;
                        accounts ac  = new accounts();
                        ac.account      = TxtID.Text.Trim();
                        ac.password     = PasswordHash.PasswordHash.CreateHash(TxtID.Text.Trim());
                        ac.teacherid    = id1;
                        ac.accountlevel = 1;
                        db.accounts.Add(ac);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'teachers.aspx';</script>");
                    }
                    else
                    {
                        teachers tea = db.teachers.First <teachers>(a => a.id == teaid);
                        tea.name   = Txtname.Text.Trim();
                        tea.mail   = TxtMail.Text.Trim();
                        tea.office = TxtOffice.Text.Trim();
                        tea.photo  = ImgIco.ImageUrl.ToString();
                        tea.phone  = TxtPhone.Text.Trim();
                        tea.field  = Txtfield.Text.Trim();
                        tea.course = TxtCourse.Text.Trim();
                        int i = Convert.ToInt32(DDLLevel.SelectedValue);
                        tea.teacherlevel = i;
                        i         = Convert.ToInt32(DDLTitle.SelectedValue);
                        tea.title = i;
                        if (Txtetc.Text.Trim() != "")
                        {
                            tea.etc = strp(Txtetc.Text.Trim());
                        }
                        //else tea.etc = null;
                        if (TxtHome.Text.Trim() != "")
                        {
                            tea.home = TxtHome.Text.Trim();
                        }
                        //else tea.home = null;
                        if (TxtStudy.Text.Trim() != "")
                        {
                            tea.education = strp(TxtStudy.Text.Trim());
                        }
                        //else tea.education = null;
                        if (TxtReward.Text.Trim() != "")
                        {
                            tea.reward = strp(TxtReward.Text.Trim());
                        }
                        //else tea.reward = null;
                        if (TxtPartjob.Text.Trim() != "")
                        {
                            tea.parttimejob = strp(TxtPartjob.Text.Trim());
                        }
                        //else tea.parttimejob = null;
                        if (TxtPaper.Text.Trim() != "")
                        {
                            tea.paper = strp(TxtPaper.Text.Trim());
                        }
                        //else tea.paper = null;
                        if (TxtProject.Text.Trim() != "")
                        {
                            tea.project = strp(TxtProject.Text.Trim());
                        }
                        //else tea.project = null;
                        tea.time = System.DateTime.Now;
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'teachers.aspx';</script>");
                    }
                }
                catch
                {
                    Response.Write("<script>alert('失败')</script>");
                }
            }
        }
    }
Exemple #28
0
 /// <summary>
 /// 更新教师信息
 /// </summary>
 /// <param name="n">教师信息实体类</param>
 /// <returns></returns>
 public void Update(teachers n)
 {
     ndao.Update(n);
 }
Exemple #29
0
 /// <summary>
 /// 添加新教师信息
 /// </summary>
 /// <param name="n">教师信息实体类</param>
 /// <returns></returns>
 public bool Insert(teachers n)
 {
     return(ndao.Insert(n));
 }
Exemple #30
0
 /// <summary>
 /// 更改教师登录密码
 /// </summary>
 /// <param name="n">教师信息实体类</param>
 /// <returns></returns>
 public void UpdatePwd(teachers n)
 {
     ndao.UpdatePwd(n);
 }