Esempio n. 1
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("更新失败!");
            }
        }
Esempio n. 2
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("更新失败!");
            }
        }