private void searchContent()
        {
            try
            {
                string con=ConfigurationSettings.AppSettings["np"];
                SqlConnection  conn = new SqlConnection(con);
                conn.Open();

                SqlDataAdapter myCommand = new SqlDataAdapter();
                myCommand.SelectCommand = new SqlCommand("select * from Article where content like '%'+convert(nvarchar(255),@content)+'%' and checkup=0 order by dateandtime desc", conn);
                SqlParameter content=myCommand.SelectCommand.Parameters.Add("@content",SqlDbType.NText );
                content.Value=Request["keyword"].Trim() ;

                DataSet ds=new DataSet();
                myCommand.Fill(ds,"Article");

                MyDataGrid.DataSource=ds;
                MyDataGrid.DataBind();

                conn.Close();
            }
            catch(SqlException e)
            {
                Response.Write("Exception in Main: " + e.Message);
            }
        }
        private void searchTitle()
        {
            try
            {
                string con=ConfigurationSettings.AppSettings["np"];
                SqlConnection  conn = new SqlConnection(con);
                conn.Open();

                SqlDataAdapter myCommand = new SqlDataAdapter();
                myCommand.SelectCommand = new SqlCommand("select * from Article where title like '%'+@title+'%' and checkup=0 order by dateandtime desc", conn);
                SqlParameter title=myCommand.SelectCommand.Parameters.Add("@title",SqlDbType.NVarChar ,500);
                title.Value=Request["keyword"] ;

                DataSet ds=new DataSet();
                myCommand.Fill(ds,"Articl");

                MyDataGrid.DataSource=ds;
                MyDataGrid.DataBind();

                conn.Close();
            }
            catch(SqlException e)
            {
                Response.Write("Exception in Main: " + e.Message);
            }
        }
        private void getArticle()
        {
            try
            {
                string con=ConfigurationSettings.AppSettings["np"];
                SqlConnection  conn = new SqlConnection(con);
                conn.Open();

                SqlDataAdapter myCommand = new SqlDataAdapter();
                myCommand.SelectCommand = new SqlCommand("select * from Article  where checkup=0 order by articleid desc", conn);
                DataSet ds=new DataSet();
                myCommand.Fill(ds,"Article");

            MyDataGrid.DataSource=ds;
            MyDataGrid.DataBind();
            lblCurrentIndex.Text="第"+((Int32)MyDataGrid.CurrentPageIndex+1)+"页";
            lblPageCount.Text="/共"+MyDataGrid.PageCount+"页";

                conn.Close();
            }
            catch(SqlException e)
            {
                Response.Write("Exception in Main: " + e.Message);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 绑定数据到DataGrid控件MyDataGrid上
        /// </summary>
        private void BindDataGrid()
        {
            //创建操作员记录数据表类实例
            MemCardLevelOperate clsRecord = new MemCardLevelOperate();
            //获取记录数据
            DataTable dt = new DataTable();

            if (Session["UserGroupID"].ToString() == "2" || Session["UserGroupID"].ToString() == "3")
            {
                dt = clsRecord.Bind(Convert.ToDateTime(this.txtBeginDate.Text.Trim()).ToShortDateString(), Convert.ToDateTime(this.txtEndDate.Text.Trim()).AddDays(1).ToShortDateString(), Session["UserID"].ToString());
            }
            else
            {
                dt = clsRecord.Bind(Convert.ToDateTime(this.txtBeginDate.Text.Trim()).ToShortDateString(), Convert.ToDateTime(this.txtEndDate.Text.Trim()).AddDays(1).ToShortDateString(), "");
            }
            DataView dv = new DataView();

            dt.TableName = "Mem_Log";
            if (dt != null)
            {
                dv.Table = dt;
                dv.Sort  = " operatetime 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();                                    //显示页数信息
            }
        }
Exemplo n.º 5
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();                                    //显示页数信息
            }
        }
Exemplo n.º 6
0
        private void getchangeArticle()
        {
            MyDataGrid.DataSource = null;
            DataSet ds = new DataSet();

            ds.Clear();
            try
            {
                string        con  = ConfigurationSettings.AppSettings["np"];
                SqlConnection conn = new SqlConnection(con);
                conn.Open();

                SqlDataAdapter myCommand = new SqlDataAdapter();
                myCommand.SelectCommand = new SqlCommand("select * from Article where classname=" + "'" + DropDownClass.Text + "'" + " order by dateandtime desc", conn);
                myCommand.Fill(ds);

                MyDataGrid.DataSource = ds;
                MyDataGrid.DataBind();
                lblCurrentIndex.Text = "第" + ((Int32)MyDataGrid.CurrentPageIndex + 1) + "页";
                lblPageCount.Text    = "/共" + MyDataGrid.PageCount + "页";
            }
            catch (SqlException ex1)
            {
                Response.Write("Exception in Main: " + ex1.Message);
            }
        }
Exemplo n.º 7
0
        private void getArticle()
        {
            try
            {
                string        con  = ConfigurationSettings.AppSettings["np"];
                SqlConnection conn = new SqlConnection(con);
                conn.Open();

                SqlDataAdapter myCommand = new SqlDataAdapter();   
                myCommand.SelectCommand  = new SqlCommand("select * from Article where classname=@classname and checkup=1 order by dateandtime desc", conn);
                SqlParameter classname   = myCommand.SelectCommand.Parameters.Add("@classname", SqlDbType.Char, 200);
                classname.Value = Request["classname"];
                DataSet ds = new DataSet();
                myCommand.Fill(ds);

                MyDataGrid.DataSource = ds;
                MyDataGrid.DataBind();

                lblCurrentIndex.Text = "第" + ((Int32)MyDataGrid.CurrentPageIndex + 1) + "页";
                lblPageCount.Text    = "/共" + MyDataGrid.PageCount + "页";
                conn.Close();
            }
            catch (SqlException e)
            {
                Response.Write("Exception in Main: " + e.Message);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            FileStream   fs     = new FileStream(Server.MapPath("schemadata.xml"), FileMode.Open, FileAccess.Read);
            StreamReader reader = new StreamReader(fs);

            ds.ReadXml(reader);
            fs.Close();

            DataView Source = new DataView(ds.Tables[0]);

            // Use the LiteralControl constructor to create a new
            // instance of the class.
            LiteralControl myLiteral = new LiteralControl();

            // Set the LiteralControl.Text property to an HTML
            // string and the TableName value of a data source.
            myLiteral.Text = "<h6><font face=\"verdana\">Caching an XML Table: " + Source.Table.TableName + " </font></h6>";

            MyDataGrid.DataSource = Source;
            MyDataGrid.DataBind();

            TimeMsg.Text = DateTime.Now.ToString("G");
        }
Exemplo n.º 9
0
        private void getRemark()
        {
            try
            {
                string        con  = ConfigurationSettings.AppSettings["np"];
                SqlConnection conn = new SqlConnection(con);
                conn.Open();
                     
                SqlDataAdapter myCommand = new SqlDataAdapter();   
                myCommand.SelectCommand  = new SqlCommand("select * from Remark where articleid=@articleid", conn);
                SqlParameter artid       = myCommand.SelectCommand.Parameters.Add("@articleid", SqlDbType.BigInt);
                artid.Value = Request["articleid"];



                DataSet ds = new DataSet();
                myCommand.Fill(ds, "Article");
                   

                MyDataGrid.DataSource = ds;
                MyDataGrid.DataBind();

                lblCurrentIndex.Text = "第" + ((Int32)MyDataGrid.CurrentPageIndex + 1) + "页";
                lblPageCount.Text    = "/共" + MyDataGrid.PageCount + "页";



                conn.Close();
            }
            catch (SqlException e)
            {
                Response.Write("Exception in Main: " + e.Message);
            }
        }
Exemplo n.º 10
0
        private void getAdmin()
        {
            try
            {
                string        con  = ConfigurationSettings.AppSettings["np"];
                SqlConnection conn = new SqlConnection(con);
                conn.Open();
                     
                SqlDataAdapter myCommand = new SqlDataAdapter();   
                myCommand.SelectCommand  = new SqlCommand("select * from Admin where username!='admin'", conn);

                myCommand.Fill(ds, "Admin");
                    
                MyDataGrid.DataSource = ds;
                MyDataGrid.DataBind();

                lblCurrentIndex.Text = "第" + ((Int32)MyDataGrid.CurrentPageIndex + 1) + "页";
                lblPageCount.Text    = "/共" + MyDataGrid.PageCount + "页";
                conn.Close();
            }
            catch (SqlException e)
            {
                Response.Write("Exception in Main: " + e.Message);
            }
        }
Exemplo n.º 11
0
        protected void submit_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["MSSQL"].ConnectionString);
                try
                {
                    conn.Open();
                    SqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "INSERT INTO mssql(first, last, age, gender, GAResident, USCitizen, BorninUS) VALUES('" + First.Text + "', '" + Last.Text + "','" + List.Text + "', '" + RBList.Text + "', '" + GAResident.Checked + "', '" + USCitizen.Checked + "', '" + BorninUS.Checked + "')";
                    try
                    {
                        cmd.ExecuteNonQuery();
                        status.Text = "Insert Success";
                        MyDataGrid.DataBind();
                    }
                    catch (Exception ex2)
                    {
                        status.Text = "Failed insert" + ex2.Message;
                    }
                    conn.Close();

                    conn.Dispose();
                }
                catch (Exception ex)
                {
                    status.Text = "Failed to connect" + ex.Message;
                }
            }
        }
Exemplo n.º 12
0
        private void searchAuthor()
        {
            try
            {
                string        con  = ConfigurationSettings.AppSettings["np"];
                SqlConnection conn = new SqlConnection(con);
                conn.Open();
                     
                SqlDataAdapter myCommand = new SqlDataAdapter();   
                myCommand.SelectCommand  = new SqlCommand("select * from Remark where username like '%'+@username+'%'", conn);
                SqlParameter username    = myCommand.SelectCommand.Parameters.Add("@username", SqlDbType.NVarChar, 50);
                username.Value = Request["keyword"];

                DataSet ds = new DataSet();
                myCommand.Fill(ds, "Article");
                    
                MyDataGrid.DataSource = ds;
                MyDataGrid.DataBind();


                conn.Close();
            }
            catch (SqlException e)
            {
                Response.Write("Exception in Main: " + e.Message);
            }
        }
Exemplo n.º 13
0
        public void BindGrid()
        {
            DataSet ds = new DataSet();

            ds = baseOperation.GetStaffDataSet("");
            MyDataGrid.DataSource = ds.Tables[0].DefaultView;
            MyDataGrid.DataBind();
            ShowStats();
        }
Exemplo n.º 14
0
        public void BindGrid()
        {
            DataSet ds = new DataSet();

            ds = dal.GetList("");
            if (!(ds.Tables[0].Columns.Count == 0))
            {
                MyDataGrid.DataSource = ds.Tables[0].DefaultView;
                MyDataGrid.DataBind();
                ShowStats();
            }
        }
Exemplo n.º 15
0
        public void BindGrid()
        {
            DataSet ds = new DataSet();

            ds = baseOperation.GetFunctionDataSet();

            if (!(ds.Tables[0].Columns.Count == 0))
            {
                MyDataGrid.DataSource = ds.Tables[0].DefaultView;
                MyDataGrid.DataBind();
                ShowStats();
            }
        }
        /// <summary>
        /// 绑定数据到DataGrid控件MyDataGrid上
        /// </summary>
        private void BindDataGrid()
        {
            OperatorAuthorization clsRight = new OperatorAuthorization(); //创建用户权限数据表操作类实例
            DataTable             dt       = clsRight.BindData();         //获取绑定数据的数据集对象

            if (dt != null)
            {
                int intCountRecNum = dt.Rows.Count;     //获取数据表记录数
                MyDataGrid.DataSource = dt.DefaultView;
                MyDataGrid.DataBind();
                lblRecNum.Text = intCountRecNum.ToString(); //显示总记录数
                ShowStats();                                //显示页数信息
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 绑定数据到DataGrid控件MyDataGrid上
        /// </summary>
        private void BindDataGrid()
        {
            //创建操作员记录数据表类实例
            SMSTemplate sms = new SMSTemplate();
            //获取记录数据
            DataTable dt = sms.Bind();
            DataView  dv = new DataView();

            dt.TableName = "SMSTemplate";
            if (dt != null)
            {
                dv.Table = dt;

                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();                                    //显示页数信息
            }
        }
        protected void tvCategory_SelectedNodeChanged(object sender, EventArgs e)
        {
            string id = tvCategory.SelectedNode.Value;
            OperatorAuthorization clsRight = new OperatorAuthorization(); //创建用户权限数据表操作类实例
            DataTable             dt       = clsRight.BindNodes(id);      //获取绑定数据的数据集对象

            if (dt != null)
            {
                int intCountRecNum = dt.Rows.Count;     //获取数据表记录数
                MyDataGrid.DataSource = dt.DefaultView;
                MyDataGrid.DataBind();
                lblRecNum.Text = intCountRecNum.ToString(); //显示总记录数
                ShowStats();                                //显示页数信息
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 绑定数据到DataGrid控件MyDataGrid上
        /// </summary>
        private void BindDataGrid()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("FileName", Type.GetType("System.String")));
            dt.Columns.Add(new DataColumn("FileSize", Type.GetType("System.Int64")));
            dt.Columns.Add(new DataColumn("CreateDate", Type.GetType("System.DateTime")));
            dt.Columns.Add(new DataColumn("LastModifyDate", Type.GetType("System.DateTime")));

            DirectoryInfo dir = new DirectoryInfo(Server.MapPath(BackupPath));

            foreach (FileSystemInfo fsi in dir.GetFileSystemInfos())
            {
                try
                {
                    DateTime CreateTime = fsi.CreationTime;
                    DateTime ModifyTime = fsi.LastWriteTime;
                    int      subLength  = 25;
                    if (fsi is FileInfo)
                    {
                        DataRow  drTmp = dt.NewRow();
                        FileInfo f     = (FileInfo)fsi;
                        //此 if 语句只是确保不要将文件的名称变得太短!
                        if (f.Name.Length < subLength)
                        {
                            subLength = f.Name.Length;
                        }
                        drTmp[0] = f.Name.Substring(0, subLength);
                        drTmp[1] = (f.Length) / 1024;
                        drTmp[2] = CreateTime;
                        drTmp[3] = ModifyTime;
                        dt.Rows.Add(drTmp);
                    }
                }
                catch (Exception)
                {
                    Common.ShowMsg("系统提示:查询文件列表失败!");
                }
            }
            if (dt != null)
            {
                int intCountRecNum = dt.Rows.Count;     //获取数据表记录数
                MyDataGrid.DataSource = dt.DefaultView;
                MyDataGrid.DataBind();
                lblRecNum.Text = intCountRecNum.ToString();     //显示总记录数
                ShowStats();                                    //显示页数信息
            }
        }
Exemplo n.º 20
0
        //数据初始化
        public void BindGrid(String strWhere)
        {
            DataSet ds = new DataSet();

            ds = dal.GetList(strWhere);
            if (ds != null && (ds.Tables[0].Columns.Count > 0))
            {
                createDataTable();
                DataTable dt     = ds.Tables[0];
                Hashtable ztHt   = ztDal.GetHashTable("");
                Hashtable deptHt = deptDal.GetHashTable("");
                Hashtable emplHt = emplDal.GetHashTable("");
                Hashtable kjHt   = kjDal.GetHashtable("");
                Hashtable sbHt   = sbDal.GetHashTable("");
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr    = dt.Rows[i];
                    DataRow drnew = showData.NewRow();
                    drnew["BARCODE"]             = dr["BARCODE"];
                    drnew["ASSETCODE"]           = dr["ASSETCODE"];
                    drnew["ASSETNAME"]           = dr["ASSETNAME"];
                    drnew["KUAIJILEIBIE"]        = dr["KUAIJILEIBIE"];
                    drnew["KUAIJILEIBIENAME"]    = kjHt == null ? "" : kjHt[dr["KUAIJILEIBIE"].ToString().Trim()];
                    drnew["SHEBEILEIBIE"]        = dr["SHEBEILEIBIE"];
                    drnew["SHEBEILEIBIENAME"]    = sbHt == null ? "" : sbHt[dr["SHEBEILEIBIE"].ToString().Trim()];
                    drnew["GUIGEXINGHAO"]        = dr["GUIGEXINGHAO"];
                    drnew["ZICHANZHUANGTAI"]     = dr["ZICHANZHUANGTAI"];
                    drnew["ZICHANZHUANGTAINAME"] = ztHt == null ? "" : ztHt[dr["ZICHANZHUANGTAI"].ToString().Trim()];
                    drnew["CUNFANGDIDIAN"]       = dr["CUNFANGDIDIAN"];
                    drnew["CUNFANGDIDIANNAME"]   = deptHt == null ? "" : deptHt[dr["CUNFANGDIDIAN"].ToString().Trim()];
                    drnew["SHIYONGBUMEN"]        = dr["SHIYONGBUMEN"];
                    drnew["SHIYONGBUMENNAME"]    = deptHt == null ? "" : deptHt[dr["SHIYONGBUMEN"].ToString().Trim()];
                    drnew["GUYUANBIANHAO"]       = dr["GUYUANBIANHAO"];
                    drnew["GUYUANBIANHAONAME"]   = emplHt == null ? "" : emplHt[dr["GUYUANBIANHAO"].ToString().Trim()];
                    drnew["ZICHANSHIBEIMA"]      = dr["ZICHANSHIBEIMA"];
                    drnew["BEIZHU"]        = dr["BEIZHU"];
                    drnew["XULIEHAO"]      = dr["XULIEHAO"];
                    drnew["SUPPLIER"]      = dr["SUPPLIER"];
                    drnew["ADMINDEPT"]     = dr["ADMINDEPT"];
                    drnew["ASSETCLASSIFY"] = dr["ASSETCLASSIFY"];
                    showData.Rows.Add(drnew);
                }
            }

            MyDataGrid.DataSource = new DataView(showData);
            MyDataGrid.DataBind();
            ShowStats();
        }
Exemplo n.º 21
0
    void BindGrid()
    {
        // Command  and connection string
        String strCmd = "SELECT * FROM tbWeddings";

        OleDbDataAdapter da = new OleDbDataAdapter(strCmd, m_connString);
        DataSet          ds = new DataSet();

        da.Fill(ds, "tbWeddings");

        ds.Tables["tbWeddings"].Columns.Add("checked", System.Type.GetType("System.Boolean"));
        foreach (DataRow row in ds.Tables["tbWeddings"].Rows)
        {
            row["checked"] = false;
        }

        if (Page.IsPostBack)
        {
            if (Request.Form["grpSelect"] != null)
            {
                string    selectedId = Request.Form["grpSelect"].ToString();
                DataRow[] rows       = ds.Tables["tbWeddings"].Select("id=" + selectedId);

                rows[0]["checked"] = true;

                string content = GetContent();

                content = content.Replace("[[parents]]", (string)rows[0]["fldParents"]);
                content = content.Replace("[[child's sex]]", (string)rows[0]["fldChildSex"]);
                content = content.Replace("[[child's name]]", (string)rows[0]["fldChildName"]);
                content = content.Replace("[[fiance(e)]]", (string)rows[0]["fldFiance"]);
                content = content.Replace("[[date]]", ((DateTime)rows[0]["fldDate"]).ToLongDateString());
                content = content.Replace("[[church]]", (string)rows[0]["fldChurch"]);
                content = content.Replace("[[city]]", (string)rows[0]["fldCity"]);
                content = content.Replace("[[state]]", (string)rows[0]["fldState"]);

                editor.Content = content;
            }
        }

        MyDataGrid.DataSource = ds;
        MyDataGrid.DataBind();
    }
Exemplo n.º 22
0
        //数据初始化
        public void BindGrid(String strWhere)
        {
            DataSet ds = new DataSet();

            ds = dal.GetList(strWhere);
            if (ds != null && (ds.Tables[0].Columns.Count > 0))
            {
                createDataTable();
                System.Data.DataTable dt = ds.Tables[0];

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr    = dt.Rows[i];
                    DataRow drnew = showData.NewRow();
                    drnew["BARCODE"]   = dr["BARCODE"];
                    drnew["ASSETCODE"] = dr["ASSETCODE"];
                    drnew["RESULT"]    = dr["RESULT"];
                    if (dr["RESULT"].ToString().Equals("-1"))
                    {
                        drnew["RESULTNAME"] = "资产不存在";
                    }
                    else if (dr["RESULT"].ToString().Equals("0"))
                    {
                        drnew["RESULTNAME"] = "资产信息有误";
                    }
                    else if (dr["RESULT"].ToString().Equals("1"))
                    {
                        drnew["RESULTNAME"] = "资产信息正确";
                    }
                    else
                    {
                        drnew["RESULTNAME"] = "";
                    }
                    drnew["COMMENTS"]   = dr["COMMENTS"];
                    drnew["SCANPERSON"] = dr["SCANPERSON"];
                    drnew["SCANTIME"]   = dr["SCANTIME"];
                    showData.Rows.Add(drnew);
                }
            }
            MyDataGrid.DataSource = new DataView(showData);
            MyDataGrid.DataBind();
            ShowStats();
        }
Exemplo n.º 23
0
        protected void get_files()
        {
            string[] backup_files = System.IO.Directory.GetFiles(app_data_folder, "*.bak");

            if (backup_files.Length == 0)
            {
                MyDataGrid.Visible = false;
                return;
            }

            MyDataGrid.Visible = true;

            // sort the files
            ArrayList list = new ArrayList();

            list.AddRange(backup_files);
            list.Sort();

            DataTable dt = new DataTable();
            DataRow   dr;

            dt.Columns.Add(new DataColumn("file", typeof(String)));
            dt.Columns.Add(new DataColumn("url", typeof(String)));

            for (int i = 0; i < list.Count; i++)
            {
                dr = dt.NewRow();

                string just_file = System.IO.Path.GetFileName((string)list[i]);
                dr[0] = just_file;
                dr[1] = "download_file.aspx?which=backup&filename=" + just_file;

                dt.Rows.Add(dr);
            }

            DataView dv = new DataView(dt);

            MyDataGrid.DataSource = dv;
            MyDataGrid.DataBind();
        }
Exemplo n.º 24
0
 protected void BindGrid()
 {
     if (!this.IsPostBack)
     {
         string constr = ConfigurationManager.ConnectionStrings["WebAppConnString"].ConnectionString;
         using (MySqlConnection con = new MySqlConnection(constr))
         {
             using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM database.email WHERE email.emailFrom='" + (String)(Session["uemail"]) + "' ORDER BY date DESC  "))
             {
                 using (MySqlDataAdapter sda = new MySqlDataAdapter())
                 {
                     cmd.Connection    = con;
                     sda.SelectCommand = cmd;
                     using (DataTable dt = new DataTable())
                     {
                         sda.Fill(dt);
                         MyDataGrid.DataSource = dt;
                         MyDataGrid.DataBind();
                     }
                 }
             }
         }
     }
 }
 protected void BindGrid()
 {
     if (!this.IsPostBack)
     {
         string constr = ConfigurationManager.ConnectionStrings["WebAppConnString"].ConnectionString;
         using (MySqlConnection con = new MySqlConnection(constr))
         {
             using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM database.activite WHERE activite.iduser='******' AND activite.nature='Sorties' "))
             {
                 using (MySqlDataAdapter sda = new MySqlDataAdapter())
                 {
                     cmd.Connection    = con;
                     sda.SelectCommand = cmd;
                     using (DataTable dt = new DataTable())
                     {
                         sda.Fill(dt);
                         MyDataGrid.DataSource = dt;
                         MyDataGrid.DataBind();
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 26
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();                                    //显示页数信息
            }
        }
Exemplo n.º 27
0
        protected void DropDownClass_SelectedIndexChanged(object sender, EventArgs e)
        {
            MyDataGrid.CurrentPageIndex = 0;
            lblCurrentIndex.Text        = "第1页";
            MyDataGrid.DataSource       = null;
            DataSet ds = new DataSet();

            ds.Clear();
            if (DropDownClass.SelectedIndex == 1)
            {
                try
                {
                    string        con  = ConfigurationSettings.AppSettings["np"];
                    SqlConnection conn = new SqlConnection(con);
                    conn.Open();

                    SqlDataAdapter myCommand = new SqlDataAdapter();   
                    myCommand.SelectCommand  = new SqlCommand("select * from Article where classname=" + "'体育'" + "and checkup=1 order by dateandtime desc", conn);
                    myCommand.Fill(ds);

                    MyDataGrid.DataSource = ds;
                    MyDataGrid.DataBind();

                    SqlCommand cmd = new SqlCommand("select * from Class where classname=" + "'体育'", conn);

                    SqlDataReader rd;
                    rd = cmd.ExecuteReader();
                    if (rd.Read() == true)
                    {
                        NameLabel.Text = "新闻数量:" + rd.GetInt32(2) + " 篇";
                        rd.Close();
                    }
                    SqlCommand cmd1 = new SqlCommand("select classid from Class where className=" + "'体育'", conn);
                    rd = cmd1.ExecuteReader();
                    int id;
                    if (rd.Read() == true)
                    {
                        id = Convert.ToInt32(rd["classid"]);
                        DropDownClass.SelectedIndex = id;
                    }
                    conn.Close();
                }
                catch (SqlException ex)
                {
                    Response.Write("Exception in Main: " + ex.Message);
                }
            }
            if (DropDownClass.SelectedIndex == 0)
            {
                try
                {
                    string        con  = ConfigurationSettings.AppSettings["np"];
                    SqlConnection conn = new SqlConnection(con);
                    conn.Open();

                    SqlDataAdapter myCommand = new SqlDataAdapter();  
                    myCommand.SelectCommand  = new SqlCommand("select * from Article where classname=" + "'新闻'" + "and checkup=1 order by dateandtime desc", conn);
                    myCommand.Fill(ds);

                    MyDataGrid.DataSource = ds;
                    MyDataGrid.DataBind();

                    SqlCommand cmd = new SqlCommand("select * from Class where classname=" + "'新闻'", conn);

                    SqlDataReader rd;
                    rd = cmd.ExecuteReader();
                    if (rd.Read() == true)
                    {
                        NameLabel.Text = "新闻数量:" + rd.GetInt32(2) + " 篇";
                        rd.Close();
                    }
                    SqlCommand cmd1 = new SqlCommand("select classid from Class where className=" + "'新闻'", conn);
                    rd = cmd1.ExecuteReader();
                    int id;
                    if (rd.Read() == true)
                    {
                        id = Convert.ToInt32(rd["classid"]);
                        DropDownClass.SelectedIndex = id;
                    }
                    conn.Close();
                }
                catch (SqlException ex)
                {
                    Response.Write("Exception in Main: " + ex.Message);
                }
            }
            if (DropDownClass.SelectedIndex == 2)
            {
                try
                {
                    string        con  = ConfigurationSettings.AppSettings["np"];
                    SqlConnection conn = new SqlConnection(con);
                    conn.Open();

                    SqlDataAdapter myCommand = new SqlDataAdapter();   
                    myCommand.SelectCommand  = new SqlCommand("select * from Article where classname=" + "'科技'" + "and checkup=1 order by dateandtime desc", conn);
                    myCommand.Fill(ds);

                    MyDataGrid.DataSource = ds;
                    MyDataGrid.DataBind();

                    SqlCommand cmd = new SqlCommand("select * from Class where classname=" + "'科技'", conn);

                    SqlDataReader rd;
                    rd = cmd.ExecuteReader();
                    if (rd.Read() == true)
                    {
                        NameLabel.Text = "新闻数量:" + rd.GetInt32(2) + " 篇";
                        rd.Close();
                    }
                    SqlCommand cmd1 = new SqlCommand("select classid from Class where className=" + "'科技'", conn);
                    rd = cmd1.ExecuteReader();
                    int id;
                    if (rd.Read() == true)
                    {
                        id = Convert.ToInt32(rd["classid"]);
                        DropDownClass.SelectedIndex = id;
                    }
                    conn.Close();
                }
                catch (SqlException ex)
                {
                    Response.Write("Exception in Main: " + ex.Message);
                }
            }
        }
Exemplo n.º 28
0
        public void PagerButtonClick(Object sender, EventArgs e)
        {
            string arg = ((LinkButton)sender).CommandArgument;

            switch (arg)
            {
            case ("next"):
            {
                MyDataGrid.DataSource = null;
                DataSet ds = new DataSet();
                ds.Clear();
                try
                {
                    string        con  = ConfigurationSettings.AppSettings["np"];
                    SqlConnection conn = new SqlConnection(con);
                    conn.Open();

                    SqlDataAdapter myCommand = new SqlDataAdapter();  
                    myCommand.SelectCommand  = new SqlCommand("select * from Article where classname=" + "'" + DropDownClass.Text + "'" + " order by dateandtime desc", conn);
                    myCommand.Fill(ds);

                    MyDataGrid.DataSource = ds;
                    MyDataGrid.DataBind();
                    if (MyDataGrid.CurrentPageIndex < (MyDataGrid.PageCount - 1))
                    {
                        MyDataGrid.CurrentPageIndex++;
                    }
                }
                catch (SqlException ex1)
                {
                    Response.Write("Exception in Main: " + ex1.Message);
                }


                break;
            }

            case ("prev"):
            {
                MyDataGrid.DataSource = null;
                DataSet ds = new DataSet();
                ds.Clear();
                try
                {
                    string        con  = ConfigurationSettings.AppSettings["np"];
                    SqlConnection conn = new SqlConnection(con);
                    conn.Open();

                    SqlDataAdapter myCommand = new SqlDataAdapter();
                    myCommand.SelectCommand = new SqlCommand("select * from Article where classname=" + "'" + DropDownClass.Text + "'" + " order by dateandtime desc", conn);
                    myCommand.Fill(ds);

                    MyDataGrid.DataSource = ds;
                    MyDataGrid.DataBind();
                    if (MyDataGrid.CurrentPageIndex > 0)
                    {
                        MyDataGrid.CurrentPageIndex--;
                    }
                }
                catch (SqlException ex1)
                {
                    Response.Write("Exception in Main: " + ex1.Message);
                }
                break;
            }

            case ("last"):
            {
                MyDataGrid.DataSource = null;
                DataSet ds = new DataSet();
                ds.Clear();
                try
                {
                    string        con  = ConfigurationSettings.AppSettings["np"];
                    SqlConnection conn = new SqlConnection(con);
                    conn.Open();

                    SqlDataAdapter myCommand = new SqlDataAdapter();   
                    myCommand.SelectCommand  = new SqlCommand("select * from Article where classname=" + "'" + DropDownClass.Text + "'" + " order by dateandtime desc", conn);
                    myCommand.Fill(ds);

                    MyDataGrid.DataSource = ds;
                    MyDataGrid.DataBind();
                    MyDataGrid.CurrentPageIndex = (MyDataGrid.PageCount - 1);
                }
                catch (SqlException ex1)
                {
                    Response.Write("Exception in Main: " + ex1.Message);
                }

                break;
            }

            case ("first"):
            {
                MyDataGrid.DataSource = null;
                DataSet ds = new DataSet();
                ds.Clear();
                try
                {
                    string        con  = ConfigurationSettings.AppSettings["np"];
                    SqlConnection conn = new SqlConnection(con);
                    conn.Open();

                    SqlDataAdapter myCommand = new SqlDataAdapter();  
                    myCommand.SelectCommand  = new SqlCommand("select * from Article where classname=" + "'" + DropDownClass.Text + "'" + " order by dateandtime desc", conn);
                    myCommand.Fill(ds);

                    MyDataGrid.DataSource = ds;
                    MyDataGrid.DataBind();
                    MyDataGrid.CurrentPageIndex = 0;
                }
                catch (SqlException ex1)
                {
                    Response.Write("Exception in Main: " + ex1.Message);
                }

                break;
            }
            }
            getchangeArticle();
        }
Exemplo n.º 29
0
        ///////////////////////////////////////////////////////////////////////
        protected void Page_Load(Object sender, EventArgs e)
        {
            Util.do_not_cache(Response);
            Master.Menu.SelectedItem = "admin";
            Page.Header.Title        = Util.get_setting("AppTitle", "BugTracker.NET") + " - "
                                       + "edit user";

            if (!User.IsInRole(BtnetRoles.Admin))
            {
                // Check if the current user is an admin for any project
                sql = new SQLString(@"select pu_project
			from project_user_xref
			where pu_user = us
			and pu_admin = 1"            );
                sql = sql.AddParameterWithValue("us", Convert.ToString(User.Identity.GetUserId()));
                DataSet ds_projects = btnet.DbUtil.get_dataset(sql);

                if (ds_projects.Tables[0].Rows.Count == 0)
                {
                    Response.Write("You not allowed to add users.");
                    Response.End();
                }

                admin.Visible               = false;
                admin_label.Visible         = false;
                project_admin_label.Visible = false;
                project_admin.Visible       = false;
                project_admin_help.Visible  = false;
            }

            if (Request["copy"] != null && Request["copy"] == "y")
            {
                copy = true;
            }

            msg.InnerText = "";

            string var = Request.QueryString["id"];

            if (var == null)
            {
                id = 0;
                // MAW -- 2006/01/27 -- Set default settings when adding a new user
                auto_subscribe_own.Checked                 = true;
                auto_subscribe_reported.Checked            = true;
                enable_popups.Checked                      = true;
                reported_notifications.Items[4].Selected   = true;
                assigned_notifications.Items[4].Selected   = true;
                subscribed_notifications.Items[4].Selected = true;
            }
            else
            {
                id = Convert.ToInt32(var);
            }

            if (!IsPostBack)
            {
                if (!User.IsInRole(BtnetRoles.Admin))
                {
                    // logged in user is a project level admin

                    // get values for permissions grid
                    // Table 0
                    sql = new SQLString(@"
				select pj_id, pj_name,
				isnull(a.pu_permission_level,@dpl) [pu_permission_level],
				isnull(a.pu_auto_subscribe,0) [pu_auto_subscribe],
				isnull(a.pu_admin,0) [pu_admin]
				from projects
				inner join project_user_xref project_admin on pj_id = project_admin.pu_project
				and project_admin.pu_user = @this_usid
				and project_admin.pu_admin = 1
				left outer join project_user_xref a on pj_id = a.pu_project
				and a.pu_user = @us
				order by pj_name;"                );


                    sql = sql.AddParameterWithValue("this_usid", Convert.ToString(User.Identity.GetUserId()));
                }
                else // user is a real admin
                {
                    // Table 0

                    // populate permissions grid
                    sql = new SQLString(@"
				select pj_id, pj_name,
				isnull(pu_permission_level,@dpl) [pu_permission_level],
				isnull(pu_auto_subscribe,0) [pu_auto_subscribe],
				isnull(pu_admin,0) [pu_admin]
				from projects
				left outer join project_user_xref on pj_id = pu_project
				and pu_user = @us
				order by pj_name;"                );
                }

                // Table 1

                sql.Append(@"/* populate query dropdown */
		    declare @org int
		    set @org = null
		    select @org = us_org from users where us_id = @us

			select qu_id, qu_desc
			from queries
			where (isnull(qu_user,0) = 0 and isnull(qu_org,0) = 0)
			or isnull(qu_user,0) = @us
			or isnull(qu_org,0) = isnull(@org,-1)
			order by qu_desc;"            );

                // Table 2

                if (User.IsInRole(BtnetRoles.Admin))
                {
                    sql.Append(@"/* populate org dropdown 1 */
				select og_id, og_name
				from orgs
				order by og_name;"                );
                }
                else
                {
                    if (User.Identity.GetOtherOrgsPermissionLevels() == PermissionLevel.All)
                    {
                        sql.Append(@"/* populate org dropdown 2 */
					select og_id, og_name
					from orgs
					where og_non_admins_can_use = 1
					order by og_name;"                    );
                    }
                    else
                    {
                        sql.Append(@"/* populate org dropdown 3 */
					select 1; -- dummy"                    );
                    }
                }


                // Table 3
                if (id != 0)
                {
                    // get existing user values

                    sql.Append(@"
			select
				us_username,
				isnull(us_firstname,'') [us_firstname],
				isnull(us_lastname,'') [us_lastname],
				isnull(us_bugs_per_page,10) [us_bugs_per_page],
				us_use_fckeditor,
				us_enable_bug_list_popups,
				isnull(us_email,'') [us_email],
				us_active,
				us_admin,
				us_enable_notifications,
				us_send_notifications_to_self,
                us_reported_notifications,
                us_assigned_notifications,
                us_subscribed_notifications,
				us_auto_subscribe,
				us_auto_subscribe_own_bugs,
				us_auto_subscribe_reported_bugs,
				us_default_query,
				us_org,
				isnull(us_signature,'') [us_signature],
				isnull(us_forced_project,0) [us_forced_project],
				us_created_user
				from users
				where us_id = @us"                );
                }


                sql = sql.AddParameterWithValue("us", Convert.ToString(id));
                sql = sql.AddParameterWithValue("dpl", Util.get_setting("DefaultPermissionLevel", "2"));

                DataSet ds = btnet.DbUtil.get_dataset(sql);

                // query dropdown
                query.DataSource     = ds.Tables[1].DefaultView;
                query.DataTextField  = "qu_desc";
                query.DataValueField = "qu_id";
                query.DataBind();

                // forced project dropdown
                forced_project.DataSource     = ds.Tables[0].DefaultView;
                forced_project.DataTextField  = "pj_name";
                forced_project.DataValueField = "pj_id";
                forced_project.DataBind();
                forced_project.Items.Insert(0, new ListItem("[no forced project]", "0"));

                // org dropdown
                if (User.IsInRole(BtnetRoles.Admin) ||
                    User.Identity.GetOtherOrgsPermissionLevels() == PermissionLevel.All)
                {
                    org.DataSource     = ds.Tables[2].DefaultView;
                    org.DataTextField  = "og_name";
                    org.DataValueField = "og_id";
                    org.DataBind();
                    org.Items.Insert(0, new ListItem("[select org]", "0"));
                }
                else
                {
                    int organizationId = User.Identity.GetOrganizationId();
                    int orgRow         = ds.Tables[2].DefaultView.Find(organizationId);
                    org.Items.Insert(0, new ListItem((string)ds.Tables[2].Rows[orgRow]["og_name"], Convert.ToString(organizationId)));
                }

                // populate permissions grid
                MyDataGrid.DataSource = ds.Tables[0].DefaultView;
                MyDataGrid.DataBind();

                // subscribe by project dropdown
                project_auto_subscribe.DataSource     = ds.Tables[0].DefaultView;
                project_auto_subscribe.DataTextField  = "pj_name";
                project_auto_subscribe.DataValueField = "pj_id";
                project_auto_subscribe.DataBind();

                // project admin dropdown
                project_admin.DataSource     = ds.Tables[0].DefaultView;
                project_admin.DataTextField  = "pj_name";
                project_admin.DataValueField = "pj_id";
                project_admin.DataBind();


                // add or edit?
                if (id == 0)
                {
                    sub.Value                    = "Create";
                    bugs_per_page.Value          = "10";
                    active.Checked               = true;
                    enable_notifications.Checked = true;
                }
                else
                {
                    sub.Value = "Update";

                    // get the values for this existing user
                    DataRow dr = ds.Tables[3].Rows[0];

                    // check if project admin is allowed to edit this user
                    if (!User.IsInRole(BtnetRoles.Admin))
                    {
                        if (User.Identity.GetUserId() != (int)dr["us_created_user"])
                        {
                            Response.Write("You not allowed to edit this user, because you didn't create it.");
                            Response.End();
                        }
                        else if ((int)dr["us_admin"] == 1)
                        {
                            Response.Write("You not allowed to edit this user, because it is an admin.");
                            Response.End();
                        }
                    }


                    // select values in dropdowns

                    // select forced project
                    int current_forced_project = (int)dr["us_forced_project"];
                    foreach (ListItem li in forced_project.Items)
                    {
                        if (Convert.ToInt32(li.Value) == current_forced_project)
                        {
                            li.Selected = true;
                            break;
                        }
                    }

                    // Fill in this form
                    if (copy)
                    {
                        username.Value      = "Enter username here";
                        firstname.Value     = "";
                        lastname.Value      = "";
                        email.Value         = "";
                        signature.InnerText = "";
                    }
                    else
                    {
                        username.Value      = (string)dr["us_username"];
                        firstname.Value     = (string)dr["us_firstname"];
                        lastname.Value      = (string)dr["us_lastname"];
                        email.Value         = (string)dr["us_email"];
                        signature.InnerText = (string)dr["us_signature"];
                    }

                    bugs_per_page.Value          = Convert.ToString(dr["us_bugs_per_page"]);
                    use_fckeditor.Checked        = Convert.ToBoolean((int)dr["us_use_fckeditor"]);
                    enable_popups.Checked        = Convert.ToBoolean((int)dr["us_enable_bug_list_popups"]);
                    active.Checked               = Convert.ToBoolean((int)dr["us_active"]);
                    admin.Checked                = Convert.ToBoolean((int)dr["us_admin"]);
                    enable_notifications.Checked = Convert.ToBoolean((int)dr["us_enable_notifications"]);
                    send_to_self.Checked         = Convert.ToBoolean((int)dr["us_send_notifications_to_self"]);
                    reported_notifications.Items[(int)dr["us_reported_notifications"]].Selected     = true;
                    assigned_notifications.Items[(int)dr["us_assigned_notifications"]].Selected     = true;
                    subscribed_notifications.Items[(int)dr["us_subscribed_notifications"]].Selected = true;
                    auto_subscribe.Checked          = Convert.ToBoolean((int)dr["us_auto_subscribe"]);
                    auto_subscribe_own.Checked      = Convert.ToBoolean((int)dr["us_auto_subscribe_own_bugs"]);
                    auto_subscribe_reported.Checked = Convert.ToBoolean((int)dr["us_auto_subscribe_reported_bugs"]);


                    // org
                    foreach (ListItem li in org.Items)
                    {
                        if (Convert.ToInt32(li.Value) == (int)dr["us_org"])
                        {
                            li.Selected = true;
                            break;
                        }
                    }

                    // query
                    foreach (ListItem li in query.Items)
                    {
                        if (Convert.ToInt32(li.Value) == (int)dr["us_default_query"])
                        {
                            li.Selected = true;
                            break;
                        }
                    }

                    // select projects
                    foreach (DataRow dr2 in ds.Tables[0].Rows)
                    {
                        foreach (ListItem li in project_auto_subscribe.Items)
                        {
                            if (Convert.ToInt32(li.Value) == (int)dr2["pj_id"])
                            {
                                if ((int)dr2["pu_auto_subscribe"] == 1)
                                {
                                    li.Selected = true;
                                }
                                else
                                {
                                    li.Selected = false;
                                }
                            }
                        }
                    }

                    foreach (DataRow dr3 in ds.Tables[0].Rows)
                    {
                        foreach (ListItem li in project_admin.Items)
                        {
                            if (Convert.ToInt32(li.Value) == (int)dr3["pj_id"])
                            {
                                if ((int)dr3["pu_admin"] == 1)
                                {
                                    li.Selected = true;
                                }
                                else
                                {
                                    li.Selected = false;
                                }
                            }
                        }
                    }
                } // add or edit
            }     // if !postback
            else
            {
                on_update();
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// 绑定数据到DataGrid控件MyDataGrid上
        /// </summary>
        private void BindDataGrid()
        {
            //创建操作员记录数据表类实例
            MemCardLevelOperate clsRecord = new MemCardLevelOperate();
            DataTable           dt        = new DataTable();

            //获取记录数据
            //if (Session["UserGroupID"].ToString() != "1")
            //{
            //    dt = clsRecord.BindAgent(Convert.ToDateTime(this.txtBeginDate.Text.Trim()).ToShortDateString(), Convert.ToDateTime(this.txtEndDate.Text.Trim()).AddDays(1).ToShortDateString(), Session["UserGroupId"].ToString(), Session["UserId"].ToString());
            //}
            //else
            //{
            //    dt = clsRecord.BindAgent(Convert.ToDateTime(this.txtBeginDate.Text.Trim()).ToShortDateString(), Convert.ToDateTime(this.txtEndDate.Text.Trim()).AddDays(1).ToShortDateString(),, Session["UserId"].ToString()"");
            //}
            dt = clsRecord.BindAgent(Convert.ToDateTime(this.txtBeginDate.Text.Trim()).ToShortDateString(), Convert.ToDateTime(this.txtEndDate.Text.Trim()).AddDays(1).ToShortDateString(), Session["UserGroupId"].ToString(), Session["UserId"].ToString());

            //获取记录数据
            //DataTable dt = clsRecord.BindAgent(Convert.ToDateTime(this.txtBeginDate.Text.Trim()).ToShortDateString(), Convert.ToDateTime(this.txtEndDate.Text.Trim()).AddDays(1).ToShortDateString(),Session["UserId"].ToString());
            DataView dv = new DataView();

            dt.TableName = "Mem_Log";
            if (dt != null)
            {
                dv.Table = dt;

                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;  //获取数据表记录数

                //double totalAccount = 0.00;
                double totalZongXiaofei  = 0.00;
                double totalZongChongzhi = 0.00;

                for (int i = 0; i < intCountRecNum; i++)
                {
                    dv[i]["idno"] = i + 1;

                    //totalAccount += Convert.ToDouble(dv[i]["Account"]);
                    totalZongXiaofei  += Convert.ToDouble(dv[i]["ZongXiaofei"]);
                    totalZongChongzhi += Convert.ToDouble(dv[i]["ZongCongzhi"]);
                }


                MyDataGrid.DataSource = dv;

                this.lbTotalXiaofei.Text  = totalZongXiaofei.ToString();
                this.lbTotalChongzhi.Text = totalZongChongzhi.ToString();


                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();                                    //显示页数信息
            }
        }