Exemplo n.º 1
0
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     using (var db = new CstwebEntities())
     {
         try
         {
             news new1 = db.news.FirstOrDefault(a => a.@class == 5);
             new1.title = TxtTitle.Text;
             new1.body  = myEditor.InnerText;
             new1.time  = DateTime.Now;
             db.SaveChanges();
             Response.Write("<script language=javascript>alert('修改成功');window.location = 'training.aspx';</script>");
         }
         catch
         {
             news new1 = new news();
             new1.title  = TxtTitle.Text;
             new1.body   = myEditor.InnerText;
             new1.time   = DateTime.Now;
             new1.@class = 5;
             db.news.Add(new1);
             db.SaveChanges();
             Response.Write("<script language=javascript>alert('修改成功');window.location = 'training.aspx';</script>");
         }
     }
 }
Exemplo n.º 2
0
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            using (var db = new CstwebEntities())
            {
                int id = Convert.ToInt32(e.CommandArgument);
                var le1 = db.lesrelation.Where(a => a.lesson == id).ToList();
                try
                {
                    db.lesrelation.Remove(le1[0]);
                    db.SaveChanges();
                }
                catch { }
                try
                {
                    db.lesrelation.Remove(le1[1]);
                    db.SaveChanges();
                }
                catch { }
                try
                {
                    db.lesrelation.Remove(le1[2]);
                    db.SaveChanges();
                }
                catch { }
                lesson les = db.lesson.FirstOrDefault(a => a.id == id);

                db.lesson.Remove(les);
                db.SaveChanges();
                Response.Write("<script>alert('删除成功');window.location = 'lessons.aspx';</script>");
            }
        }
    }
Exemplo n.º 3
0
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     using (var db = new CstwebEntities())
     {
         try
         {
             news new1 = db.news.FirstOrDefault(a => a.@class == 0);
             new1.title = TxtTitle.Text;
             new1.body = myEditor.InnerText;
             new1.time = DateTime.Now;
             db.SaveChanges();
             Response.Write("<script language=javascript>alert('修改成功');window.location = 'introduce.aspx';</script>");
         }
         catch
         {
             news new1 = new news();
             new1.title = TxtTitle.Text;
             new1.body = myEditor.InnerText;
             new1.time = DateTime.Now;
             new1.@class = 0;
             db.news.Add(new1);
             db.SaveChanges();
             Response.Write("<script language=javascript>alert('修改成功');window.location = 'introduce.aspx';</script>");
         }
     }
 }
Exemplo n.º 4
0
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            using (var db = new CstwebEntities())
            {
                int id  = Convert.ToInt32(e.CommandArgument);
                var le1 = db.lesrelation.Where(a => a.lesson == id).ToList();
                try
                {
                    db.lesrelation.Remove(le1[0]);
                    db.SaveChanges();
                }
                catch { }
                try
                {
                    db.lesrelation.Remove(le1[1]);
                    db.SaveChanges();
                }
                catch { }
                try
                {
                    db.lesrelation.Remove(le1[2]);
                    db.SaveChanges();
                }
                catch { }
                lesson les = db.lesson.FirstOrDefault(a => a.id == id);

                db.lesson.Remove(les);
                db.SaveChanges();
                Response.Write("<script>alert('删除成功');window.location = 'lessons.aspx';</script>");
            }
        }
    }
Exemplo n.º 5
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string str = Server.HtmlDecode(myEditor.InnerHtml);

        if (TxtTitle.Text.Trim() == "")
        {
            Response.Write("<script>alert('标题不能为空')</script>");
        }
        else if (str.Trim() == "")
        {
            Response.Write("<script>alert('文章不能为空')</script>");
        }
        else
        {
            try
            {
                using (var db = new CstwebEntities())
                {
                    games ne;
                    if (neid == 0)
                    {
                        ne = new games();
                    }
                    else
                    {
                        ne = db.games.First <games>(a => a.id == neid);
                    }

                    ne.gamename = TxtTitle.Text.Trim();
                    ne.body     = str.Trim();
                    ne.addtime  = DateTime.Now;
                    int status = Convert.ToInt16(DdlStatus.SelectedValue);
                    ne.status = status;
                    if (neid == 0)
                    {
                        db.games.Add(ne);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('发布成功');window.location = 'games.aspx';</script>");
                    }
                    else
                    {
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'games.aspx';</script>");
                    }
                }
            }
            catch
            {
                Response.Write("<script>alert('失败')</script>");
            }
        }
    }
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string str = Server.HtmlDecode(myEditor.InnerHtml);

        if (TxtTitle.Text.Trim() == "")
        {
            Response.Write("<script>alert('标题不能为空')</script>");
        }
        else if (str.Trim() == "")
        {
            Response.Write("<script>alert('文章不能为空')</script>");
        }
        else
        {
            try
            {
                using (var db = new CstwebEntities())
                {
                    news ne;
                    if (neid == 0)
                    {
                        ne = new news();
                    }
                    else
                    {
                        ne = db.news.First <news>(a => a.id == neid);
                    }

                    ne.title  = TxtTitle.Text.Trim();
                    ne.body   = str.Trim();
                    ne.@class = Convert.ToInt32(DdlNew.SelectedValue);
                    ne.time   = DateTime.Now;
                    if (neid == 0)
                    {
                        db.news.Add(ne);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('发布成功');window.location = 'wanttednews.aspx?nc=" + newsclass.ToString() + "';</script>");
                    }
                    else
                    {
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'wanttednews.aspx?nc=" + newsclass.ToString() + "';</script>");
                    }
                }
            }
            catch
            {
                Response.Write("<script>alert('失败')</script>");
            }
        }
    }
Exemplo n.º 7
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 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 (TxtGrade.Text.Trim() == "") Response.Write("<script>alert('入学年份不能为空')</script>");
        else if (TxtPhone.Text.Trim() == "") Response.Write("<script>alert('国籍不能为空')</script>");
        else if (TxtBirth.Text.Trim() == "") Response.Write("<script>alert('出生年月不能为空')</script>");
        else if (TxtHome.Text.Trim() == "") Response.Write("<script>alert('毕业院校不能为空')</script>");
        else if (TxtMajor.Text.Trim() == "") Response.Write("<script>alert('专业不能为空')</script>");
        else
            using (var db = new CstwebEntities())
            {
                try
                {
                    if (teaid == 0)
                    {
                        var tea = new exchange();
                        tea.name = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.major = TxtMajor.Text.Trim();
                        tea.home = TxtHome.Text.Trim();
                        tea.birth = TxtBirth.Text.Trim();
                        tea.grade = TxtGrade.Text.Trim();
                        tea.nation = TxtPhone.Text.Trim();
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "") tea.ect = tempstr;
                        db.exchange.Add(tea);
                        db.SaveChanges();
                        
                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'exchangelist.aspx';</script>");

                    }
                    else
                    {
                        exchange tea = db.exchange.First<exchange>(a => a.id == teaid);
                        tea.name = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.major = TxtMajor.Text.Trim();
                        tea.home = TxtHome.Text.Trim();
                        tea.birth = TxtBirth.Text.Trim();
                        tea.grade = TxtGrade.Text.Trim();
                        tea.nation = TxtPhone.Text.Trim();
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "") tea.ect = tempstr;

                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'exchangelist.aspx';</script>");
                    }


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

            }
    }
Exemplo n.º 9
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>");
         }
     }
 }
Exemplo n.º 10
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string str = Server.HtmlDecode(myEditor.InnerHtml);
        if (TxtTitle.Text.Trim() == "") Response.Write("<script>alert('标题不能为空')</script>");
        else if (str.Trim() == "") Response.Write("<script>alert('文章不能为空')</script>");
        else
            try
            {
                using (var db = new CstwebEntities())
                {
                    games ne;
                    if (neid == 0)
                        ne = new games();
                    else
                        ne = db.games.First<games>(a => a.id == neid);

                    ne.gamename = TxtTitle.Text.Trim();
                    ne.body = str.Trim();
                    ne.addtime = DateTime.Now;
                    int status = Convert.ToInt16(DdlStatus.SelectedValue);
                    ne.status = status;
                    if (neid == 0)
                    {
                        db.games.Add(ne);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('发布成功');window.location = 'games.aspx';</script>");
                    }
                    else
                    {
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'games.aspx';</script>");
                    }

                }
            }
            catch
            {
                Response.Write("<script>alert('失败')</script>");
            }
    }
Exemplo n.º 11
0
    protected void BtnSubmit_Click(object sender, EventArgs e)
    {
        string str = Server.HtmlDecode(myEditor.InnerHtml);
        if (TxtTitle.Text.Trim() == "") Response.Write("<script>alert('标题不能为空')</script>");
        else if (str.Trim() == "") Response.Write("<script>alert('文章不能为空')</script>");
        else
            try
            {
                using (var db = new CstwebEntities())
                {
                    news ne;
                    if (neid == 0)
                        ne = new news();
                    else
                        ne = db.news.First<news>(a => a.id == neid);

                    ne.title = TxtTitle.Text.Trim();
                    ne.body = str.Trim();
                    ne.@class =11;
                    ne.time = DateTime.Now;
                    if (neid == 0)
                    {
                        db.news.Add(ne);
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('发布成功');window.location = 'graduatenews.aspx';</script>");
                    }
                    else
                    {
                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'graduatenews.aspx';</script>");
                    }

                }
            }
            catch
            {
                Response.Write("<script>alert('失败')</script>");
            }
    }
Exemplo n.º 12
0
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     using (var db = new CstwebEntities())
     {
         int id = Convert.ToInt16(Session["admin"].ToString());
         accounts ac = db.accounts.FirstOrDefault(a => a.id == id);
         if (PasswordHash.PasswordHash.ValidatePassword(TxtOldPw.Text, ac.password))
         {
             string str = PasswordHash.PasswordHash.CreateHash(NewPw1.Text);
             ac.password = str;
             db.SaveChanges();
             Response.Write("<script>alert('修改成功')</script>");
         }
     }
 }
Exemplo n.º 13
0
 protected void BtnSubmit_Click(object sender, EventArgs e)
 {
     using (var db = new CstwebEntities())
     {
         int      id = Convert.ToInt16(Session["teacherid"].ToString());
         accounts ac = db.accounts.FirstOrDefault(a => a.teacherid == id);
         if (PasswordHash.PasswordHash.ValidatePassword(TxtOldPw.Text, ac.password))
         {
             string str = PasswordHash.PasswordHash.CreateHash(NewPw1.Text);
             ac.password = str;
             db.SaveChanges();
             Response.Write("<script>alert('修改成功')</script>");
         }
     }
 }
Exemplo n.º 14
0
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "del")
        {
            using (var db = new CstwebEntities())
            {
                int     id  = Convert.ToInt32(e.CommandArgument);
                friends tea = db.friends.FirstOrDefault(a => a.id == id);

                db.friends.Remove(tea);

                db.SaveChanges();
                Response.Write("<script>alert('删除成功');window.location = 'friendslist.aspx';</script>");
            }
        }
    }
Exemplo n.º 15
0
 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "del")
     {
         using (var db = new CstwebEntities())
         {
             int id = Convert.ToInt32(e.CommandArgument);
             friends tea = db.friends.FirstOrDefault(a => a.id == id);
             
             db.friends.Remove(tea);
             
             db.SaveChanges();
             Response.Write("<script>alert('删除成功');window.location = 'friendslist.aspx';</script>");
         }
     }
 }
Exemplo n.º 16
0
 protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     int id = Convert.ToInt32(e.CommandArgument);
     if (e.CommandName == "del")
     {
         using (var db = new CstwebEntities())
         {
             try
             {
                 news ne = db.news.FirstOrDefault<news>(a => a.id == id);
                 db.news.Remove(ne);
                 db.SaveChanges();
                 Response.Write("<script>alert('删除成功');window.location = 'graduatenews.aspx';</script>");
             }
             catch { Response.Write("<script>alert('删除失败')</script>"); }
         }
     }
 }
Exemplo n.º 17
0
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument);

        if (e.CommandName == "del")
        {
            using (var db = new CstwebEntities())
            {
                try
                {
                    cooperation ne = db.cooperation.FirstOrDefault <cooperation>(a => a.id == id);
                    db.cooperation.Remove(ne);
                    db.SaveChanges();
                    Response.Write("<script>alert('删除成功');window.location = 'cooperation.aspx?co=" + newsclass.ToString() + "';</script>");
                }
                catch { Response.Write("<script>alert('删除失败')</script>"); }
            }
        }
    }
Exemplo n.º 18
0
    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument);

        if (e.CommandName == "del")
        {
            using (var db = new CstwebEntities())
            {
                try
                {
                    news ne = db.news.FirstOrDefault <news>(a => a.id == id);
                    db.news.Remove(ne);
                    db.SaveChanges();
                    Response.Write("<script>alert('删除成功');window.location = 'graduatenews.aspx';</script>");
                }
                catch { Response.Write("<script>alert('删除失败')</script>"); }
            }
        }
    }
Exemplo n.º 19
0
    protected void BtnPost_Click(object sender, EventArgs e)
    {
        int temp;
        double cr;
        if (IsOK())
        {
            using (var db = new CstwebEntities())
            {
                if (Session["lessonID"].ToString() != "0")
                {
                    try
                    {
                        temp = Convert.ToInt32(Session["lessonID"].ToString());
                        var del = db.lesrelation.Where(a => a.lesson == temp).ToList();
                        lesrelation les1;
                        try
                        {
                            les1 = del[0];
                            db.lesrelation.Remove(les1);
                            db.SaveChanges();
                        }
                        catch { }
                        try
                        {
                            les1 = del[1];
                            db.lesrelation.Remove(les1);
                            db.SaveChanges();
                        }
                        catch { }
                        try
                        {
                            les1 = del[2];
                            db.lesrelation.Remove(les1);
                            db.SaveChanges();
                        }
                        catch { }
                        lesson les = db.lesson.First(a => a.id == temp);
                        les.classname = TxtLessonName.Text.Trim();
                        cr = Convert.ToDouble(TxtCredits.Text.Trim());
                        les.credits = cr;
                        temp = Convert.ToInt32(TxtTeach.Text.Trim());
                        les.teach = temp;
                        temp = Convert.ToInt32(TxtExp.Text.Trim());
                        les.experiment = temp;
                        temp = Convert.ToInt32(DDLClass.SelectedValue);
                        les.lesscla = temp;
                        temp = Convert.ToInt32(Session["lessonID"].ToString());
                        if (LblFilename.Text != "")
                        {
                            les.lesfile = LblFilename.Text;
                        }
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        les.etc = tempstr.Trim();
                        les1 = new lesrelation();
                        les1.lesson = temp;
                        db.SaveChanges();
                        if (Label1.Text != "0")
                        {
                            temp = Convert.ToInt32(Label1.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        if (Label2.Text != "0")
                        {
                            temp = Convert.ToInt32(Label2.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        if (Label3.Text != "0")
                        {
                            temp = Convert.ToInt32(Label3.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        Session["FList"] = null;
                        Session["Less"] = null;
                        Session["First1"] = null;
                        Session["First2"] = null;
                        Session["First3"] = null;
                        Session["lessonID"] = null;
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'lessons.aspx';</script>");
                    }
                    catch
                    {
                        Response.Write("<script>alert('修改失败')</script>");
                    }
                }
                else
                {
                    try
                    {
                        lesson les = new lesson();
                        lesrelation les1 = new lesrelation();
                        les.classname = TxtLessonName.Text.Trim();
                        cr = Convert.ToDouble(TxtCredits.Text.Trim());
                        les.credits = cr;
                        temp = Convert.ToInt32(TxtTeach.Text.Trim());
                        les.teach = temp;
                        temp = Convert.ToInt32(TxtExp.Text.Trim());
                        les.experiment = temp;
                        temp = Convert.ToInt32(DDLClass.SelectedValue);
                        les.lesscla = temp;
                        temp = Convert.ToInt32(Session["lessonID"].ToString());
                        if (LblFilename.Text != "")
                        {
                            les.lesfile = LblFilename.Text;
                            
                        }
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        les.etc = tempstr.Trim();
                        db.lesson.Add(les);
                        db.SaveChanges();
                        temp = db.lesson.First(a => a.classname == TxtLessonName.Text.Trim()).id;
                        les1.lesson = temp;
                        if (Label1.Text != "0")
                        {
                            temp = Convert.ToInt32(Label1.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        if (Label2.Text != "0")
                        {
                            temp = Convert.ToInt32(Label2.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        if (Label3.Text != "0")
                        {
                            temp = Convert.ToInt32(Label3.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        Session["FList"] = null;
                        Session["Less"] = null;
                        Session["First1"] = null;
                        Session["First2"] = null;
                        Session["First3"] = null;
                        Session["lessonID"] = null;
                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'lessons.aspx';</script>");

                    }
                    catch { Response.Write("<script>alert('添加失败')</script>"); }
                }
            }
        }
    }
Exemplo n.º 20
0
    protected void BtnPost_Click(object sender, EventArgs e)
    {
        int    temp;
        double cr;

        if (IsOK())
        {
            using (var db = new CstwebEntities())
            {
                if (Session["lessonID"].ToString() != "0")
                {
                    try
                    {
                        temp = Convert.ToInt32(Session["lessonID"].ToString());
                        var         del = db.lesrelation.Where(a => a.lesson == temp).ToList();
                        lesrelation les1;
                        try
                        {
                            les1 = del[0];
                            db.lesrelation.Remove(les1);
                            db.SaveChanges();
                        }
                        catch { }
                        try
                        {
                            les1 = del[1];
                            db.lesrelation.Remove(les1);
                            db.SaveChanges();
                        }
                        catch { }
                        try
                        {
                            les1 = del[2];
                            db.lesrelation.Remove(les1);
                            db.SaveChanges();
                        }
                        catch { }
                        lesson les = db.lesson.First(a => a.id == temp);
                        les.classname  = TxtLessonName.Text.Trim();
                        cr             = Convert.ToDouble(TxtCredits.Text.Trim());
                        les.credits    = cr;
                        temp           = Convert.ToInt32(TxtTeach.Text.Trim());
                        les.teach      = temp;
                        temp           = Convert.ToInt32(TxtExp.Text.Trim());
                        les.experiment = temp;
                        temp           = Convert.ToInt32(DDLClass.SelectedValue);
                        les.lesscla    = temp;
                        temp           = Convert.ToInt32(Session["lessonID"].ToString());
                        if (LblFilename.Text != "")
                        {
                            les.lesfile = LblFilename.Text;
                        }
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        les.etc     = tempstr.Trim();
                        les1        = new lesrelation();
                        les1.lesson = temp;
                        db.SaveChanges();
                        if (Label1.Text != "0")
                        {
                            temp             = Convert.ToInt32(Label1.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        if (Label2.Text != "0")
                        {
                            temp             = Convert.ToInt32(Label2.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        if (Label3.Text != "0")
                        {
                            temp             = Convert.ToInt32(Label3.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        Session["FList"]    = null;
                        Session["Less"]     = null;
                        Session["First1"]   = null;
                        Session["First2"]   = null;
                        Session["First3"]   = null;
                        Session["lessonID"] = null;
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'lessons.aspx';</script>");
                    }
                    catch
                    {
                        Response.Write("<script>alert('修改失败')</script>");
                    }
                }
                else
                {
                    try
                    {
                        lesson      les  = new lesson();
                        lesrelation les1 = new lesrelation();
                        les.classname  = TxtLessonName.Text.Trim();
                        cr             = Convert.ToDouble(TxtCredits.Text.Trim());
                        les.credits    = cr;
                        temp           = Convert.ToInt32(TxtTeach.Text.Trim());
                        les.teach      = temp;
                        temp           = Convert.ToInt32(TxtExp.Text.Trim());
                        les.experiment = temp;
                        temp           = Convert.ToInt32(DDLClass.SelectedValue);
                        les.lesscla    = temp;
                        temp           = Convert.ToInt32(Session["lessonID"].ToString());
                        if (LblFilename.Text != "")
                        {
                            les.lesfile = LblFilename.Text;
                        }
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        les.etc = tempstr.Trim();
                        db.lesson.Add(les);
                        db.SaveChanges();
                        temp        = db.lesson.First(a => a.classname == TxtLessonName.Text.Trim()).id;
                        les1.lesson = temp;
                        if (Label1.Text != "0")
                        {
                            temp             = Convert.ToInt32(Label1.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        if (Label2.Text != "0")
                        {
                            temp             = Convert.ToInt32(Label2.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        if (Label3.Text != "0")
                        {
                            temp             = Convert.ToInt32(Label3.Text);
                            les1.firstlesson = temp;
                            db.lesrelation.Add(les1);
                            db.SaveChanges();
                        }
                        Session["FList"]    = null;
                        Session["Less"]     = null;
                        Session["First1"]   = null;
                        Session["First2"]   = null;
                        Session["First3"]   = null;
                        Session["lessonID"] = null;
                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'lessons.aspx';</script>");
                    }
                    catch { Response.Write("<script>alert('添加失败')</script>"); }
                }
            }
        }
    }
Exemplo n.º 21
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 (TxtWork.Text.Trim() == "") Response.Write("<script>alert('工作单位不能为空')</script>");
        
        else if (TxtBirth.Text.Trim() == "") Response.Write("<script>alert('出生年月不能为空')</script>");
        else if (TxtPhone.Text.Trim() == "") Response.Write("<script>alert('联系电话不能为空')</script>");
      
        else
            using (var db = new CstwebEntities())
            {
                try
                {
                    if (teaid == 0)
                    {
                        var tea = new friends();
                        tea.fname = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        int sex = Convert.ToInt32(DdlSex.SelectedValue);
                        tea.sex = sex;
                        tea.birth = TxtBirth.Text.Trim();
                        tea.workplace = TxtWork.Text.Trim();
                        
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "") tea.ect = tempstr;
                        db.friends.Add(tea);
                        db.SaveChanges();
                        
                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'friendslist.aspx';</script>");

                    }
                    else
                    {
                        friends tea = db.friends.First<friends>(a => a.id == teaid);
                        tea.fname = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        int sex = Convert.ToInt32(DdlSex.SelectedValue);
                        tea.sex = sex;
                        tea.birth = TxtBirth.Text.Trim();
                        tea.workplace = TxtWork.Text.Trim();
                        
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "") tea.ect = tempstr;

                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'friendslist.aspx';</script>");
                    }


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

            }
    }
Exemplo n.º 22
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>");
                }
            }
        }
    }
Exemplo n.º 23
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
                {
                    
                        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 = 'index2.aspx';</script>");



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

            }
    }
Exemplo n.º 24
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 (TxtWork.Text.Trim() == "")
        {
            Response.Write("<script>alert('工作单位不能为空')</script>");
        }

        else if (TxtBirth.Text.Trim() == "")
        {
            Response.Write("<script>alert('出生年月不能为空')</script>");
        }
        else if (TxtPhone.Text.Trim() == "")
        {
            Response.Write("<script>alert('联系电话不能为空')</script>");
        }

        else
        {
            using (var db = new CstwebEntities())
            {
                try
                {
                    if (teaid == 0)
                    {
                        var tea = new friends();
                        tea.fname = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        int sex = Convert.ToInt32(DdlSex.SelectedValue);
                        tea.sex       = sex;
                        tea.birth     = TxtBirth.Text.Trim();
                        tea.workplace = TxtWork.Text.Trim();

                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "")
                        {
                            tea.ect = tempstr;
                        }
                        db.friends.Add(tea);
                        db.SaveChanges();

                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'friendslist.aspx';</script>");
                    }
                    else
                    {
                        friends tea = db.friends.First <friends>(a => a.id == teaid);
                        tea.fname = Txtname.Text.Trim();
                        tea.email = TxtMail.Text.Trim();
                        tea.photo = ImgIco.ImageUrl.ToString();
                        tea.phone = TxtPhone.Text.Trim();
                        int sex = Convert.ToInt32(DdlSex.SelectedValue);
                        tea.sex       = sex;
                        tea.birth     = TxtBirth.Text.Trim();
                        tea.workplace = TxtWork.Text.Trim();

                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "")
                        {
                            tea.ect = tempstr;
                        }

                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'friendslist.aspx';</script>");
                    }
                }
                catch
                {
                    Response.Write("<script>alert('失败')</script>");
                }
            }
        }
    }
    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 (TxtGrade.Text.Trim() == "")
        {
            Response.Write("<script>alert('入学年份不能为空')</script>");
        }
        else if (TxtPhone.Text.Trim() == "")
        {
            Response.Write("<script>alert('国籍不能为空')</script>");
        }
        else if (TxtBirth.Text.Trim() == "")
        {
            Response.Write("<script>alert('出生年月不能为空')</script>");
        }
        else if (TxtHome.Text.Trim() == "")
        {
            Response.Write("<script>alert('毕业院校不能为空')</script>");
        }
        else if (TxtMajor.Text.Trim() == "")
        {
            Response.Write("<script>alert('专业不能为空')</script>");
        }
        else
        {
            using (var db = new CstwebEntities())
            {
                try
                {
                    if (teaid == 0)
                    {
                        var tea = new exchange();
                        tea.name   = Txtname.Text.Trim();
                        tea.email  = TxtMail.Text.Trim();
                        tea.photo  = ImgIco.ImageUrl.ToString();
                        tea.major  = TxtMajor.Text.Trim();
                        tea.home   = TxtHome.Text.Trim();
                        tea.birth  = TxtBirth.Text.Trim();
                        tea.grade  = TxtGrade.Text.Trim();
                        tea.nation = TxtPhone.Text.Trim();
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "")
                        {
                            tea.ect = tempstr;
                        }
                        db.exchange.Add(tea);
                        db.SaveChanges();

                        Response.Write("<script language=javascript>alert('添加成功');window.location = 'exchangelist.aspx';</script>");
                    }
                    else
                    {
                        exchange tea = db.exchange.First <exchange>(a => a.id == teaid);
                        tea.name   = Txtname.Text.Trim();
                        tea.email  = TxtMail.Text.Trim();
                        tea.photo  = ImgIco.ImageUrl.ToString();
                        tea.major  = TxtMajor.Text.Trim();
                        tea.home   = TxtHome.Text.Trim();
                        tea.birth  = TxtBirth.Text.Trim();
                        tea.grade  = TxtGrade.Text.Trim();
                        tea.nation = TxtPhone.Text.Trim();
                        string tempstr = Server.HtmlDecode(myEditor.InnerHtml);
                        if (tempstr != "")
                        {
                            tea.ect = tempstr;
                        }

                        db.SaveChanges();
                        Response.Write("<script language=javascript>alert('修改成功');window.location = 'exchangelist.aspx';</script>");
                    }
                }
                catch
                {
                    Response.Write("<script>alert('失败')</script>");
                }
            }
        }
    }