Exemplo n.º 1
0
        /// <summary>
        /// 更新 card信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdateCard_Click(object sender, EventArgs e)
        {
            #region 检查
            if (ddlCardType.SelectedValue == "")
            {
                PageCommon.RegisterJsMsg(this, "please select Card Type", "");
                return;
            }
            if (string.IsNullOrEmpty(txbCardNumber.Text))
            {
                PageCommon.RegisterJsMsg(this, "please input Card Number", "");
                return;
            }

            if (string.IsNullOrEmpty(txbCardExpiration.Text))
            {
                PageCommon.RegisterJsMsg(this, "please input Card Expiration", "");
                return;
            }

            if (txbCardExpiration.Text.Trim().IndexOf('/') == -1)
            {
                PageCommon.RegisterJsMsg(this, "the expiration in the format of mm/yy", "");
                return;
            }

            if (string.IsNullOrEmpty(txbCardCSCcode.Text))
            {
                PageCommon.RegisterJsMsg(this, "please input Card CSC code", "");
                return;
            }

            if (string.IsNullOrEmpty(txbNameonCard.Text))
            {
                PageCommon.RegisterJsMsg(this, "please input Name on Card", "");
                return;
            }
            #endregion

            try
            {
                var creditCard = new LP_Service.UpdateCreditCardRequest();

                var exp = txbCardExpiration.Text.Trim().Split('/');

                int mm = Convert.ToInt32(exp[0]);
                if (mm >= 1 && mm <= 12)
                {
                    creditCard.Card_Exp_Month = exp[0];
                }
                else
                {
                    PageCommon.RegisterJsMsg(this, "Card Expiration (mm/yy): mm should be a number between 1 and 12", "");
                    return;
                }
                if (Convert.ToInt32(DateTime.Now.Year.ToString().Substring(0, 2) + exp[1]) >= DateTime.Now.Year)
                {
                    creditCard.Card_Exp_Year = exp[1];
                }
                else
                {
                    PageCommon.RegisterJsMsg(this, "Card Expiration (mm/yy): yy Should be more than equal to the current year", "");
                    return;
                }



                var name = txbNameonCard.Text.Split(' ').ToList();
                if (name.Count < 2)
                {
                }
                creditCard.Card_First_Name = name.FirstOrDefault();

                creditCard.Card_Last_Name = name.LastOrDefault();

                creditCard.Card_IsDefault = "True";

                creditCard.Card_Number = txbCardNumber.Text.Trim();
                creditCard.Card_SIC    = txbCardCSCcode.Text.Trim();
                creditCard.Card_Type   = (LP_Service.CreditCardType)Convert.ToInt32(ddlCardType.SelectedValue.Trim());

                //creditCard.ExtensionData =

                creditCard.Card_ID = hfCardID.Value.Trim();

                ServiceManager sm = new ServiceManager();
                using (LP2ServiceClient client = sm.StartServiceClient())
                {
                    creditCard.hdr        = new LP_Service.ReqHdr();
                    creditCard.hdr.UserId = loginUser.iUserID;

                    var rq = client.UpdateCreditCard(creditCard);
                    if (rq.hdr.Successful)
                    {
                        //PageCommon.RegisterJsMsg(this, "", PageCommon.Js_RefreshSelf);
                        PageCommon.RegisterJsMsg(this, "Update Credit Card Successfully.", "");
                    }
                    else
                    {
                        PageCommon.RegisterJsMsg(this, rq.hdr.StatusInfo, "");
                    }
                }
            }
            catch (Exception ex)
            {
                PageCommon.AlertMsg(this, "Error:" + ex.Message);
            }
        }