Пример #1
0
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (((Button)(dvStu.FindControl("btnEdit"))).Text == "取消")
     {
         string   name   = ((TextBox)(dvStu.FindControl("tbName"))).Text;
         string   sex    = ((TextBox)(dvStu.FindControl("tbSex"))).Text;
         string   level  = ((TextBox)(dvStu.FindControl("tbLevel"))).Text;
         string   pname  = ((TextBox)(dvStu.FindControl("tbPro"))).Text;
         string   sclass = ((TextBox)(dvStu.FindControl("tbClass"))).Text;
         string   year   = ((HtmlInputText)(dvStu.FindControl("subYear"))).Value;
         string   phone  = ((TextBox)(dvStu.FindControl("tbPhone"))).Text;
         string   Tel    = ((TextBox)(dvStu.FindControl("tbTel"))).Text;
         string   email  = ((TextBox)(dvStu.FindControl("tbEmail"))).Text;
         bool     b      = ((CheckBox)(dvStu.FindControl("cbAccept"))).Checked;
         string[] pt     = new string[11] {
             id, name, sex, level, pname, sclass, year, phone, Tel, email, b.ToString()
         };
         Fannie.Student s = new Fannie.Student();
         if (s.ModifyOneStu(pt) > 0)
         {
             Set(true);
             ((Button)(dvStu.FindControl("btnEdit"))).Text = "编辑";
         }
     }
     else
     {
         Response.Write("<script language='javascript'>alert('请点击编辑,修改信息后再点 更新')</script>");
     }
 }
Пример #2
0
    //退选所选课程
    protected void DeleteChosenSub_Click(object sender, EventArgs e)
    {
        int count;

        Fannie.Student stu   = new Fannie.Student();
        int            subid = Convert.ToInt32(ChosenSub1.DataKey.Value.ToString());

        if (IsTime())
        {
            count = stu.DeleteChosen(id);
            if (count > 0)
            {
                stu.ReduceChosenPeople(subid);
                Response.Write("<script> alert('退选成功!')</script>");
                databind();
            }
            else
            {
                Response.Write("<script> alert('退选失败!')</script>");
            }
        }
        else
        {
            Response.Write("<script> alert('已超过选题时间,不能退选!');history.go(-1)</script>");
        }
    }
Пример #3
0
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        int m = 0;

        Fannie.Student s = new Fannie.Student();
        for (int i = 0; i < gvStudent.Rows.Count; i++)
        {
            if (((CheckBox)(gvStudent.Rows[i].FindControl("cbSelect"))).Checked)
            {
                s.DeletOneStu(gvStudent.DataKeys[i].Value.ToString());
            }
            else
            {
                m++;
            }
        }
        if (m == gvStudent.Rows.Count)
        {
            Response.Write("<script>alert('请先选择需要删除的记录')</script>");
        }
        else
        {
            GetAllStu();
        }
    }
Пример #4
0
    private void GetStuDetail()
    {
        Fannie.Student s  = new Fannie.Student();
        DataSet        ds = s.GetOneStu(id);

        dvStu.DataKeyNames = new string[] { "StudentID" };
        dvStu.DataSource   = ds;
        dvStu.DataBind();
    }
Пример #5
0
 protected void ChangeChecked(object sender, EventArgs e)
 {
     Fannie.Student s = new Fannie.Student();
     for (int i = 0; i < gvStudent.Rows.Count; i++)
     {
         bool   b  = ((CheckBox)(gvStudent.Rows[i]).Cells[12].Controls[0]).Checked;
         string id = gvStudent.DataKeys[i].Value.ToString();
         s.ModifyAccepted(id, b);
     }
 }
Пример #6
0
    private void GetAllProfession()
    {
        Fannie.Student s  = new Fannie.Student();
        DataTable      dt = s.GetAllMajor().Tables[0];

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            ListItem li = new ListItem();
            li.Text = dt.Rows[i][1].ToString();
            ddlMajor.Items.Add(li);
            li = null;
        }
    }
Пример #7
0
    private void Ddind()
    {
        Fannie.Student stu = new Fannie.Student();
        DataSet        ds1 = new DataSet();
        DataSet        ds2 = new DataSet();
        DataTable      dt  = new DataTable();

        dt  = stu.GetProfession(sid).Tables[0];
        ds1 = stu.GetSuitSubject(sid);
        ds2 = ds1;
        //if (ds1.Tables[0].Rows.Count != 0)
        //{
        //    for (int j = 0; j < ds1.Tables[0].Rows.Count; j++)
        //    {
        //        bool bl = false;
        //        string[] prof;
        //        prof = ds1.Tables[0].Rows[j]["SuitProfession"].ToString().Split(',');
        //        for (int i = 0; i < prof.Length; i++)
        //        {
        //            if (prof[i] == dt.Rows[0][0].ToString())
        //            {
        //                bl = true;
        //                break;
        //            }
        //        }
        //        if (!bl)
        //        {
        //            ds2.Tables[0].Rows.RemoveAt(j);
        //        }
        //    }
        //}
        if (ds2.Tables[0].Rows.Count == 0)
        {
            Label1.Visible = true;
        }
        else
        {
            Label1.Visible = false;
            DataColumn dc = new DataColumn();
            dc.ColumnName = "SubNo";
            ds2.Tables[0].Columns.Add(dc);
            for (int i = 0; i < ds2.Tables[0].Rows.Count; i++)
            {
                ds2.Tables[0].Rows[i]["SubNo"] = (i + 1).ToString();
            }
            GridView1.DataKeyNames = new string[] { "SubjectID" };
            GridView1.DataSource   = ds2;
            GridView1.DataBind();
        }
    }
Пример #8
0
    private bool IsChosen()
    {
        Fannie.Student stu = new Fannie.Student();
        DataTable      dt  = stu.GetChosenSub(studentid).Tables[0];

        if (dt.Rows.Count != 0)
        {
            Response.Write("<script> alert('您已经选择了课题,请不要重复选择!')</script>");
            return(false);
        }
        else
        {
            return(true);
        }
    }
Пример #9
0
    private void GetAllStu()
    {
        Fannie.Student s  = new Fannie.Student();
        DataSet        ds = s.GetAllStu();
        DataColumn     dc = new DataColumn();

        dc.ColumnName = "AutoId";
        ds.Tables[0].Columns.Add(dc);
        gvStudent.DataKeyNames = new string[] { "StudentID" };
        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            ds.Tables[0].Rows[i]["AutoId"] = (i + 1).ToString();
        }
        gvStudent.DataSource = ds;
        gvStudent.DataBind();
    }
Пример #10
0
 protected void ChooseSubject_Click(object sender, EventArgs e)
 {
     Fannie.Student stu = new Fannie.Student();
     if (IsTime())
     {
         if (IsChosen())
         {
             if (IsMax())
             {
                 //conn.Open();
                 //string str = "insert into ChosenSubject values(@studentid,@subid)";
                 //SqlParameter[] pt = new SqlParameter[2] {
                 //    new SqlParameter("@studentid",studentid),
                 //    new SqlParameter("@subid",subid)};
                 //SqlCommand mycom = new SqlCommand(str, conn);
                 //mycom.Parameters.Add(pt[0]);
                 //mycom.Parameters.Add(pt[1]);
                 //int count = mycom.ExecuteNonQuery();
                 //conn.Close();
                 int count = stu.InsertChosen(studentid, subid);
                 if (count > 0)
                 {
                     //string sql = "update Subjects set NowPeople = NowPeople + 1 where SubjectID =" + subid;
                     //SqlCommand cmd2 = new SqlCommand();
                     //conn.Open();
                     //cmd2.CommandText = sql;
                     //cmd2.Connection = conn;
                     //cmd2.ExecuteNonQuery();
                     //conn.Close();
                     //stu.AddChosenPeople(subid);
                     Response.Write("<script> alert('选题成功!');window.location.href='ChosenSub.aspx';</script>");
                 }
                 else
                 {
                     Response.Write("<script> alert('选题失败!')</script>");
                 }
             }
             else
             {
                 Response.Write("<script> alert('此课题已被选满,请选其他课题');window.location.href='SubList.aspx';</script>");
             }
         }
     }
 }
Пример #11
0
    //数据绑定
    private void databind()
    {
        ChosenSub1.DataKeyNames = new string[] { "SubjectID" };
        Fannie.Student getSub = new Fannie.Student();
        DataTable      dt     = getSub.GetChosenSub(id).Tables[0];

        if (dt.Rows.Count == 0)
        {
            ChosenSub1.DataSource = getSub.GetChosenSub(id);
            ChosenSub1.DataBind();
            Label1.Visible = true;
        }
        else
        {
            ChosenSub1.DataSource = getSub.GetChosenSub(id);
            ChosenSub1.DataBind();
            Label1.Visible = false;
        }
    }
Пример #12
0
    //判断是否是选题时间
    private bool IsChosenTime()
    {
        DateTime  dtm = DateTime.Now;
        DataTable dt  = new DataTable();

        Fannie.Student stu = new Fannie.Student();
        dt = stu.GetChooseTime().Tables[0];
        DateTime begin = Convert.ToDateTime(dt.Rows[0]["ChooseBegin"].ToString());
        DateTime end   = Convert.ToDateTime(dt.Rows[0]["ChooseEnd"].ToString());

        if (dtm < begin || dtm > end)
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Пример #13
0
 protected void btnSelect_Click(object sender, EventArgs e)
 {
     if (tbID.Text != "")
     {
         Fannie.Student stu = new Fannie.Student();
         DataSet        ds  = stu.GetOneStu(tbID.Text.Trim());
         if (ds.Tables[0].Rows.Count == 0)
         {
             Response.Write("<script>alert('该学生不存在')</script>");
         }
         else
         {
             gvTeacher.Visible    = false;
             gvStudent.Visible    = true;
             gvStudent.DataSource = ds;
             gvStudent.DataBind();
         }
     }
 }
Пример #14
0
    private bool IsTime()
    {
        DateTime  dtm = DateTime.Now;
        DataTable dt  = new DataTable();

        Fannie.Student stu = new Fannie.Student();
        dt = stu.GetChooseTime().Tables[0];
        DateTime begin = Convert.ToDateTime(dt.Rows[0]["ChooseBegin"].ToString());
        DateTime end   = Convert.ToDateTime(dt.Rows[0]["ChooseEnd"].ToString());

        if (dtm < begin || dtm > end)
        {
            Response.Write("<script> alert('还未到选题时间,不能选题!');history.go(-1)</script>");
            return(false);
        }
        else
        {
            return(true);
        }
    }
Пример #15
0
    //protected void btnDown_Click(object sender, EventArgs e)
    //{
    //    Response.Clear();
    //    Response.AddHeader("content-disposition", "attachment;filename=subinfo.xls");
    //    Response.Charset = "utf-8";//设定输出的字符集
    //    Response.ContentType = "application/ms.xls";
    //    System.IO.StringWriter stringWrite = new System.IO.StringWriter();
    //    System.Web.UI.HtmlTextWriter htmlwrite = new HtmlTextWriter(stringWrite);
    //    gvStu.AllowPaging = false;
    //    GetOneSubStu();
    //    gvStu.RenderControl(htmlwrite);
    //    Response.Write(stringWrite.ToString());
    //    Response.End();
    //    gvStu.AllowPaging = true;
    //    GetOneSubStu();
    //}

    protected void RefuseStu_Click(object sender, EventArgs e)          //退选学生
    {
        LinkButton lb = sender as LinkButton;
        int        count;
        string     sid = lb.CommandArgument;

        Fannie.Student stu   = new Fannie.Student();
        int            subid = Convert.ToInt32(id);

        count = stu.DeleteChosen(sid);
        if (count > 0)
        {
            stu.ReduceChosenPeople(subid);
            Response.Write("<script> alert('退选成功!')</script>");
            GetOneSubStu();
        }
        else
        {
            Response.Write("<script> alert('退选失败!')</script>");
        }
    }
Пример #16
0
    private bool IsMax()
    {
        int     max;
        int     count;
        DataSet ds = new DataSet();

        Fannie.Student stu = new Fannie.Student();
        //string ifcan = "select MaxPeople, NowPeople from Subjects where SubjectID =" + subid;
        //SqlDataAdapter sda = new SqlDataAdapter(ifcan,conn);
        //sda.Fill(ds);
        ds    = stu.GetMaxandNowPeople(subid);
        max   = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());
        count = Convert.ToInt32(ds.Tables[0].Rows[0][1].ToString());
        if (max > count)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Пример #17
0
 protected void btnImport_Click(object sender, EventArgs e)
 {
     if (fuStu.HasFile)
     {
         string filename  = Server.HtmlEncode(fuStu.FileName);
         string extention = Path.GetExtension(filename);
         if (extention != ".xls" && extention != ".xlsx")
         {
             Response.Write("<script>alert('请选择正确的Excel文件!');</script>");
             return;
         }
         string upfilename = "~/DownLoadZone/" + DateTime.Now.ToString("yyyyMMddHHmmss") + extention;
         fuStu.SaveAs(Server.MapPath(upfilename));
         string ExcelConn = "";
         if (extention == ".xls")
         {
             // Excel 2007以前的版本
             ExcelConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(upfilename) + ";Extended Properties='Excel 8.0;HDR=YES;IMEX=2'";
         }
         else
         {
             // Excel 2007
             ExcelConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath(upfilename) + ";Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=2'";
         }
         DataTable dt = GetData(ExcelConn);
         File.Delete(Server.MapPath(upfilename));
         Fannie.Student s = new Fannie.Student();
         if (s.ImportStu(dt))
         {
             Response.Write("<script>alert('导入成功!');</script>");
         }
         else
         {
             Response.Write("<script>alert('导入失败,请检查是否EXCEL按照模版的样式输入数据或者是否重复的学号');</script>");
         }
     }
 }
Пример #18
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string id     = tbNo.Text.Trim();
        string name   = tbName.Text;
        string sex    = rblSex.SelectedValue;
        string level  = rblLeve.SelectedValue;
        string pname  = ddlMajor.Text;
        string sclass = tbClass.Text;
        string year   = tYeat.Value;
        string t1     = tbPhone.Text;
        string t2     = tbTel.Text;
        string emai   = tbEmail.Text;

        string[] str = new string[10] {
            id, name, sex, level, pname, sclass, year, t1, t2, emai
        };
        Fannie.Student s = new Fannie.Student();
        if (s.InsertOneStu(str) > 0)
        {
            Response.Write("<script>alert('新建成功!')</script>");
            string link = string.Format("~/Admin/ManageStu.aspx?id={0}", id);
            Response.Redirect(link);
        }
    }
Пример #19
0
 protected void gvStudent_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     Fannie.Student s = new Fannie.Student();
     s.DeletOneStu(gvStudent.DataKeys[e.RowIndex].Value.ToString());
     GetAllStu();
 }