コード例 #1
0
ファイル: userService.cs プロジェクト: TouchLQL/BookStore
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <param name="sex"></param>
        /// <param name="birth"></param>
        /// <param name="mail"></param>
        /// <param name="realName"></param>
        /// <param name="address"></param>
        /// <param name="telephone"></param>
        /// <returns></returns>
        public string registe(string userName, string password, string sex, string birth,
                              string mail, string realName, string address, string telephone)
        {
            bool   isexist = false;
            string sql_1   = "select userName from [user] where userName = '******'";

            isexist = db.YNExistData(sql_1);
            if (isexist == false)
            {
                string    sql1   = "select max(userID) as userid from [user]";
                DataTable dt     = db.GetDataTable(sql1);
                int       userid = int.Parse(dt.Rows[0][0].ToString());
                userid = userid + 1;

                string sql = "insert into [user](userID,userName, password, sex, birth, email,realName,address, telephone,type,balance)" +
                             "values({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}')";
                sql = string.Format(sql, userid, userName, password, sex, birth, mail, realName, address, telephone, "普通用户", "0");
                db.ExecuteNonQuery(sql);
                return("1");
            }
            else
            {
                return("0");
            }
        }
コード例 #2
0
ファイル: orderService.cs プロジェクト: TouchLQL/BookStore
        public DataTable ShowOrderInfo(string orderId)
        {
            string sql = "SELECT ID,ordertime,ordernum,[order].bookid,[order].userid,[order].type,money,bookName,userName " +
                         "FROM [order],[user],[book] WHERE [order].bookid = book.bookID AND [order].userid = [user].userID and ID= '" + orderId + "'";
            DataTable dt = db.GetDataTable(sql);

            return(dt);
        }
コード例 #3
0
        /// <summary>
        /// 根据展示图书详情
        /// </summary>
        /// <param name="ISBN2"></param>
        /// <returns></returns>
        public DataTable showDetails(string bookid)
        {
            string sql = "select * FROM book where bookID='" + bookid + "'";

            DataTable result = db.GetDataTable(sql);

            return(result);
        }
コード例 #4
0
        /// <summary>
        /// 展示全部图书数据
        /// </summary>
        /// <returns></returns>
        public DataTable View()
        {
            SqlDBConnect db   = new SqlDBConnect();
            string       sql1 = "select * FROM book";

            return(db.GetDataTable(sql1));
        }
コード例 #5
0
ファイル: PagePart2.ascx.cs プロジェクト: TouchLQL/BookStore
        private new void DataBind()
        {
            this.pageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
            this.sql      = (string)ViewState["Sql"];
            this.dt       = (DataTable)ViewState["Dt"];

            if (string.IsNullOrWhiteSpace(this.sql) && this.dt == null)
            {
                return;
            }

            SqlDBConnect db       = new SqlDBConnect();
            DataTable    dtSourse = null;

            if (this.sql != null)
            {
                dtSourse = db.GetDataTable(this.sql);
            }
            else if (this.dt != null)
            {
                dtSourse = this.dt;
            }

            Control control = Parent.FindControl(this.controlId);//待绑定控件

            PagedDataSource pds = new PagedDataSource();

            pds.DataSource  = dtSourse.DefaultView;
            pds.AllowPaging = true;
            pds.PageSize    = this.pageSize;
            this.totalCount = pds.DataSourceCount; //获取总项数
            this.totalPages = pds.PageCount;       //获取总页数
            if (IsPostBack && Request.Form["hidPageSize"] != "")
            {
                if (Request.Form["hidPageSize"] == "首页")
                {
                    this.nowPage = 1;
                }
                else if (Request.Form["hidPageSize"] == "上一页")
                {
                    this.nowPage = Convert.ToInt32(ViewState["NowPage"]) - 1;
                }
                else if (Request.Form["hidPageSize"] == "下一页")
                {
                    this.nowPage = Convert.ToInt32(ViewState["NowPage"]) + 1;
                }
                else if (Request.Form["hidPageSize"] == "末页")
                {
                    this.nowPage = this.totalCount;
                }
                else if (Request.Form["hidPageSize"] != "")
                {
                    string i = Request.Form["hidPageSize"];
                    this.nowPage = Convert.ToInt32(Request.Form["hidPageSize"]);
                }
            }
            if (this.nowPage < 1)
            {
                if (ViewState["NowPage"] == null)
                {
                    this.nowPage = 1;
                }
                else
                {
                    this.nowPage = Convert.ToInt32(ViewState["NowPage"]);
                }
            }
            else if (this.nowPage > this.totalCount)
            {
                this.nowPage = this.totalCount;
            }
            this.nowPage         = this.nowPage > this.totalPages ? this.totalPages : this.nowPage;//矫正当前索引页
            ViewState["NowPage"] = this.nowPage;
            pds.CurrentPageIndex = this.nowPage - 1;

            if (control.GetType() == typeof(Repeater))
            {
                (control as Repeater).DataSource = pds;
                control.DataBind();
            }
            else if (control.GetType() == typeof(GridView))
            {
                (control as GridView).DataSource = pds;
                control.DataBind();
            }
        }