当前位置: 首页>>代码示例>>C#>>正文


C# DbHelper.GetSqlStringCommond方法代码示例

本文整理汇总了C#中DbHelper.GetSqlStringCommond方法的典型用法代码示例。如果您正苦于以下问题:C# DbHelper.GetSqlStringCommond方法的具体用法?C# DbHelper.GetSqlStringCommond怎么用?C# DbHelper.GetSqlStringCommond使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DbHelper的用法示例。


在下文中一共展示了DbHelper.GetSqlStringCommond方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["uname"] == null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }
        if (Session["uid"]==null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }

        if (Session["ucount"] == null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }
        string uid = Session["uid"].ToString();
        dbh = new DbHelper();
        string sql;
        sql = string.Format("select count(*) from userinfo where parent_id='{0}' ", uid);
        DbCommand dbc = dbh.GetSqlStringCommond(sql);

        int count=int.Parse(dbh.ExecuteScalar(dbc).ToString());

        int usercount = int.Parse(Session["ucount"].ToString()); ;
        if (count >= usercount)
        {
            Response.Write("<script>alert('用户最大数超出设定范围,请联系管理员!');window.location.href='userlist.aspx';</script>");
            return;
        }

        if (Request["id"] != null)
        {

            id = Request["id"];

            sql = string.Format("select * from userinfo where id='{0}' ", Request["id"]);
            DbCommand dbc3 = dbh.GetSqlStringCommond(sql);
            dbr = dbh.ExecuteReader(dbc3);
            dbr.Read();
            tb_guid.Text = dbr["guid"].ToString();
            tb_memo.Text = dbr["memo"].ToString();
            tb_buydate.Text = dbr["buy_date"].ToString();
            tb_stopdate.Text = dbr["stop_date"].ToString();
            tb_username.Text = dbr["user_name"].ToString();
            rb_stop.Checked = dbr["active"].ToString() == "0" ? true : false;
            rb_active.Checked = dbr["active"].ToString() == "0" ? false : true;

        }
        else
        {
            tb_guid.ReadOnly = false;
            tb_buydate.Text = DateTime.Now.ToString("yyyyMMdd");
            tb_stopdate.Text = DateTime.Now.AddYears(1).ToString("yyyyMMdd");
            rb_stop.Checked = true;
        }
    }
开发者ID:wangshu,项目名称:printv2,代码行数:59,代码来源:UserInfo.aspx.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Form["uname"] == null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }
        if (Request.Form["psw"] == null)
        {
            Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
            return;
        }
        DbHelper dbh = new DbHelper();
        string user = Request.Form["uname"];
        string psw = Request.Form["psw"];
        string sql = "select count(*) as c from admin where [email protected] and [email protected]";
        DbCommand cmd = dbh.GetSqlStringCommond(sql);
        SqlParameter[] dbp = new SqlParameter[2];
        dbp[0] = new SqlParameter();
        dbp[0].ParameterName = "@u";
        dbp[0].Value = user;
        dbp[1] = new SqlParameter();
        dbp[1].ParameterName = "@p";
        dbp[1].Value = psw;
        sql = dbh.ExecuteScalar(cmd, dbp).ToString();
        if (sql != "1")
        {
            Response.Write("<script>alert('用户名密码错误,请重新输入!');window.location.href='default.aspx';</script>");

        }
        else
        {
            Session.Timeout = 30;
             sql = "select * from admin where username='"+user+"' and password='"+psw +"'";
            DbCommand cmd2 = dbh.GetSqlStringCommond(sql);
            DbDataReader dr = dbh.ExecuteReader(cmd2);
            dr.Read();
            Session["uname"] = user;
            Session["uid"] = dr["id"].ToString();
            Session["ucount"] = dr["usercount"].ToString();
            Response.Write("<script> window.location.href='userlist.aspx';</script>");
        }
    }
开发者ID:wangshu,项目名称:printv2,代码行数:43,代码来源:main.aspx.cs

示例3: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["uname"] == null)
     {
         Response.Write("<script>alert('系统超时或非法登录,请重新登录!');window.location.href='default.aspx';</script>");
     }
     dbh = new DbHelper();
     string sql;
     sql = string.Format("select * from version" );
     DbCommand dbc = dbh.GetSqlStringCommond(sql);
     dbr = dbh.ExecuteReader(dbc);
     this.GridView1.DataSource = dbr;
     this.GridView1.DataBind();
 }
开发者ID:wangshu,项目名称:printv2,代码行数:14,代码来源:Versioninfo.aspx.cs

示例4: CheckOpen

 public bool CheckOpen(String Uid)
 {
     string sql;
     dbh = new DbHelper();
     sql = string.Format("select count(*) from userinfo where guid='{0}' and  active=1", Uid);
     DbCommand dbc = dbh.GetSqlStringCommond(sql);
     String s = dbh.ExecuteScalar(dbc).ToString();
     if (s.Equals("1"))
     {
         return true;
     }
     else
     {
         return false;
     }
 }
开发者ID:wangshu,项目名称:printv2,代码行数:16,代码来源:WebService.cs


注:本文中的DbHelper.GetSqlStringCommond方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。