コード例 #1
0
ファイル: orderService.cs プロジェクト: TouchLQL/BookStore
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="bookmodel">图书实体</param>
        /// <returns>"1"表示新增成功 "0"表示新增失败</returns>
        public string add(order ordermodel)
        {
            string sql_1   = "select * from [order] where bookID = '" + ordermodel.ID + "'";
            bool   isExist = db.YNExistData(sql_1);

            if (isExist == false)
            {
                string    sql1    = "select max(ID) as orderid from [order]";
                DataTable dt      = db.GetDataTable(sql1);
                int       orderid = int.Parse(dt.Rows[0][0].ToString());
                orderid = orderid + 1;

                string sql = "insert into [order](ID,ordertime, ordernum, bookid, userid, type, money) " +
                             "values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')";
                sql = string.Format(sql, orderid, ordermodel.ordertime,
                                    ordermodel.ordernum, ordermodel.bookid, ordermodel.userid,
                                    ordermodel.type, ordermodel.money);
                db.ExecuteNonQuery(sql);
                return("1");
            }
            else
            {
                return("0");
            }
        }
コード例 #2
0
        /// <summary>
        /// 根据图书类型读取图书
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public DataTable getBytype(string type)
        {
            string sql    = "select * FROM book where type='" + type + "'";
            bool   boolen = db.YNExistData(sql);

            if (boolen)
            {
                return(db.GetDataTable(sql));
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
ファイル: userService.cs プロジェクト: TouchLQL/BookStore
        /// <summary>
        /// 前台登陆
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="password">密码</param>
        /// <returns>成功失败</returns>
        public string Login(string userName, string password)
        {
            bool   isexist = false;
            string sql1    = "select * from [user] where userName='******'" +
                             " and password='******'";

            isexist = db.YNExistData(sql1);
            if (isexist)
            {
                System.Web.HttpContext.Current.Session["userName"] = userName;
                return("1");
            }

            else
            {
                return("0");
            }
        }