Exemplo n.º 1
0
        void showGrid()
        {
            string sqlstr = " select std_id, std_name,sex,  dep_id, religion from student";

            StdGrid.DataSource = mydb.GetDataTable(sqlstr);
            StdGrid.DataBind();
            //park department at right position
            for (int idx = 0; idx < StdGrid.Rows.Count; idx++)
            {   //Department
                ((Label)StdGrid.Rows[idx].FindControl("Dep_Id")).Text = getDepName(((Label)StdGrid.Rows[idx].FindControl("Dep_Id")).Text.Trim());

                //Religion
                ((Label)StdGrid.Rows[idx].FindControl("Religion")).Text = getReligion(((Label)StdGrid.Rows[idx].FindControl("Religion")).Text.Trim());

                //Sex
                string sexS = ((Label)StdGrid.Rows[idx].FindControl("Sex")).Text;
                if (sexS == "True")
                {
                    ((Label)StdGrid.Rows[idx].FindControl("Sex")).Text = "男";
                }
                else
                {
                    ((Label)StdGrid.Rows[idx].FindControl("Sex")).Text = "女";
                }
            }
        }
Exemplo n.º 2
0
        void showGrid()
        {
            string sqlstr = " select std_id, std_name,sex,  dep_id, religion, club_id from student";

            StdGrid.DataSource = mydb.GetDataTable(sqlstr);
            StdGrid.DataBind();
            //park department at right position
            for (int idx = 0; idx < StdGrid.Rows.Count; idx++)
            {   //Department
                int selected = 0;
                foreach (DataRow row in depSet.Rows)
                {
                    if (row["dep_id"].ToString() == ((HiddenField)StdGrid.Rows[idx].FindControl("HDep_Id")).Value)
                    {
                        ((DropDownList)StdGrid.Rows[idx].FindControl("DepList")).SelectedIndex = selected;
                        break;
                    }

                    selected++;
                }
                //Department
                selected = 0;
                foreach (DataRow row in clubSet.Rows)
                {
                    if (row["club_id"].ToString() == ((HiddenField)StdGrid.Rows[idx].FindControl("HClub_Id")).Value)
                    {
                        ((DropDownList)StdGrid.Rows[idx].FindControl("ClubList")).SelectedIndex = selected;
                        break;
                    }

                    selected++;
                }
                //Religion
                selected = 0;
                foreach (DataRow row in ReligionSet.Rows)
                {
                    if (row["rel_id"].ToString() == ((HiddenField)StdGrid.Rows[idx].FindControl("Hrel_id")).Value)
                    {
                        ((DropDownList)StdGrid.Rows[idx].FindControl("ReligionList")).SelectedIndex = selected;
                        break;
                    }

                    selected++;
                }
                //Sex

                if ("True" == ((HiddenField)StdGrid.Rows[idx].FindControl("Hsex")).Value)
                {
                    ((RadioButtonList)StdGrid.Rows[idx].FindControl("SexList")).Items[0].Selected = true;
                    ((RadioButtonList)StdGrid.Rows[idx].FindControl("SexList")).Items[1].Selected = false;
                }
                else
                {
                    ((RadioButtonList)StdGrid.Rows[idx].FindControl("SexList")).Items[0].Selected = false;
                    ((RadioButtonList)StdGrid.Rows[idx].FindControl("SexList")).Items[1].Selected = true;
                }
            }
        }
        void showGrid()
        {
            string sqlstr = "select s.std_id as Std_Id, s.std_name as Std_Name, s.sex as Sex, d.Dep_Name as Dep_Name, c.club_name as Club_Name, r.Rel_Name as rel_Name ";

            sqlstr += " from student  s , department d, club c, religion r ";
            sqlstr += " where s.dep_id = d.dep_id";
            sqlstr += "    and s.club_id = c.club_id";
            sqlstr += "   and s.religion = r.rel_id ";
            string Qstring = "";

            if (Flag_Std_Id.Checked)
            {
                Qstring += " and s.std_id like " + mydb.qo("%" + Std_Id.Text.Trim() + "%");
            }
            if (Flag_Std_Name.Checked)
            {
                Qstring += " and s.std_name like " + mydb.qo("%" + Std_Name.Text.Trim() + "%");
            }
            if (Flag_Dep.Checked)
            {
                Qstring += " and s.dep_id = " + mydb.qo(DepList.SelectedValue.Trim());
            }
            if (Flag_Religion.Checked)
            {
                Qstring += " and s.religion = " + mydb.qo(ReligionList.SelectedValue.Trim());
            }
            if (Flag_Club.Checked)
            {
                Qstring += " and s.club_id = " + mydb.qo(ClubList.SelectedValue.Trim());
            }
            //string sexS = SexList.SelectedValue;
            if (Flag_Sex.Checked)
            {
                Qstring += " and s.sex = " + SexList.SelectedValue;
            }
            sqlstr += Qstring;

            StdGrid.DataSource = mydb.GetDataTable(sqlstr);
            StdGrid.DataBind();
            //park department at right position
            for (int idx = 0; idx < StdGrid.Rows.Count; idx++)
            {
                //Sex
                string sexS = ((LinkButton)StdGrid.Rows[idx].FindControl("Sex")).Text;
                if (sexS == "True")
                {
                    ((LinkButton)StdGrid.Rows[idx].FindControl("Sex")).Text = "男";
                }
                else
                {
                    ((LinkButton)StdGrid.Rows[idx].FindControl("Sex")).Text = "女";
                }
            }

            /*
             * string Qstring = "";
             * if(Flag_Std_Id.Checked)
             * {  if (Qstring == "")
             *      Qstring += " where std_id like" + mydb.qo("%" + Std_Id.Text.Trim() + "%");
             * else
             *      Qstring += " and std_id like " + mydb.qo("%" + Std_Id.Text.Trim() + "%");
             * }
             * if (Flag_Std_Name.Checked)
             * {
             *  if (Qstring == "")
             *      Qstring += " where std_name like " + mydb.qo("%" + Std_Name.Text.Trim()+ "%");
             *  else
             *      Qstring += " and std_name like " + mydb.qo("%" + Std_Name.Text.Trim() + "%");
             * }
             * if (Flag_Dep.Checked)
             * {
             *  if (Qstring == "")
             *      Qstring += " where dep_id = " + mydb.qo(DepList.SelectedValue.Trim());
             *  else
             *      Qstring += " and dep_id = " + mydb.qo(DepList.SelectedValue.Trim());
             * }
             * if (Flag_Religion.Checked)
             * {
             *  if (Qstring == "")
             *      Qstring += " where religion = " + mydb.qo( ReligionList.SelectedValue.Trim());
             *  else
             *      Qstring += " and religion = " + mydb.qo(ReligionList.SelectedValue.Trim());
             * }
             * if (Flag_Club.Checked)
             * {
             *  if (Qstring == "")
             *      Qstring += " where club_id = " + mydb.qo(ClubList.SelectedValue.Trim());
             *  else
             *      Qstring += " and club_id = " + mydb.qo(ClubList.SelectedValue.Trim());
             * }
             * //string sexS = SexList.SelectedValue;
             * if (Flag_Sex.Checked)
             * {
             *  if (Qstring == "")
             *      Qstring += " where sex = " + SexList.SelectedValue;
             *  else
             *      Qstring += " and sex = " + SexList.SelectedValue;
             * }
             * string sqlstr = "select * from student " + Qstring;
             *
             * StdGrid.DataSource = mydb.GetDataTable(sqlstr);
             * StdGrid.DataBind();
             * //park department at right position
             * for (int idx = 0; idx < StdGrid.Rows.Count; idx++)
             * {   //Department
             *  ((LinkButton)StdGrid.Rows[idx].FindControl("Dep_Id")).Text = getDepName(((LinkButton)StdGrid.Rows[idx].FindControl("Dep_Id")).Text.Trim());
             *
             *  //Religion
             *  ((LinkButton)StdGrid.Rows[idx].FindControl("Religion")).Text = getReligion(((LinkButton)StdGrid.Rows[idx].FindControl("Religion")).Text.Trim());
             *  //Club
             *  ((LinkButton)StdGrid.Rows[idx].FindControl("Club_Id")).Text = getClubName(((LinkButton)StdGrid.Rows[idx].FindControl("Club_Id")).Text.Trim());
             *
             *  //Sex
             *  string sexS = ((LinkButton)StdGrid.Rows[idx].FindControl("Sex")).Text;
             *  if (sexS == "True")
             *      ((LinkButton)StdGrid.Rows[idx].FindControl("Sex")).Text = "男";
             *  else
             *      ((LinkButton)StdGrid.Rows[idx].FindControl("Sex")).Text = "女";
             *
             * }  */
        }