예제 #1
0
        protected void Unnamed_Click(object sender, EventArgs e)
        {
            ImageCupDataContext dc = new ImageCupDataContext();

            try
            {
                var data = dc.ImagineCup.Where(o => o.Sid == text1.Text);
                if (data != null)
                {
                    gridview.DataSource = data;
                    gridview.DataBind();
                }
                else
                {
                    lable1.Visible   = true;
                    lable1.Text      = "您查找的学生未录入,请重新输入";
                    text1.Text       = "";
                    lable1.BackColor = Color.Red;
                }
            }
            catch (Exception)
            {
                Response.Write("加载失败!");
            }
        }
예제 #2
0
        protected void Unnamed_Click1(object sender, EventArgs e)
        {
            ImageCupDataContext idc = new ImageCupDataContext();

            try
            {
                foreach (GridViewRow row in gridview.Rows)
                {
                    if ((row.FindControl("checkbox1") as CheckBox).Checked)
                    {
                        var data = idc.ImagineCup.Where(o => o.Sid == gridview.DataKeys[row.RowIndex].Value.ToString());
                        foreach (var clf in data)
                        {
                            clf.IsDeal = true;
                        }
                        idc.SubmitChanges();
                    }
                }
            }
            catch (Exception)
            {
                Response.Write("<script>alert('处理失败!')</script>");
            }
            this.databing();
        }
예제 #3
0
        private void databing()
        {
            ImageCupDataContext dc = new ImageCupDataContext();

            //ImagineCup imagecup=new ImagineCup();
            try
            {
                var data = dc.ImagineCup.Where(o => o.Sid != null);
                gridview.DataSource   = data;
                gridview.DataKeyNames = new string[] { "Sid" };
                gridview.DataBind();
            }
            catch (Exception)
            {
                Response.Write("加载失败!");
            }
        }
예제 #4
0
 protected void Button2_Click(object sender, EventArgs e)
 {
     using (var dc = new ImageCupDataContext())
     {
         try
         {
             var model = new ImagineCup();
             if (!String.IsNullOrWhiteSpace(TextBox1.Text) && !String.IsNullOrWhiteSpace(TextBox2.Text) && !String.IsNullOrWhiteSpace(TextBox3.Text) && !String.IsNullOrWhiteSpace(TextBox4.Text) && !String.IsNullOrWhiteSpace(TextBox5.Text) && !String.IsNullOrWhiteSpace(dropdownlist.SelectedValue) && !String.IsNullOrWhiteSpace(TextBox9.Text))
             {
                 model.Name         = TextBox1.Text;
                 model.Grade        = TextBox2.Text;
                 model.Major        = TextBox3.Text;
                 model.Email        = TextBox4.Text;
                 model.Phone        = TextBox5.Text;
                 model.ProjectTypes = dropdownlist.SelectedItem.Value;
                 model.ProjectNames = TextBox7.Text;
                 model.TroopsName   = TextBox8.Text;
                 model.Sid          = TextBox9.Text;
                 model.Ip           = Request.UserHostAddress;
                 model.IsDeal       = false;
                 model.IsStudent    = false;
                 var isRepeat = dc.ImagineCup.Where(o => o.Email == model.Email);
                 var ipRepeat = dc.ImagineCup.Where(o => o.Ip == model.Ip);
                 if (isRepeat.Count() == 0)
                 {
                     if (ipRepeat.Count() < 10)
                     {
                         dc.ImagineCup.InsertOnSubmit(model);
                         dc.SubmitChanges();
                     }
                     else
                     {
                         isOK = "同一IP提交次数过多。";
                         Server.Transfer("Rezult.aspx");
                     }
                 }
                 else
                 {
                     isOK = "请不要重复提交。";
                     Server.Transfer("Rezult.aspx");
                 }
                 if (dc.ImagineCup.Where(o => o.Email == model.Email).Count() > 0 && dc.ImagineCup.Where(o => o.Sid == model.Sid).Count() > 0)
                 {
                     isOK = "提交成功。请携带您的学生证到9栋填写完整的申请表并领取微软大礼包。";
                     Server.Transfer("Rezult.aspx");
                 }
                 else
                 {
                     isOK = "提交失败。";
                     Server.Transfer("Rezult.aspx");
                 }
             }
             else
             {
                 isOK = "请填写完整再提交";
                 Server.Transfer("Rezult.aspx");
             }
         }
         catch
         {
         }
     }
 }