Exemplo n.º 1
0
    public static Order GetOrderByOrderId(int orderid)
    {
        string          sql = "select * from cloudorder where id=?id";
        MySqlConnection con = new MySqlConnection(Config_MySql.sqlUrl);

        con.Open();
        MySqlCommand comm = new MySqlCommand(sql, con);

        comm.Parameters.Add(new MySqlParameter("?id", orderid));
        MySqlDataReader rdr   = comm.ExecuteReader();
        Order           order = new Order();

        while (rdr.Read())
        {
            order.Id        = rdr.GetInt32("id");
            order.UserId    = rdr.GetInt32("userid");
            order.CloudCode = rdr.GetString("cloudcode");
            order.Addtime   = rdr.GetString("addtime");
            order.OrderId   = rdr.GetString("orderid");
            order.GoodId    = rdr.GetInt32("goodid");
            order.good      = GoodService.GetGoodMsg(order.GoodId);
        }
        comm.Clone();
        con.Close();
        return(order);
    }
Exemplo n.º 2
0
    /**
     * 0:进行中
     * 1:已经揭晓
     */
    public static int getStatus(int good_id)
    {
        List <Order>    orders = new List <Order>();
        string          sql    = "select * from cloudorder where goodid = @good_id";
        MySqlConnection con    = new MySqlConnection(Config_MySql.sqlUrl);

        con.Open();
        MySqlCommand comm = new MySqlCommand(sql, con);

        comm.Parameters.Add(new MySqlParameter("@good_id", good_id));
        MySqlDataReader sdr = comm.ExecuteReader();

        while (sdr.Read())
        {
            Order order = new Order();
            order.Id        = sdr.GetInt32("id");
            order.Addtime   = sdr.GetString("addtime");
            order.UserId    = sdr.GetInt32("userid");
            order.OrderSum  = 0;
            order.CloudCode = sdr.GetString("cloudcode");
            order.GoodId    = sdr.GetInt32("goodid");
            order.good      = GoodService.GetGoodMsg(order.GoodId);
            orders.Add(order);
        }
        sdr.Close();
        con.Close();
        if (orders.Count > 0 && orders.Count >= orders[0].good.Joinpeoplenum)
        {
            return(1);
        }
        else
        {
            return(0);
        }
    }
Exemplo n.º 3
0
    public static List <Order> GetOrdersByUserId(int user_id)
    {
        List <Order>    orders = new List <Order>();
        string          sql    = "select * from cloudorder where userid = @userid";
        MySqlConnection con    = new MySqlConnection(Config_MySql.sqlUrl);

        con.Open();
        MySqlCommand comm = new MySqlCommand(sql, con);

        comm.Parameters.Add(new MySqlParameter("@userid", user_id));
        MySqlDataReader sdr = comm.ExecuteReader();

        while (sdr.Read())
        {
            Order order = new Order();
            order.Id        = sdr.GetInt32("id");
            order.Addtime   = sdr.GetString("addtime");
            order.UserId    = sdr.GetInt32("userid");
            order.OrderSum  = 0;
            order.CloudCode = sdr.GetString("cloudcode");
            order.GoodId    = sdr.GetInt32("goodid");
            order.good      = GoodService.GetGoodMsg(order.GoodId);
            orders.Add(order);
        }
        sdr.Close();
        con.Close();
        return(orders);
    }
    public Good getGoodId()
    {
        int id = int.Parse(Request.QueryString["id"].ToString());

        good = GoodService.GetGoodMsg(id);
        return(good);
    }
Exemplo n.º 5
0
    public static ShopCar getShopCarByShopCarId(int shopcarid)
    {
        ShopCar         shopcar = new ShopCar();
        string          sql     = "select * from shopcar where id=?shopcarid";
        MySqlConnection con     = new MySqlConnection(Config_MySql.sqlUrl);

        con.Open();
        MySqlCommand comm = new MySqlCommand(sql, con);

        comm.Parameters.Add(new MySqlParameter("?shopcarid", shopcarid));
        MySqlDataReader rdr = comm.ExecuteReader();

        while (rdr.Read())
        {
            shopcar.UserId  = rdr.GetInt32("userid");
            shopcar.GoodId  = rdr.GetInt32("goodid");
            shopcar.BuyTime = rdr.GetInt32("buytime");
            shopcar.good    = GoodService.GetGoodMsg(shopcar.GoodId);
        }


        comm.Clone();
        con.Close();
        return(shopcar);
    }
Exemplo n.º 6
0
    protected void addOrder(object sender, EventArgs e)
    {
        string buytime = buytime1.Value;
        int    userid  = 0;

        username = (string)Session["username"];
        if (UserService.getUserIdByPhone(username) == 0)
        {
            userid = UserService.getUserIdByEmail(username);
        }
        else
        {
            userid = UserService.getUserIdByPhone(username);
        }

        int buytime_judge = int.Parse(buytime);

        if (buytime_judge > shopcar.good.RemainPeople || buytime_judge <= 0)
        {
            Response.Write("<script>alert('您的输入有误,请您重新输入购买个数!');location.href='Index.aspx';</script>");
        }
        else
        {
            int    buytimeInt       = Convert.ToInt32(buytime);
            int    goodid           = shopcar.GoodId;
            string addtime          = DateTime.Now.ToShortDateString().ToString();
            Good   value_good       = GoodService.GetGoodMsg(goodid);
            int    totalPeople      = value_good.Joinpeoplenum;
            int    old_remainpeople = value_good.RemainPeople;

            //生成订单编号
            string orderId_head = "2017";
            string orderId      = orderId_head + userid + goodid;
            int[]  codeArray    = Hashtable_code(totalPeople);

            for (int i = 0; i < buytimeInt; i++)
            {
                int joinpeople = OrderService.GetOrderMsg(goodid);
                //真正云购码
                string realCode = getCloudCode(codeArray, joinpeople).ToString() + userid + goodid;
                Order  order    = OrderService.AddOrder(userid, goodid, realCode, addtime, orderId);
            }

            int new_joinpeople = OrderService.GetOrderMsg(goodid);
            int remainpeople   = totalPeople - new_joinpeople;
            GoodService.UpdateGoodPeople(new_joinpeople, remainpeople, goodid);
            if (remainpeople == 0)
            {
                //开奖
                //1.依据goodid从cloudorder中随机查询一个luckycode
                string luckyCode = OrderService.getLuckyCodeByGoodId(goodid);
                //2.修改该good的信息
                GoodService.UpateGoodLuckyMsg(goodid, luckyCode);
                //3.进入显示该商品信息的界面
                Response.Write("<script>location.href='PersonalPage/PurchaseRecord/AnnouncedPurchase.aspx';</script>");
            }
            Response.Write("<script>alert('订单添加成功!');location.href='PersonalPage/PurchaseRecord/JinxingPurchase.aspx';</script>");
        }
    }