Exemple #1
0
        /// <summary>
        /// 绑定数据到DataGrid控件MyDataGrid上
        /// </summary>
        private void BindDataGrid()
        {
            //创建操作员记录数据表类实例
            MemberOperate clsUser = new MemberOperate();
            DataTable     dt      = new DataTable();

            //获取记录数据
            if (Session["UserGroupID"].ToString() == "2" || Session["UserGroupID"].ToString() == "3")
            {
                dt = clsUser.Bind(Session["UserID"].ToString());
            }
            else
            {
                dt = clsUser.Bind("");
            }
            DataView dv = new DataView();

            dt.TableName = "Mem";
            if (dt != null)
            {
                dv.Table = dt;
                dv.Sort  = " father DESC";

                if (ViewState["Condition"] != null && ViewState["Condition"].ToString() != "")
                {
                    dv.RowFilter = ViewState["Condition"].ToString();
                }
                else
                {
                    dv = dt.DefaultView;
                }

                //新增ID自增值列绑定
                dt.Columns.Add(new DataColumn("idno", Type.GetType("System.Int32")));
                int intCountRecNum = dv.Count;  //获取数据表记录数
                for (int i = 0; i < intCountRecNum; i++)
                {
                    dv[i]["idno"] = i + 1;
                }
                MyDataGrid.DataSource = dv;
                int PageCount = 0;
                if (intCountRecNum % MyDataGrid.PageSize == 0)
                {
                    PageCount = intCountRecNum / MyDataGrid.PageSize;
                }
                else
                {
                    PageCount = intCountRecNum / MyDataGrid.PageSize + 1;
                }

                if (PageCount != 0 && MyDataGrid.CurrentPageIndex >= PageCount)
                {
                    MyDataGrid.CurrentPageIndex = PageCount - 1;
                }

                MyDataGrid.DataBind();
                lblRecNum.Text = intCountRecNum.ToString();     //显示总记录数
                ShowStats();                                    //显示页数信息
            }
        }
Exemple #2
0
        //private string strAgentID = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                //程序模块权限验证
                Authorization clsRighter = new Authorization("0201");

                //if (ViewState["OperateStatus"].Equals(null) && !clsRighter.Add)
                //{
                //    Common.ShowMsg("权限不足!");
                //    return;
                //}
                this.ddlStatus.Enabled = true;
                btnSave.Enabled        = clsRighter.Modify | clsRighter.Add;
                btnDelete.Enabled      = clsRighter.Delete;
                if (Session["UserGroupId"].ToString() == "2" || Session["UserGroupId"].ToString() == "3")
                {
                    this.ddlStatus.Enabled = false;
                }
                if (Request.QueryString["MemID"] != null && Request.QueryString["MemID"].ToString() != "")
                {
                    //ViewState["UserID"] = Request.QueryString["UserID"].ToString();
                    MemberOperate mem = new MemberOperate();
                    FillDataToCtrl(true);                       //填充数据到表单文本控件,下拉框控件
                    ViewState["OperateStatus"] = "EditData";    //置当前状态为编辑操作
                }
                else
                {
                    ViewState["CardID"] = "";
                    FillDataToCtrl(false);
                    ViewState["OperateStatus"] = "AddData";             //置当前状态为新增操作
                    this.btnDelete.Visible     = false;
                }
                if (Request.QueryString["AgentID"] != null && Request.QueryString["AgentID"].ToString() != "")
                {
                    if (Request.QueryString["AgentID"].ToString() != null && Request.QueryString["AgentID"].ToString() != "---请选择---" && Request.QueryString["AgentID"].ToString() != "")
                    {
                        this.txtAgent.Text = Request.QueryString["AgentID"].ToString();
                    }
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// 绑定数据到DataGrid控件MyDataGrid上
        /// </summary>
        private void BindDataGrid()
        {
            string MemID     = ddlMemID.SelectedItem.Value;
            string Condition = " 1=1 ";

            if (MemID != null && MemID != "---请选择---" && MemID != "")
            {
                Condition += " AND father='" + MemID + "'";
            }
            //			if(txtProgramName.Text.Trim()!="")
            //				Condition += " AND ModuleName = '" + txtProgramName.Text + "'";
            if (this.txtCardId.Text.Trim() != "")
            {
                Condition += " AND cardid like '%" + this.txtCardId.Text.Trim() + "%'";
            }

            if (this.txtMemName.Text.Trim() != "")
            {
                Condition += " and memname like '%" + this.txtMemName.Text.Trim() + "%'";
            }

            ViewState["Condition"] = Condition;

            //创建操作员记录数据表类实例
            MemberOperate clsMem = new MemberOperate();
            //获取记录数据
            DataTable dt = new DataTable();

            if (Session["UserGroupID"].ToString() == "2" || Session["UserGroupID"].ToString() == "3")
            {
                dt = clsMem.Bind(Session["UserID"].ToString());
            }
            else
            {
                dt = clsMem.Bind("");
            }

            DataView dv = new DataView();

            dt.TableName = "Mem";
            if (dt != null)
            {
                dv.Table = dt;
                dv.Sort  = " father DESC";

                if (ViewState["Condition"] != null && ViewState["Condition"].ToString() != "")
                {
                    dv.RowFilter = ViewState["Condition"].ToString();
                }
                else
                {
                    dv = dt.DefaultView;
                }

                //新增ID自增值列绑定
                dt.Columns.Add(new DataColumn("idno", Type.GetType("System.Int32")));
                int intCountRecNum = dv.Count;  //获取数据表记录数
                for (int i = 0; i < intCountRecNum; i++)
                {
                    dv[i]["idno"] = i + 1;
                }
                MyDataGrid.DataSource = dv;
                int PageCount = 0;
                if (intCountRecNum % MyDataGrid.PageSize == 0)
                {
                    PageCount = intCountRecNum / MyDataGrid.PageSize;
                }
                else
                {
                    PageCount = intCountRecNum / MyDataGrid.PageSize + 1;
                }

                if (PageCount != 0 && MyDataGrid.CurrentPageIndex >= PageCount)
                {
                    MyDataGrid.CurrentPageIndex = PageCount - 1;
                }

                MyDataGrid.DataBind();
                lblRecNum.Text = intCountRecNum.ToString();     //显示总记录数
                ShowStats();                                    //显示页数信息
            }
        }