Exemplo n.º 1
0
    //Display All The Schools
    public void BindDetails()
    {
        School.Registration obj = new School.Registration();

        DataSet ds = obj.DisplayCustomRegDet();

        //Bind Schools
        DropDownListSchool.DataTextField  = "schname";
        DropDownListSchool.DataValueField = "schid";
        DropDownListSchool.DataSource     = ds.Tables[0];
        DropDownListSchool.DataBind();
        DropDownListSchool.Items.Insert(0, new ListItem("Select Your School", ""));
        DropDownListState.Items.Insert(0, new ListItem("select your state", ""));
        DropDownListState.Items.Insert(0, new ListItem("select you city", ""));
        //Bind Classes
        DropDownListClass.DataTextField  = "clsnam";
        DropDownListClass.DataValueField = "clsid";
        DropDownListClass.DataSource     = ds.Tables[1];
        DropDownListClass.DataBind();
        DropDownListClass.Items.Insert(0, new ListItem("Select Your Class", ""));

        //Bind Sections
        DropDownListSection.DataTextField  = "secnam";
        DropDownListSection.DataValueField = "secid";
        DropDownListSection.DataSource     = ds.Tables[2];
        DropDownListSection.DataBind();
        DropDownListSection.Items.Insert(0, new ListItem("Select Your Section", ""));

        ds.Dispose();
        ds = null;
    }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Admin"] == null)
            {
                return;
            }
            Admin a = (Admin)Session["Admin"];

            LabelUserName.Text = a.MaGv1;
            if (!IsPostBack)
            {
                DropDownListClass.DataTextField  = "TenLop";
                DropDownListClass.DataValueField = "MaLop";
                DropDownListClass.DataSource     = Lop.getAllClass();
                DropDownListClass.DataBind();

                GridViewSinhVien.DataSource = SinhVien.getAllSinhVien();
                GridViewSinhVien.DataBind();

                DropDownListKhoa.DataTextField  = "TenKhoa1";
                DropDownListKhoa.DataValueField = "MaKhoa1";
                DropDownListKhoa.DataSource     = Khoa.GetKhoas();
                DropDownListKhoa.DataBind();
            }
        }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        role = (string)Session["role"];
        if (!this.IsPostBack)
        {
            role = "";
            DropDownListID.DataSource = SqlDataSource1;
            DropDownListID.DataBind();
            DropDownListID.Items.Add(new ListItem("Select ID"));
            DropDownListID.ClearSelection();
            DropDownListID.Items.FindByValue("Select ID").Selected = true;

            DropDownListClass.DataSource = SqlDataSource2;
            DropDownListClass.DataBind();
            DropDownListClass.Items.Add(new ListItem("Select Class"));
            DropDownListClass.ClearSelection();
            DropDownListClass.Items.FindByValue("Select Class").Selected = true;

            DropDownListCourse.DataSource = SqlDataSource3;
            DropDownListCourse.DataBind();
            DropDownListCourse.Items.Add(new ListItem("Select Course"));
            DropDownListCourse.ClearSelection();
            DropDownListCourse.Items.FindByValue("Select Course").Selected = true;
        }
        if ((string)Session["user"] == "")
        {
            ClientScript.RegisterStartupScript(Page.GetType(), "alert", "alert('Please log in first');window.location='LoginPage.aspx';", true);
        }
        user = "******" + (string)(Session["user"]);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        //获取所有班级
        SqlConnection  sqlConnection  = SqlTools.Connection();
        SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("select * from classinfo", sqlConnection);
        DataSet        dataSet        = new DataSet();

        sqlDataAdapter.Fill(dataSet);

        //所有班级绑定到班级下拉框
        DropDownListClass.DataSource    = dataSet;
        DropDownListClass.DataTextField = "name";
        DropDownListClass.DataBind();


        //获取所有系别
        SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter("select * from dept", sqlConnection);
        DataSet        dataSet1        = new DataSet();

        sqlDataAdapter1.Fill(dataSet1);

        //所有系别绑定到系别下拉框
        DropDownListDept.DataSource    = dataSet1;
        DropDownListDept.DataTextField = "name";
        DropDownListDept.DataBind();

        sqlConnection.Close();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //获取要编辑学生
            string  id = Request.QueryString["id"];
            Student s  = (Student)dao.getBody(id, 1);

            TextBoxID.Text       = s.ID1;
            TextBoxName.Text     = s.Name1;
            TextBoxPassword.Text = s.Password1;
            TextBoxBirth.Text    = s.Birth1;
            TextBoxEmail.Text    = s.Email1;
            TextBoxPhone.Text    = s.Telephone1;
            TextBoxAddress.Text  = s.Address1;
            TextBoxState.Text    = s.State1;
            if (s.Sex1.Equals("女"))
            {
                RadioButtonSexFemale.Checked = true;
            }
            else
            {
                RadioButtonSexMale.Checked = true;
            }


            //获取所有班级
            SqlConnection  sqlConnection  = SqlTools.Connection();
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter("select * from classinfo", sqlConnection);
            DataSet        dataSet        = new DataSet();
            sqlDataAdapter.Fill(dataSet);

            //所有班级绑定到班级下拉框
            DropDownListClass.DataSource    = dataSet;
            DropDownListClass.DataTextField = "name";
            DropDownListClass.DataBind();

            //下拉框选中该学生班级
            DropDownListClass.SelectedValue = s.Class1;

            //获取所有系别
            SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter("select * from dept", sqlConnection);
            DataSet        dataSet1        = new DataSet();
            sqlDataAdapter1.Fill(dataSet1);

            //所有系别绑定到系别下拉框
            DropDownListDept.DataSource    = dataSet1;
            DropDownListDept.DataTextField = "name";
            DropDownListDept.DataBind();
            //下拉框选中该学生系别
            DropDownListDept.SelectedValue = s.Dept1;


            sqlConnection.Close();
        }

        //不能改学号
        TextBoxID.Enabled = false;
    }
Exemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection sqlConnection = SqlTools.Connection();

        //获取所有课程名
        SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter("select * from course", sqlConnection);
        DataSet        dataSet1        = new DataSet();

        sqlDataAdapter1.Fill(dataSet1);

        //所有课程名绑定到课程号下拉框
        DropDownListCourse.DataSource    = dataSet1;
        DropDownListCourse.DataTextField = "name";
        DropDownListCourse.DataBind();

        //获取所有教室
        SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter("select * from classroom", sqlConnection);
        DataSet        dataSet2        = new DataSet();

        sqlDataAdapter2.Fill(dataSet2);

        //所有教室绑定到地点下拉框
        DropDownListPlace.DataSource    = dataSet2;
        DropDownListPlace.DataTextField = "id";
        DropDownListPlace.DataBind();


        //获取所有班级
        SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter("select * from classinfo", sqlConnection);
        DataSet        dataSet3        = new DataSet();

        sqlDataAdapter3.Fill(dataSet3);

        //所有班级绑定到班级下拉框
        DropDownListClass.DataSource    = dataSet3;
        DropDownListClass.DataTextField = "name";
        DropDownListClass.DataBind();


        sqlConnection.Close();
    }
Exemplo n.º 7
0
    protected void DropDownListID_SelectedIndexChanged(object sender, EventArgs e)
    {
        string id = DropDownListID.SelectedValue;
        string role2;

        if (id == "Select ID")
        {
            role = "";
            DropDownListCourse.Visible = false;
            course.Visible             = false;
            DropDownListClass.ClearSelection();
            DropDownListClass.Items.FindByValue("Select Class").Selected = true;
            DropDownListCourse.ClearSelection();
            DropDownListCourse.Items.FindByValue("Select Course").Selected = true;
        }
        else
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            conn.Open();
            string     uname = "SELECT role FROM UserData WHERE id = '" + id + "'";
            SqlCommand com   = new SqlCommand(uname, conn);
            role2           = com.ExecuteScalar().ToString().Trim();
            role            = role2;
            Session["role"] = role2;
            conn.Close();
            if (role2 == "Teacher")
            {
                DropDownListCourse.Visible      = true;
                RequiredFieldValidator4.Enabled = true;
                course.Visible = true;
            }
            else
            {
                DropDownListCourse.Visible      = false;
                RequiredFieldValidator4.Enabled = false;
                course.Visible = false;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //获取要编辑课程
            string id = Request.QueryString["id"];
            Exam   ex = (Exam)dao.getBody(id, 7);

            TextBoxID.Text   = ex.ID;
            TextBoxDate.Text = ex.Date;



            SqlConnection sqlConnection = SqlTools.Connection();

            //获取所有课程名
            SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter("select * from course", sqlConnection);
            DataSet        dataSet1        = new DataSet();
            sqlDataAdapter1.Fill(dataSet1);

            //所有课程名绑定到课程号下拉框
            DropDownListCourse.DataSource    = dataSet1;
            DropDownListCourse.DataTextField = "name";
            DropDownListCourse.DataBind();
            //选中
            DropDownListCourse.SelectedValue = ex.Course;


            //获取所有教室
            SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter("select * from classroom", sqlConnection);
            DataSet        dataSet2        = new DataSet();
            sqlDataAdapter2.Fill(dataSet2);

            //所有教室绑定到地点下拉框
            DropDownListPlace.DataSource    = dataSet2;
            DropDownListPlace.DataTextField = "id";
            DropDownListPlace.DataBind();
            //选中
            DropDownListPlace.SelectedValue = ex.Place;

            //获取所有班级
            SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter("select * from classinfo", sqlConnection);
            DataSet        dataSet3        = new DataSet();
            sqlDataAdapter3.Fill(dataSet3);

            //所有班级绑定到班级下拉框
            DropDownListClass.DataSource    = dataSet3;
            DropDownListClass.DataTextField = "name";
            DropDownListClass.DataBind();
            //选中
            DropDownListClass.SelectedValue = ex.ClassInfo;


            //绑定考试时间
            string[] dayAndNode = ex.Time.Split(',');
            for (int i = 0; i < dayAndNode.Length; i++)
            {
                //第一个字符为1说明是星期一
                if (dayAndNode[i].Substring(0, 1).Equals("1"))
                {
                    RadioButtonMonday.Checked        = true;
                    DropDownListMonday.SelectedValue = dayAndNode[i].Substring(2, 1);
                }
                else if (dayAndNode[i].Substring(0, 1).Equals("2"))
                {
                    RadioButtonTuesday.Checked        = true;
                    DropDownListTuesday.SelectedValue = dayAndNode[i].Substring(2, 1);
                }
                else if (dayAndNode[i].Substring(0, 1).Equals("3"))
                {
                    RadioButtonWed.Checked = true;
                    DropDownListWednesday.SelectedValue = dayAndNode[i].Substring(2, 1);
                }
                else if (dayAndNode[i].Substring(0, 1).Equals("4"))
                {
                    RadioButtonThur.Checked            = true;
                    DropDownListThursday.SelectedValue = dayAndNode[i].Substring(2, 1);
                }
                else if (dayAndNode[i].Substring(0, 1).Equals("5"))
                {
                    RadioButtonFri.Checked           = true;
                    DropDownListFriday.SelectedValue = dayAndNode[i].Substring(2, 1);
                }
            }


            sqlConnection.Close();
        }

        //不能改课程号
        TextBoxID.Enabled = false;
    }