コード例 #1
0
    protected void btnpassword_Click(object sender, EventArgs e)
    {
        string username = Request.QueryString["username"];

        if (RequiredFieldValidator2.IsValid == true && CompareValidator1.IsValid == true)
        {
            if (txtPwd.Text.Length >= 8)
            {
                string pwd = Class1.md5(txtPwd.Text, 32);

                using (var db = new ITShowEntities())
                {
                    Admin admin = db.Admin.SingleOrDefault(a => a.AdminName == username);

                    admin.AdminPassword = pwd;

                    if (db.SaveChanges() == 1)
                    {
                        Response.Write("<script>alert('修改成功')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('修改失败请重试')</script>");
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('密码长度不够!')</script>");
            }
        }
    }
コード例 #2
0
    protected void BtnReply_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        if (txtReply.Text.Trim().Length > 0)
        {
            using (var db = new ITShowEntities())
            {
                if (txtReply.Text.Trim().Length > 90)
                {
                    Response.Write("<script>alert('字数超过限制')</script>");
                }
                else
                {
                    Message message = db.Message.SingleOrDefault(a => a.MessageId == id);

                    message.MessageComment = txtReply.Text.Trim();

                    message.MessageAdminName = Session["username"].ToString();

                    db.SaveChanges();

                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script >alert('回复成功');layer_close();</script>");
                }
            }
        }
    }
コード例 #3
0
    protected void btnemail_Click(object sender, EventArgs e)
    {
        if (Convert.ToInt32(Session["number"].ToString()) == Convert.ToInt32(txtemail.Text))
        {
            using (var db = new ITShowEntities())

            {
                string username = Session["username"].ToString();

                Admin admin = (from it in db.Admin where it.AdminName == username select it).FirstOrDefault();

                admin.Flag = true;

                db.SaveChanges();

                divemail.Visible = false;

                Response.Write("<script>alert('验证成功!');location='Welcome.aspx'</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('验证码错误!')</script>");
        }
    }
コード例 #4
0
    protected void rptAdmin_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        int id = Convert.ToInt32(e.CommandArgument);

        //删除对应管理员,超级管理员不能删除自己
        if (id == 3)
        {
            Response.Write("<script>alert('你没有权限删除此管理员!');location='Admin-list.aspx'</script>");
        }
        else
        {
            if (e.CommandName == "Delete")
            {
                using (var db = new ITShowEntities())
                {
                    Admin admin = db.Admin.SingleOrDefault(a => a.AdminId == id);

                    db.Admin.Remove(admin);

                    db.SaveChanges();
                }
                Response.Write("<script>window.location='Admin-list.aspx'</script>");
            }
        }
    }
コード例 #5
0
    protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "delete")
        {
            int id = Convert.ToInt32(e.CommandArgument);
            using (var db = new ITShowEntities())
            {
                Works person = (from it in db.Works where it.WorksId == id select it).FirstOrDefault();

                db.Works.Remove(person);

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('删除成功');location='WorksList.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('删除失败请重试');location='WorksList.aspx'</script>");
                }
            }
        }
        //if (e.CommandName == "URL")
        //{
        //    //string url = Server.UrlEncode (e.CommandArgument.ToString().Trim());
        //    string url = e.CommandArgument.ToString().Trim();
        //    Response.Write("<script>window.open('http://www.baidu.com','_blank')</script>");
        //}
    }
コード例 #6
0
    protected void btnemail_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        string email = txtemail.Text;

        using (var db = new ITShowEntities())
        {
            Admin admin = db.Admin.SingleOrDefault(a => a.AdminId == id);

            if (email == admin.AdminEmail)
            {
                Response.Write("<script>alert('邮箱相同')</script>");
            }
            else
            {
                admin.AdminEmail = email;
                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('修改成功')</script>");
                }
                else
                {
                    Response.Write("<script>alert('修改失败请重试')</script>");
                }
            }
        }
    }
コード例 #7
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (txtGradeMajor.Value.Length > 0 && txtQQ.Value.Length > 0 && txtName.Value.Length > 0 && txtTel.Value.Length > 0 && Request.Form["txtIntroduction"].Length > 0 && txtDepart.Value.Length > 0)
        {
            string     name         = txtName.Value;
            string     tel          = txtTel.Value;
            string     gradeMajor   = txtGradeMajor.Value;
            string     introduction = Request.Form["txtIntroduction"];
            int        depart       = Convert.ToInt32(txtDepart.Value);
            IPManager  manager      = new IPManager();//查看IP是否用得频繁
            string     IPAddress    = manager.GetClientIPv4Address();
            XmlManager xmanager     = new XmlManager();
            int        ans          = xmanager.Editor(IPAddress);
            if (ans > 0)                     //能否写入IP
            {
                if (ans == 1)                //该IP十秒内无操作
                {
                    xmanager.Add(IPAddress); //如果没有这个IP,就加入记录
                    using (var db = new ITShowEntities())
                    {
                        Application person = new Application();
                        person.Name        = name;
                        person.GradeMajor  = gradeMajor;
                        person.Telephone   = tel;
                        person.Introdution = introduction;
                        person.Time        = Convert.ToDateTime(DateTime.Now.ToString());
                        person.QQ          = txtQQ.Value;
                        switch (depart)
                        {
                        case 1: person.Department = "前端开发"; break;

                        case 2: person.Department = "程序开发"; break;

                        case 3: person.Department = "UI设计"; break;

                        case 4: person.Department = "APP开发"; break;
                        }
                        db.Application.Add(person);

                        if (db.SaveChanges() == 1)
                        {
                            Response.Write("<script>alert('报名成功,欢迎加入爱特交流群,群号:245775349');location='ApplicationFormMobile.aspx'</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('报名失败请重试');location='ApplicationFormMobile.aspx'</script>");
                        }
                    }
                }
                else
                {
                    Response.Write("<script>alert('操作过于频繁请10秒后再操作');location='ApplicationFormMobile.aspx'</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('操作失败请重试');location='ApplicationFormMobile.aspx'</script>");
            }
        }
    }
コード例 #8
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string year = dropYear.SelectedValue;//届数

        string name = txtName.Text.Trim();

        string department = dropDepartment.SelectedValue;

        string grade = dropGrade.SelectedValue;

        string instruction = txtIntruduction.Text;

        string hobby = txtHobby.Text;



        //string image =;

        if (name.Length > 0 && img.ImageUrl.Length > 0)
        {
            using (var db = new ITShowEntities())
            {
                Member person = new Member()
                {
                    MemberDepartment = department,

                    MemberGrade = grade,

                    MemberName = name,

                    MemberImage = img.ImageUrl,

                    MemberYear = year,

                    MemberInstruction = instruction,

                    MemberInterest = hobby,
                };

                db.Member.Add(person);

                if (db.SaveChanges() == 1)
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script >alert('添加成功');layer_close();</script>");
                }
                else
                {
                    Response.Write("<script>alert('添加失败请重试')</script>");
                }
            }
        }

        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
コード例 #9
0
    protected void btnEditor_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        string title = txtTitle.Text.Trim();

        string link = txtLink.Text.Trim();

        string url = btnImage.ImageUrl.Trim();//图片

        string Pattern = @"(http|https)://[^\s]*";
        Regex  r       = new Regex(Pattern);

        if (title.Length > 0 && url.Length > 0 && link.Length > 0)
        {
            if (r.IsMatch(link))
            {
                using (var db = new ITShowEntities())//修改
                {
                    Works person = (from it in db.Works where it.WorksId == id select it).FirstOrDefault();

                    if (person.WorksName == title && person.WorksImage == btnImage.ImageUrl && person.WorksUrl == link)
                    {
                        Response.Write("<script>alert('未修改');location='WorksList.aspx'</script>");
                    }
                    else
                    {
                        person.WorksName  = title;
                        person.WorksUrl   = link;
                        person.WorksImage = url;
                        if (db.SaveChanges() == 1)
                        {
                            Response.Write("<script>alert('编辑成功');location='WorksList.aspx'</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('编辑失败请重试')</script>");
                        }
                    }
                }
            }
            else
            {
                Response.Write("<script>alert('请输入有效URL,http/https格式')</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
コード例 #10
0
 protected void rptComment_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName == "Delete")
     {
         int idComment = Convert.ToInt32(e.CommandArgument);
         using (var db = new ITShowEntities())
         {
             Message message = db.Message.SingleOrDefault(a => a.MessageId == idComment);
             db.Message.Remove(message);
             db.SaveChanges();
         }
         Response.Write("<script>window.location='Comment-list.aspx'</script>");
     }
 }
コード例 #11
0
    protected void BtnReply_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        using (var db = new ITShowEntities())
        {
            Message message = db.Message.SingleOrDefault(a => a.MessageId == id);

            message.MessageComment = Server.HtmlDecode(myEditor.InnerText);

            message.MessageAdminName = Session["username"].ToString();

            db.SaveChanges();
        }
    }
コード例 #12
0
ファイル: WorksAdd.aspx.cs プロジェクト: lly159/ITshow
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string title = txtTitle.Text.Trim();

        string link = txtLink.Text.Trim();

        string Pattern = @"(http|https)://[^\s]*";

        string time = txtTime.Value;

        Regex r = new Regex(Pattern);

        if (link.Length > 0 && time.Length > 0 && title.Length > 0 && img.ImageUrl.Length > 0)//都不能为空
        {
            if (r.IsMatch(link))
            {
                using (var db = new ITShowEntities())
                {
                    Works person = new Works()
                    {
                        WorksName = title,

                        WorksUrl = link,

                        WorksTime = Convert.ToDateTime(time),

                        WorksImage = img.ImageUrl
                    };

                    db.Works.Add(person);

                    if (db.SaveChanges() == 1)
                    {
                        ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script >alert('添加成功');layer_close();</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('添加失败请重试')</script>");
                    }
                }
            }
            Response.Write("<script>alert('请输入有效URL,http/https格式')</script>");
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
コード例 #13
0
    protected void btnEditor_Click(object sender, EventArgs e)
    {
        int    id          = Convert.ToInt32(Request.QueryString["id"]);
        string name        = txtName.Text.Trim();
        string instruction = txtIntruduction.Text;

        if (name.Length > 0 && instruction.Length > 0 && btnImage.ImageUrl.Length > 0)
        {
            using (var db = new ITShowEntities())//修改
            {
                Member person = (from it in db.Member where it.MemberId == id select it).FirstOrDefault();

                if (person.MemberImage == btnImage.ImageUrl && person.MemberInstruction == instruction && person.MemberName == name && person.MemberDepartment == dropDepartment.SelectedValue)
                {
                    Response.Write("<script>alert('未修改');location='MemberList.aspx'</script>");
                }
                else
                {
                    if (instruction.Length > 40)
                    {
                        Response.Write("<script>alert('字数超过限制')</script>");
                    }
                    else
                    {
                        person.MemberName        = name;
                        person.MemberDepartment  = dropDepartment.SelectedValue;
                        person.MemberImage       = btnImage.ImageUrl;//修改图片
                        person.MemberYear        = dropYear.SelectedValue;
                        person.MemberInstruction = instruction;
                        if (db.SaveChanges() == 1)
                        {
                            Response.Write("<script>alert('编辑成功');location='MemberList.aspx'</script>");
                        }
                        else
                        {
                            Response.Write("<script>alert('编辑失败请重试')</script>");
                        }
                    }
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
コード例 #14
0
    protected void btnEditor_Click(object sender, EventArgs e)
    {
        int    id      = Convert.ToInt32(Request.QueryString["id"]);
        string content = txtContent.Text.Trim();
        string time    = txtTime.Value;

        string url = "";

        if (img.ImageUrl.Length > 0)
        {
            url = img.ImageUrl;//图片地址
        }
        if (content.Length > 0 && txtTime.Value.Length > 0)
        {
            using (var db = new ITShowEntities())
            {
                Event person = (from it in db.Event where it.EventId == id select it).FirstOrDefault();

                if (person.EventTime == time && person.EventContent == content && person.EventImage == img.ImageUrl)//如果没修改
                {
                    Response.Write("<script>alert('未修改');location='EventList.aspx'</script>");
                }
                else
                {
                    person.EventContent = content;
                    person.EventTime    = time;
                    person.EventImage   = url;
                    if (db.SaveChanges() == 1)
                    {
                        Response.Write("<script>alert('编辑成功');location='EventList.aspx'</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('编辑失败请重试')</script>");
                    }
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
コード例 #15
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string content = txtContent.Text.Trim();

        string time = txtTime.Value;

        string url = "";

        if (img.ImageUrl.Length > 0)
        {
            url = img.ImageUrl;
        }

        if (content.Length > 0 && time.Length > 0)
        {
            using (var db = new ITShowEntities())
            {
                Event person = new Event()
                {
                    EventContent = content,

                    EventImage = url,//图片是可有可无的

                    EventTime = time
                };
                db.Event.Add(person);
                if (db.SaveChanges() == 1)
                {
                    ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script >alert('添加成功');layer_close();</script>");
                }
                else
                {
                    Response.Write("<script>alert('添加失败请重试')</script>");
                }
            }
        }
        else
        {
            Response.Write("<script>alert('不能为空')</script>");
        }
    }
コード例 #16
0
    protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "delete")
        {
            int id = Convert.ToInt32(e.CommandArgument);
            using (var db = new ITShowEntities())
            {
                Application person = (from it in db.Application where it.ApplicationId == id select it).FirstOrDefault();

                db.Application.Remove(person);

                if (db.SaveChanges() == 1)
                {
                    Response.Write("<script>alert('删除成功');location='ApplicationList.aspx'</script>");
                }
                else
                {
                    Response.Write("<script>alert('删除失败请重试');location='ApplicationList.aspx'</script>");
                }
            }
        }
    }
コード例 #17
0
    protected void btnnewpwd_Click(object sender, EventArgs e)
    {
        if (RequiredFieldValidator1.IsValid == true && RequiredFieldValidator2.IsValid == true && CompareValidator1.IsValid == true)
        {
            string username = Session["name2"].ToString();

            string EnPswdStr = Class1.md5(txtPwd.Text, 32);

            string password = EnPswdStr;

            using (var db = new ITShowEntities())
            {
                Admin admin = db.Admin.SingleOrDefault(a => a.AdminName == username);

                admin.AdminPassword = password;

                db.SaveChanges();

                Response.Write("<script>alert('修改成功!');location='Login.aspx'</script>");
            }
        }
    }
コード例 #18
0
    protected void editorImage_Click(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request.QueryString["id"]);

        string url = btnImage.ImageUrl.Trim();

        using (var db = new ITShowEntities())
        {
            Admin person = (from it in db.Admin where it.AdminId == id select it).FirstOrDefault();

            person.AdminImage = url;

            if (db.SaveChanges() == 1)
            {
                Response.Write("<script>alert('修改成功')</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败请重试')</script>");
            }
        }
    }
コード例 #19
0
    protected void btnsure_Click(object sender, EventArgs e)
    {
        string username = Request.QueryString["username"];

        string url = btnImage.ImageUrl.Trim();

        using (var db = new ITShowEntities())
        {
            Admin admin = db.Admin.SingleOrDefault(a => a.AdminName == username);

            admin.AdminEmail = txtemail.Text;
            //以下写存照片的路径
            admin.AdminImage = url;

            if (db.SaveChanges() == 1)
            {
                Response.Write("<script>alert('修改成功')</script>");
            }
            else
            {
                Response.Write("<script>alert('修改失败请重试')</script>");
            }
        }
    }
コード例 #20
0
    protected void BtnRegister_Click(object sender, EventArgs e)
    {
        Class1 register = new Class1();

        string question1 = DropDownList.SelectedValue;

        string answer1 = txtanswer.Text;

        string question2 = DropDownList1.Text;

        string answer2 = txtanswer1.Text;

        string question3 = DropDownList2.Text;

        string answer3 = txtanswer2.Text;

        if ((((((CompareValidator1.IsValid == true && RequiredFieldValidator2.IsValid == true) && RequiredFieldValidator3.IsValid == true) && RequiredFieldValidator5.IsValid == true) && RequiredFieldValidator6.IsValid == true) && RequiredFieldValidator7.IsValid == true) && RequiredFieldValidator9.IsValid == true)
        {
            if (txtPwd.Text.IndexOf(" ") >= 0)
            {
                Response.Write("<script>alert('密码请不要输入空格!')</script>");
            }
            else
            {
                if (txtPwd.Text.Length >= 8)
                {
                    if (question1 == question2 || question2 == question3 || question3 == question1)
                    {
                        Response.Write("<script>alert('问题不能选择一样!')</script>");
                    }
                    else
                    {
                        using (var db = new ITShowEntities())
                        {
                            Admin admin = new Admin();

                            Admin ad = db.Admin.SingleOrDefault(a => a.AdminName == txtusername.Text);

                            if (ad == null)
                            {
                                admin.AdminName = txtusername.Text;

                                admin.AdminPassword = Class1.md5(txtPwd.Text, 32);

                                admin.AdminEmail = txtmailbox.Text;

                                admin.AdminImage = "Images / t011ea4d03abdd5760e.jpg";

                                db.Admin.Add(admin);

                                db.SaveChanges();

                                Admin ad1 = db.Admin.SingleOrDefault(a => a.AdminName == txtusername.Text);

                                int id = ad1.AdminId;

                                Question thisquestion1 = new Question();
                                Question thisquestion2 = new Question();
                                Question thisquestion3 = new Question();

                                thisquestion1.AdminId = id;
                                thisquestion2.AdminId = id;
                                thisquestion3.AdminId = id;

                                thisquestion1.Question1 = question1;
                                thisquestion2.Question1 = question2;
                                thisquestion3.Question1 = question3;

                                thisquestion1.Answer = answer1;
                                db.Question.Add(thisquestion1);
                                thisquestion2.Answer = answer2;
                                db.Question.Add(thisquestion2);
                                thisquestion3.Answer = answer3;
                                db.Question.Add(thisquestion3);

                                db.SaveChanges();
                                Response.Write("<script>alert('注册成功!')</script>");
                            }
                            else
                            {
                                Response.Write("<script>alert('用户名已经存在!')</script>");
                            }
                        }
                    }
                }
                else
                {
                    Response.Write("<script>alert('密码长度不够!')</script>");
                }
            }
        }
    }
コード例 #21
0
ファイル: Comments.aspx.cs プロジェクト: lly159/ITshow
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        IPManager  manager   = new IPManager();//查看IP是否用得频繁
        string     IPAddress = manager.GetClientIPv4Address();
        XmlManager xmanager  = new XmlManager();
        int        ans       = xmanager.Editor(IPAddress);

        if (ans > 0)
        {
            if (ans == 1)
            {
                xmanager.Add(IPAddress);                             //如果没有这个IP,就加入记录

                BadWordsFilter badwordfilter = new BadWordsFilter(); //在此处对comment进行脏字处理
                //初始化关键字
                badwordfilter.Init();
                //检查是否有存在关键字
                bool a = badwordfilter.HasBadWord(textarea1.Value.Trim());

                if (a == false)
                {
                    string comment = textarea1.Value;

                    if (txtCode.Text == Session["CheckCode1"].ToString())
                    {
                        string time     = DateTime.Now.ToString();
                        string photoUrl = "images/p1.png";
                        //获取的对应图片信息
                        if (photoIndex.Text == "0")
                        {
                            photoUrl = "images/p1.png";
                        }
                        if (photoIndex.Text == "1")
                        {
                            photoUrl = "images/p2.png";
                        }
                        if (photoIndex.Text == "2")
                        {
                            photoUrl = "images/p3.png";
                        }
                        if (photoIndex.Text == "3")
                        {
                            photoUrl = "images/p4.png";
                        }
                        if (photoIndex.Text == "4")
                        {
                            photoUrl = "images/p5.png";
                        }
                        if (photoIndex.Text == "5")
                        {
                            photoUrl = "images/p6.png";
                        }
                        if (photoIndex.Text == "6")
                        {
                            photoUrl = "images/p7.png";
                        }
                        if (photoIndex.Text == "7")
                        {
                            photoUrl = "images/p8.png";
                        }
                        if (photoIndex.Text == "8")
                        {
                            photoUrl = "images/p9.png";
                        }
                        using (var db = new ITShowEntities())
                        {
                            Message message = new Message();

                            message.MessageContent = comment;

                            message.MessageTime = Convert.ToDateTime(time);

                            message.MessagePhoto = photoUrl;

                            db.Message.Add(message);

                            db.SaveChanges();

                            Response.Write("<script>alert('留言成功!');location='Comments.aspx'</script>");
                        }
                    }
                    else
                    {
                        Response.Write("<script>alert('验证码错误!');location='Comments.aspx'</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('留言中有不合法的内容')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('操作过于频繁,请10秒后再操作')</script>");
            }
        }
        else
        {
            Response.Write("<script>alert('操作失败请重试')</script>");
        }
    }