Ejemplo n.º 1
0
        private void LoadData()
        {
            OrdersBiz biz = new OrdersBiz();

            DataTable dt = biz.GetOrders_DetailList(-1, ViewState["OrderId"].ToString(), string.Empty, string.Empty);

            gvOrders_Detail.DataSource = dt;
            gvOrders_Detail.DataBind();
        }
Ejemplo n.º 2
0
        private void LoadData()
        {
            string currentUser = string.Empty;
            
            //如果不是管理员只能看自己的
            if (!IsSuperAdmin)
            {
                currentUser = CurrentUser.UserId.ToString();
            }
            else
            {
             //   lk_back.Visible = true; //管理员显示返回"管理页"的链接                
            }

            OrdersBiz biz = new OrdersBiz();
            DataTable dt = biz.GetOrdersList(txtOrderId.Text.Trim(),currentUser,
                                            txtStartDate.Text, txtEndDate.Text, string.Empty,
                                            int.Parse(ddlState.SelectedValue));

            gvOrdersList.DataSource = dt;
            gvOrdersList.DataBind();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lnkEdit_Click(object sender, EventArgs e)
        {
            OrdersBiz biz = new OrdersBiz();
            GiftBiz giftBiz = new GiftBiz();

            LinkButton lnk = sender as LinkButton;
            GridViewRow row = lnk.Parent.Parent as GridViewRow;
            TextBox txtGiftCount = row.FindControl("txtGiftCount") as TextBox;
            TextBox txtUsage = row.FindControl("txtUsage") as TextBox;

            int newCount = int.Parse(txtGiftCount.Text.Trim());

            Orders_DetailInfo model = biz.GetOrders_DetailModel(int.Parse(lnk.CommandArgument));
            GiftInfo giftModel = giftBiz.GetModel(model.GiftId);

            //更新数量的话,更新礼品信息
            int newQuantity = giftModel.Quantity;
            newQuantity -= newCount - model.GiftCount;

            if (newQuantity < 0)
            {
                lErrorInfo.Text = "礼品【" + giftModel.Title + "】数量不足,剩余数量为:" + giftModel.Quantity.ToString() + "!";
                return;
            }
            giftModel.Quantity = newQuantity;
            model.GiftCount = newCount;
            model.Usage = txtUsage.Text.Trim();

            if (biz.UpdateOrders_Detail(model) > 0 && giftBiz.UpdateGift(giftModel) > 0)
            {
                ShowMessage("更新成功!");
            }
            else
            {
                ShowMessage("更新失败!");
            }
        }
Ejemplo n.º 4
0
        private void LoadData()
        {
            OrdersBiz biz = new OrdersBiz();

            OrderInfo model = biz.GetOrderInfo(ViewState["OrderId"].ToString());

            lOrderId.Text = model.OrderId;
            lCreateTime.Text = model.CreateDate.ToString() ;
            lState.Text = OrdersBiz.GetStateString(model.State);
            Address.Text = model.Address;
            
            MemberShipManager manager = new MemberShipManager();
            User user = manager.GetUser(new Guid(model.UserId));
            lUserName.Text = user.UserName;
            Contactor.Text = model.Contactor;
            tel.Text = model.Tel;            
            email.Text = model.Email;
            GroupName.Text = user.GroupName;

            DataTable dt = biz.GetOrders_DetailList(-1, ViewState["OrderId"].ToString(), string.Empty, string.Empty);

            gvOrders_Detail.DataSource = dt;
            gvOrders_Detail.DataBind();
        }
Ejemplo n.º 5
0
        protected void lnkDelete_Click(object sender, EventArgs e)
        {
            OrdersBiz biz = new OrdersBiz();
            LinkButton lnk = sender as LinkButton;

            if (biz.DeleteOrders(lnk.CommandArgument) > 0)
            {
                ShowMessage("删除成功!");
                LoadData();
            }
            else
            {
                ShowMessage("删除失败!");
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 更改订单状态
 /// </summary>
 /// <param name="state"></param>
 private int ChangeState(string orderId, int state)
 {
     OrdersBiz biz = new OrdersBiz();
     OrderInfo model = biz.GetOrderInfo(orderId);
     if (model == null)
     {
         return 0;
     }
     model.Operator = CurrentUser.UserId.ToString();
     model.State = state;
     return biz.UpdateOrders(model);
 }
Ejemplo n.º 7
0
        protected void lnkOver_Click(object sender, EventArgs e)
        {
            OrdersBiz biz = new OrdersBiz();
            LinkButton lnk = sender as LinkButton;

            if (ChangeState(lnk.CommandArgument, 2) > 0)
            {
                ShowMessage("通过成功!");
                LoadData();
            }
            else
            {
                ShowMessage("通过失败!");
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 生成订单,并指定订单状态
        /// </summary>
        private string CreateOrder(int orderState)
        {           
            OrdersBiz biz = new OrdersBiz();
            OrderInfo orderModel = new OrderInfo();
            GiftBiz giftBiz = new GiftBiz();

            //添加订单信息
            orderModel.OrderId = biz.GetNewOrderId();
            orderModel.UserId = CurrentUser.UserId.ToString();
            orderModel.Operator = CurrentUser.OperatorId.ToString();
            orderModel.State = orderState;
            orderModel.Address = address.Text;
            orderModel.Contactor = Contactor.Text;
            orderModel.Tel = Tel.Text;
            orderModel.Email = Email.Text;

            Orders_DetailInfo[] details = new Orders_DetailInfo[gvShoppingCartList.Rows.Count];
            GiftInfo[] giftInfoList = new GiftInfo[gvShoppingCartList.Rows.Count];
            int i = 0;

            //添加订单明细,先检查数量是否足够
            foreach (GridViewRow row in gvShoppingCartList.Rows)
            {
                Label lblGiftId = row.FindControl("lblGiftId") as Label;
                TextBox txtCount = row.FindControl("txtCount") as TextBox;
                TextBox txtUsage = row.FindControl("txtUsage") as TextBox;

                Orders_DetailInfo detailModel = new Orders_DetailInfo();
                detailModel.OrderId = orderModel.OrderId;
                detailModel.GiftId = lblGiftId.Text;
                detailModel.GiftCount = int.Parse(txtCount.Text);
                detailModel.Usage = txtUsage.Text;

                GiftInfo giftModel = giftBiz.GetModel(detailModel.GiftId);

                if (giftModel.Quantity < detailModel.GiftCount)
                {
                    lErrorInfo.Text = "礼品【" + giftModel.Title + "】数量不足,剩余数量为:" + giftModel.Quantity.ToString() + "!";
                    return string.Empty;
                }

                giftInfoList[i] = giftModel;
                details[i] = detailModel;
                i++;
            }

            //遍历更新
            for (i = 0; i < details.Length; i++)
            {
                biz.AddOrders_Detail(details[i]);
                giftInfoList[i].Quantity -= details[i].GiftCount;
                giftBiz.UpdateGift(giftInfoList[i]);
            }
            biz.AddOrders(orderModel);

            //清除购物车
            HttpCookie cookie = Request.Cookies["ShoppingCart"];
            cookie.Expires = DateTime.Now.AddHours(-2);
            Response.Cookies.Add(cookie);
            return orderModel.OrderId;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void lnkDelete_Click(object sender, EventArgs e)
        {
            OrdersBiz biz = new OrdersBiz();
            GiftBiz giftBiz = new GiftBiz();

            LinkButton lnk = sender as LinkButton;

            Orders_DetailInfo model = biz.GetOrders_DetailModel(int.Parse(lnk.CommandArgument));
            GiftInfo giftModel = giftBiz.GetModel(model.GiftId);

            //删除订单明细后,更新礼品信息
            giftModel.Quantity += model.GiftCount;

            if (biz.DeleteOrders_Detail(int.Parse(lnk.CommandArgument)) > 0 && giftBiz.UpdateGift(giftModel) > 0)
            {
                ShowMessage("更新成功!");
            }
            else
            {
                ShowMessage("更新失败!");
            }
        }