Example #1
0
        protected void btnEdit_Click(object sender, System.EventArgs e)
        {
            if (string.IsNullOrEmpty(hidUserId.Value))
            {
                this.ShowMsg("请选择所属用户!", false);
            }
            CardTypeInfoEntity cardtype = CardTypeInfoBusiness.LoadEntity(new Guid(DDLCardType.SelectedValue));

            if (cardtype != null)
            {
                //新建状态下时,余额不能小于卡的面值
                if (Globals.ToNum(txtBalance.Text) < cardtype.AmountLevel)
                {
                    this.ShowMsg("该会员卡的初始余额不能小于" + cardtype.AmountLevel.ToString("F2"), false);
                    return;
                }
            }

            ManagerInfo currentManager = ManagerHelper.GetCurrentManager();

            if (this.Page.Request.QueryString["ID"] == null)
            {
                CardInfoEntity cardInfo = new CardInfoEntity()
                {
                    ID             = Guid.NewGuid(),
                    CardNumber     = txtCardNumber.Text.Trim(),
                    DefaultMoney   = cardtype.AmountLevel,
                    CreateTime     = DateTime.Now,
                    ManagerId      = currentManager.UserId,
                    ShopId         = new Guid("767146AD-7323-44EE-841C-5C2DF99F7737"),//默认为绿地国博店
                    CardTypeId     = new Guid(DDLCardType.SelectedValue),
                    MemberId       = Globals.ToNum(hidUserId.Value),
                    Status         = 1,                        //已绑定
                    CardFrom       = "收银系统",
                    ExpirationDate = DateTime.Now.AddYears(3), //默认为三年后过期
                    Balance        = Globals.ToNum(txtBalance.Text.Trim()),
                };
                if (CardInfoBusiness.SaveEntity(cardInfo, true))
                {
                    this.ShowMsgAndReUrl("创建成功", true, "ManageCards.aspx");
                }
            }
            else
            {
                CardInfoEntity cardInfo = CardInfoBusiness.LoadEntity(id);
                cardInfo.Balance    = decimal.Parse(txtBalance.Text);
                cardInfo.UpdateTime = DateTime.Now;
                if (CardInfoBusiness.SaveEntity(cardInfo, false))
                {
                    this.ShowMsgAndReUrl("编辑成功", true, "ManageCards.aspx");
                }
            }
        }
Example #2
0
 private void LoadCardInfo()
 {
     if (this.Page.Request.QueryString["ID"] != null)
     {
         CardInfoEntity mcinfo = CardInfoBusiness.LoadEntity(this.id);
         if (mcinfo == null)
         {
             base.GotoResourceNotFound();
             return;
         }
         txtBalance.Text = mcinfo.Balance.ToString("F2");
     }
 }