예제 #1
0
        /// <summary>
        /// 获取会员卡信息 0:数据库操作失败, 1:成功, 2:会员卡号或者密码错误
        /// </summary>
        public int GetVIPCard(string cardNo, string password, out VIPCard card)
        {
            int result = 0;

            try
            {
                _daoManager.OpenConnection();
                //加密的密码
                string str            = string.Empty;
                string saltedPassword = _vipCardDao.GetCardPassword(cardNo);
                if (!string.IsNullOrEmpty(saltedPassword))
                {
                    int    index = saltedPassword.IndexOf(Delim);
                    string salt  = saltedPassword.Substring(0, index);
                    str = salt + Delim + PasswordCryptographer.SaltPassword(password, salt);
                }
                card   = _vipCardDao.GetVIPCard(cardNo, str);
                result = card == null ? 2 : 1;
            }
            catch (Exception exception)
            {
                card = null;
                LogHelper.GetInstance().Error(string.Format("[GetVIPCard]参数:cardNo_{0}", cardNo), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            return(result);
        }
예제 #2
0
 private VIPBO ToBo(VIPCard card, int[] brandIDs, DistributionEntities dbContext)
 {
     if (card != null)
     {
         VIPBO bo = new VIPBO {
             CardInfo = card
         };
         //防止无记录时null产生的空值转int问题,所以先转成int?
         var point = dbContext.VIPPointTrack.Where(v => v.VIPID == card.ID).Sum(v => (int?)v.Point);
         bo.CardPoint = point ?? 0;
         bo.Kinds     = this.GetVIPKinds(card.ID, brandIDs, dbContext);
         if (DateTime.Now.Month == card.Birthday.Month && DateTime.Now.Day == card.Birthday.Day)//当天生日
         {
             var date = DateTime.Now.Date;
             bo.BirthdayConsumption = dbContext.VIPBirthdayConsumption.FirstOrDefault(v => v.VIPID == card.ID && v.ConsumeDay == date);
             bo.BirthdayConsumption = bo.BirthdayConsumption ?? new VIPBirthdayConsumption
             {
                 VIPID      = card.ID,
                 ConsumeDay = DateTime.Now.Date
             };
         }
         return(bo);
     }
     return(null);
 }
예제 #3
0
        public VIPCard GetVIPCard(string cardNo, string password)
        {
            VIPCard card = new VIPCard();

            card.CardNo   = cardNo;
            card.Password = password;
            return(ExecuteQueryForObject("GetVIPCardInfo", card) as VIPCard);
        }
예제 #4
0
        private void myRadDataForm_BeginningEdit(object sender, System.ComponentModel.CancelEventArgs e)
        {
            VIPCard card = (VIPCard)myRadDataForm.CurrentItem;

            if (!_dataContext.DownHierarchyOrganizationIDArray.Contains(card.OrganizationID))
            {
                MessageBox.Show("只能编辑本级或下级机构创建的VIP信息.");
                e.Cancel = true;
            }
        }
    private void ChangeSelectedCard(VIPCard cardType)
    {
        selectedCard = cardType;

        for (int i = 0; i < selectedCardImage.Length; i++)
        {
            selectedCardImage[i].gameObject.SetActive(false);
        }

        selectedCardImage[(int)cardType].gameObject.SetActive(true);

        cardPriceText.text = vipPrivilegeData[(int)cardType][dropDown.value].amount;
    }
예제 #6
0
        /// <summary>
        /// 获取会员卡信息 0:数据库操作失败, 1:成功, 2:会员卡号或者密码错误
        /// </summary>
        public int SearchVIPCard(string cardNo, string password, out VIPCard card)
        {
            const int cByte = ParamFieldLength.PACKAGE_HEAD + ParamFieldLength.CARD_NO + ParamFieldLength.CARD_PASSWORD;

            byte[] sendByte   = new byte[cByte];
            int    byteOffset = 0;

            Array.Copy(BitConverter.GetBytes((int)Command.ID_GET_VIPCARD), sendByte, BasicTypeLength.INT32);
            byteOffset = BasicTypeLength.INT32;
            Array.Copy(BitConverter.GetBytes(cByte), 0, sendByte, byteOffset, BasicTypeLength.INT32);
            byteOffset += BasicTypeLength.INT32;

            byte[] tempByte = null;
            //cardNo
            tempByte = Encoding.UTF8.GetBytes(cardNo);
            Array.Copy(tempByte, 0, sendByte, byteOffset, tempByte.Length);
            byteOffset += ParamFieldLength.CARD_NO;
            //password
            tempByte = Encoding.UTF8.GetBytes(password);
            Array.Copy(tempByte, 0, sendByte, byteOffset, tempByte.Length);
            byteOffset += ParamFieldLength.CARD_PASSWORD;

            int result = 0;

            card = null;
            using (SocketClient socket = new SocketClient(ConstantValuePool.BizSettingConfig.IPAddress, ConstantValuePool.BizSettingConfig.Port))
            {
                Byte[] receiveData = null;
                Int32  operCode    = socket.SendReceive(sendByte, out receiveData);
                if (operCode == (int)RET_VALUE.SUCCEEDED)
                {
                    string strReceive = Encoding.UTF8.GetString(receiveData, ParamFieldLength.PACKAGE_HEAD, receiveData.Length - ParamFieldLength.PACKAGE_HEAD);
                    card   = JsonConvert.DeserializeObject <VIPCard>(strReceive);
                    result = 1;
                }
                else if (operCode == (int)RET_VALUE.ERROR_AUTHENTICATION)
                {
                    result = 2;
                }
                else
                {
                    result = 0;
                }
                socket.Close();
            }
            return(result);
        }
예제 #7
0
 public VIPCardBO(VIPCard vip)
 {
     this.ID           = vip.ID;
     this.CustomerName = vip.CustomerName;
     OrganizationID    = vip.OrganizationID;
     Address           = vip.Address;
     Birthday          = vip.Birthday;
     Code   = vip.Code;
     IDCard = vip.IDCard;
     //if (OrganizationListVM.CurrentOrganization.ParentID == 0 || vip.OrganizationID == VMGlobal.CurrentUser.OrganizationID)
     //    MobilePhone = vip.MobilePhone;
     //else
     //    MobilePhone = "XXXXXXXXXXX";
     MobilePhone      = vip.MobilePhone;
     Sex              = vip.Sex;
     CreateTime       = vip.CreateTime;
     CreatorID        = vip.CreatorID;
     PrestorePassword = vip.PrestorePassword;
 }
예제 #8
0
        public static byte[] SearchVIPCard(byte[] itemBuffer)
        {
            byte[] objRet   = null;
            string cardNo   = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD, ParamFieldLength.CARD_NO).Trim('\0');
            string password = Encoding.UTF8.GetString(itemBuffer, ParamFieldLength.PACKAGE_HEAD + ParamFieldLength.CARD_NO, ParamFieldLength.CARD_PASSWORD).Trim('\0');

            VIPCard card   = null;
            int     result = VIPCardService.GetInstance().GetVIPCard(cardNo, password, out card);

            if (result == 1)
            {
                //获取成功
                string json     = JsonConvert.SerializeObject(card);
                byte[] jsonByte = Encoding.UTF8.GetBytes(json);

                int transCount = BasicTypeLength.INT32 + BasicTypeLength.INT32 + jsonByte.Length;
                objRet = new byte[transCount];
                Array.Copy(BitConverter.GetBytes((int)RET_VALUE.SUCCEEDED), 0, objRet, 0, BasicTypeLength.INT32);
                Array.Copy(BitConverter.GetBytes(transCount), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
                Array.Copy(jsonByte, 0, objRet, 2 * BasicTypeLength.INT32, jsonByte.Length);
            }
            else if (result == 2)
            {
                //会员卡号或者密码错误
                objRet = new byte[ParamFieldLength.PACKAGE_HEAD];
                Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_AUTHENTICATION), 0, objRet, 0, BasicTypeLength.INT32);
                Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            }
            else
            {
                //数据库操作失败
                objRet = new byte[ParamFieldLength.PACKAGE_HEAD];
                Array.Copy(BitConverter.GetBytes((int)RET_VALUE.ERROR_DB), 0, objRet, 0, BasicTypeLength.INT32);
                Array.Copy(BitConverter.GetBytes(ParamFieldLength.PACKAGE_HEAD), 0, objRet, BasicTypeLength.INT32, BasicTypeLength.INT32);
            }
            return(objRet);
        }
    private int[] GetListIndex(string dayString, string cardString)
    {
        int[] listIndex = new int[2];

        int     day        = (int)float.Parse(dayString);
        int     totalCards = Enum.GetNames(typeof(VIPCard)).Length;
        VIPCard card       = VIPCard.Bronze;

        for (int i = 0; i < totalCards; i++)
        {
            if (cardString == "" + (VIPCard)i)
            {
                card = (VIPCard)i;
                break;
            }
        }



        for (int i = 0; i < vipPrivilegeData.Count; i++)
        {
            for (int j = 0; j < vipPrivilegeData[i].Count; j++)
            {
                if (vipPrivilegeData[i][j].day == day && vipPrivilegeData[i][j].vipCard == card)
                {
                    listIndex[0] = i;
                    listIndex[1] = j;

                    i = j = 1000;
                    break;
                }
            }
        }

        return(listIndex);
    }
예제 #10
0
        public Int32 GetVIPCardTradeList(string cardNo, DateTime beginDate, DateTime endDate, out VIPCardTradeRecord cardTradeRecord)
        {
            cardTradeRecord = new VIPCardTradeRecord();
            VIPCard card = null;

            try
            {
                _daoManager.OpenConnection();
                card = _vipCardDao.GetVIPCard(cardNo);
            }
            catch (Exception exception)
            {
                LogHelper.GetInstance().Error(string.Format("[GetVIPCardTradeList]参数:cardNo_{0},beginDate_{1},endDate_{2}", cardNo, beginDate, endDate), exception);
            }
            finally
            {
                _daoManager.CloseConnection();
            }
            int result = 0;

            if (card != null)
            {
                result = card.Status;
            }
            if (result == 1)
            {
                if (card != null)
                {
                    cardTradeRecord.Balance      = card.Balance;
                    cardTradeRecord.Integral     = card.Integral;
                    cardTradeRecord.DiscountRate = card.DiscountRate;
                }
                cardTradeRecord.VIPCardTradeList = _vipCardTradeDao.GetVIPCardTradeList(cardNo, beginDate, endDate);
            }
            return(result);
        }
예제 #11
0
 private void txtVIPCardNo_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyValue == 13)
     {
         _card = null;
         Feature.FormNumericKeypad keyForm = new Feature.FormNumericKeypad(false);
         keyForm.DisplayText = "请输入密码";
         keyForm.IsPassword  = true;
         keyForm.ShowDialog();
         if (!string.IsNullOrEmpty(keyForm.KeypadValue))
         {
             string  cardNo       = txtVIPCardNo.Text.Trim();
             string  cardPassword = keyForm.KeypadValue;
             VIPCard card;
             int     result = VIPCardService.GetInstance().SearchVIPCard(cardNo, cardPassword, out card);
             if (card != null && result == 1)
             {
                 if (card.Status == 0)
                 {
                     MessageBox.Show("该卡未开通,请先开卡!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     return;
                 }
                 txtName.Text      = card.Name;
                 txtBalance.Text   = card.Balance.ToString("f2");
                 txtIntegral.Text  = card.Integral.ToString();
                 txtDiscount.Text  = ((1M - card.DiscountRate) * 10M).ToString("f2") + "折";
                 txtTelephone.Text = card.Telephone;
                 txtAddress.Text   = card.Address;
                 if (card.Status == 1)
                 {
                     txtCardStatus.Text = "启用";
                 }
                 if (card.Status == 2)
                 {
                     txtCardStatus.Text = "锁卡";
                 }
                 if (card.Status == 3)
                 {
                     txtCardStatus.Text = "挂失";
                 }
                 if (card.Status == 4)
                 {
                     txtCardStatus.Text = "作废";
                 }
                 txtOpenCardTime.Text = card.OpenCardTime.ToString("yyyy-MM-dd HH:mm:ss");
                 if (card.LastConsumeTime != null)
                 {
                     txtLastConsumeTime.Text = Convert.ToDateTime(card.LastConsumeTime).ToString("yyyy-MM-dd HH:mm:ss");
                 }
                 _cardNo       = cardNo;
                 _cardPassword = cardPassword;
                 _card         = card;
                 if (card.Balance == 0M)
                 {
                     btnConsume.Enabled   = false;
                     btnConsume.BackColor = ConstantValuePool.DisabledColor;
                 }
                 else
                 {
                     btnConsume.Enabled   = true;
                     btnConsume.BackColor = btnConsume.DisplayColor;
                 }
             }
             else if (result == 2)
             {
                 txtVIPCardNo.Text       = string.Empty;
                 txtName.Text            = string.Empty;
                 txtBalance.Text         = string.Empty;
                 txtIntegral.Text        = string.Empty;
                 txtDiscount.Text        = string.Empty;
                 txtTelephone.Text       = string.Empty;
                 txtAddress.Text         = string.Empty;
                 txtCardStatus.Text      = string.Empty;
                 txtOpenCardTime.Text    = string.Empty;
                 txtLastConsumeTime.Text = string.Empty;
                 MessageBox.Show("您输入的会员卡号或者密码错误!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             else
             {
                 txtVIPCardNo.Text       = string.Empty;
                 txtName.Text            = string.Empty;
                 txtBalance.Text         = string.Empty;
                 txtIntegral.Text        = string.Empty;
                 txtDiscount.Text        = string.Empty;
                 txtTelephone.Text       = string.Empty;
                 txtAddress.Text         = string.Empty;
                 txtCardStatus.Text      = string.Empty;
                 txtOpenCardTime.Text    = string.Empty;
                 txtLastConsumeTime.Text = string.Empty;
                 MessageBox.Show("服务器出现错误,请重新操作!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
 }
예제 #12
0
        public void SetVIP(VIPCard vip)
        {
            this._vipInfo = new VIPInfoForRetail
            {
                ID           = vip.ID,
                Birthday     = vip.Birthday,
                Code         = vip.Code,
                MobilePhone  = vip.MobilePhone,
                CustomerName = vip.CustomerName,
                Sex          = vip.Sex
            };
            string info = vip.CustomerName + (vip.Sex ? "先生" : "女士") + "您好,";

            this._vipInfo.VIPKinds = this.GetVIPKinds(vip.ID);
            if (this._vipInfo.VIPKinds != null && this._vipInfo.VIPKinds.Count > 0)
            {
                if (DateTime.Now.Month == vip.Birthday.Month && DateTime.Now.Day == vip.Birthday.Day)//当天生日
                {
                    this._vipInfo.IsBirthday = true;
                    info += "生日快乐!";
                    var birthdayTactic = this.BirthdayTactic;
                    if (birthdayTactic != null)
                    {
                        info += "今日您能享受";
                        foreach (var kind in this._vipInfo.VIPKinds)
                        {
                            info += (VMGlobal.PoweredBrands.Find(o => o.ID == kind.BrandID).Name + ",");
                        }
                        info = info.TrimEnd(',');
                        if (birthdayTactic.QuantityLimit != null && birthdayTactic.QuantityLimit != 0)
                        {
                            info += string.Format("{0}件以内、", birthdayTactic.QuantityLimit);
                        }
                        if (birthdayTactic.MoneyLimit != null && birthdayTactic.MoneyLimit != 0)
                        {
                            info += string.Format("折前价合计{0}元", birthdayTactic.MoneyLimit);
                        }
                        info  = info.TrimEnd('、');
                        info += "商品";
                        if (birthdayTactic.PointTimes != 1)
                        {
                            this._vipInfo.PointTimes = birthdayTactic.PointTimes;
                            info += string.Format("{0}倍积分,", birthdayTactic.PointTimes);
                        }
                        this._vipInfo.BirthdayDiscount = birthdayTactic.Discount;
                        info += string.Format("{0}折扣,", birthdayTactic.Discount);
                    }
                }
                else
                {
                    info += "您能享受";
                    foreach (var kind in this._vipInfo.VIPKinds)
                    {
                        info += (VMGlobal.PoweredBrands.Find(o => o.ID == kind.BrandID).Name + kind.Name + kind.Discount.ToString() + "折扣,");
                    }
                }
            }
            info += string.Format("您的当前积分为{0}", this.GetVIPPoint(vip.ID));
            this.TraverseGridDataItems(p => this.HandleGridDataItem(p));
            VIPMessage = info;
        }
예제 #13
0
        private void myRadDataForm_AddedNewItem(object sender, AddedNewItemEventArgs e)
        {
            VIPCard card = (VIPCard)myRadDataForm.CurrentItem;

            card.OrganizationID = VMGlobal.CurrentUser.OrganizationID;
        }