Ejemplo n.º 1
0
        public List <string> GetUserNameList(int publishmentSystemId, int cardId, string cardSn, string userName)
        {
            var userNameList = new List <string>();

            string sqlWhere = $"WHERE {CardSnAttribute.PublishmentSystemId} = {publishmentSystemId} ";

            if (cardId > 0)
            {
                sqlWhere += $" AND CardID = {cardId}";
            }
            if (!string.IsNullOrEmpty(cardSn))
            {
                sqlWhere += $" AND {CardSnAttribute.Sn}='{PageUtils.FilterSql(cardSn)}'";
            }
            if (!string.IsNullOrEmpty(userName))
            {
                sqlWhere += $" AND {CardSnAttribute.UserName} ='{PageUtils.FilterSql(userName)}'";
            }
            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var cardSnInfo = new CardSnInfo(rdr);
                    if (!userNameList.Contains(cardSnInfo.UserName))
                    {
                        userNameList.Add(cardSnInfo.UserName);
                    }
                }
                rdr.Close();
            }
            return(userNameList);
        }
Ejemplo n.º 2
0
        public void Update(CardSnInfo cardSnInfo)
        {
            IDataParameter[] parms = null;
            var sqlUpdate          = BaiRongDataProvider.TableStructureDao.GetUpdateSqlString(cardSnInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);

            ExecuteNonQuery(sqlUpdate, parms);
        }
Ejemplo n.º 3
0
        public int Insert(CardSnInfo cardSnInfo)
        {
            var cardSnid = 0;

            IDataParameter[] parms = null;

            var sqlInsert = BaiRongDataProvider.TableStructureDao.GetInsertSqlString(cardSnInfo.ToNameValueCollection(), ConnectionString, TableName, out parms);


            using (var conn = GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        cardSnid = ExecuteNonQueryAndReturnId(trans, sqlInsert, parms);

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        throw;
                    }
                }
            }

            return(cardSnid);
        }
Ejemplo n.º 4
0
        public CardSnInfo GetCardSnInfo(int publishmentSystemId, int cardId, string cardSn, string userName)
        {
            CardSnInfo cardSnInfo = null;

            string sqlWhere = $"WHERE {CardSnAttribute.PublishmentSystemId} = {publishmentSystemId} ";

            if (cardId > 0)
            {
                sqlWhere += $" AND {CardSnAttribute.CardId}='{cardId}'";
            }
            if (!string.IsNullOrEmpty(cardSn))
            {
                sqlWhere += $" AND {CardSnAttribute.Sn}='{PageUtils.FilterSql(cardSn)}'";
            }
            if (!string.IsNullOrEmpty(userName))
            {
                sqlWhere += $" AND {CardSnAttribute.UserName}='{PageUtils.FilterSql(userName)}'";
            }
            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                if (rdr.Read())
                {
                    cardSnInfo = new CardSnInfo(rdr);
                }
                rdr.Close();
            }
            return(cardSnInfo);
        }
Ejemplo n.º 5
0
        public decimal GetAmount(int cardSnid, string userName)
        {
            decimal amount = 0;

            string sqlWhere  = $"WHERE ID = {cardSnid} AND userName='******'";
            var    sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                if (rdr.Read())
                {
                    var cardSnInfo = new CardSnInfo(rdr);
                    amount = cardSnInfo.Amount;
                }
                rdr.Close();
            }
            return(amount);
        }
Ejemplo n.º 6
0
        public CardSnInfo GetCardSnInfo(int cardSnid)
        {
            CardSnInfo cardSnInfo = null;

            string sqlWhere  = $"WHERE ID = {cardSnid}";
            var    sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                if (rdr.Read())
                {
                    cardSnInfo = new CardSnInfo(rdr);
                }
                rdr.Close();
            }

            return(cardSnInfo);
        }
Ejemplo n.º 7
0
        public List <CardSnInfo> GetCardSnInfoList(int publishmentSystemId, int cardId)
        {
            var cardSnInfoList = new List <CardSnInfo>();

            string sqlWhere =
                $"WHERE {CardSnAttribute.PublishmentSystemId} = {publishmentSystemId} AND {CardSnAttribute.CardId} = {cardId}";
            var sqlSelect = BaiRongDataProvider.TableStructureDao.GetSelectSqlString(ConnectionString, TableName, 0, SqlUtils.Asterisk, sqlWhere, null);

            using (var rdr = ExecuteReader(sqlSelect))
            {
                while (rdr.Read())
                {
                    var cardSnInfo = new CardSnInfo(rdr);
                    cardSnInfoList.Add(cardSnInfo);
                }
                rdr.Close();
            }
            return(cardSnInfoList);
        }
Ejemplo n.º 8
0
        void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                var cardSnInfo = new CardSnInfo(e.Item.DataItem);
                var userInfo   = BaiRongDataProvider.UserDao.GetUserInfoByUserName(cardSnInfo.UserName);
                //var userContactInfo = BaiRongDataProvider.UserContactDao.GetContactInfo(cardSnInfo.UserName);

                var ltlItemIndex  = e.Item.FindControl("ltlItemIndex") as Literal;
                var ltlSn         = e.Item.FindControl("ltlSN") as Literal;
                var ltlUserName   = e.Item.FindControl("ltlUserName") as Literal;
                var ltlMobile     = e.Item.FindControl("ltlMobile") as Literal;
                var ltlAmount     = e.Item.FindControl("ltlAmount") as Literal;
                var ltlCredits    = e.Item.FindControl("ltlCredits") as Literal;
                var ltlAddDate    = e.Item.FindControl("ltlAddDate") as Literal;
                var ltlIsDisabled = e.Item.FindControl("ltlIsDisabled") as Literal;

                var ltlConsumeUrl  = e.Item.FindControl("ltlConsumeUrl") as Literal;
                var ltlRechargeUrl = e.Item.FindControl("ltlRechargeUrl") as Literal;
                var ltlCreditesUrl = e.Item.FindControl("ltlCreditesUrl") as Literal;

                ltlItemIndex.Text = (e.Item.ItemIndex + 1).ToString();
                ltlSn.Text        = cardSnInfo.Sn;
                if (userInfo != null)
                {
                    ltlUserName.Text = userInfo.DisplayName;
                    ltlMobile.Text   = userInfo.Mobile;
                }
                ltlAmount.Text     = cardSnInfo.Amount.ToString();
                ltlAddDate.Text    = DateUtils.GetDateAndTimeString(cardSnInfo.AddDate);
                ltlIsDisabled.Text = cardSnInfo.IsDisabled ? "使用" : "冻结";
                ltlConsumeUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{ModalCardConsume.GetOpenWindowString(PublishmentSystemId,
                        cardSnInfo.CardId, cardSnInfo.Id)}"">消费</a>";
                ltlRechargeUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{ModalCardRecharge.GetOpenWindowString(PublishmentSystemId,
                        cardSnInfo.CardId, cardSnInfo.Id)}"">充值</a>";
                ltlCreditesUrl.Text =
                    $@"<a href=""javascript:;"" onclick=""{ModalCardCredits.GetOpenWindowString(PublishmentSystemId,
                        cardSnInfo.CardId, cardSnInfo.Id)}"">积分</a>";
            }
        }
Ejemplo n.º 9
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                try
                {
                    if (!string.IsNullOrEmpty(TbUserNameList.Text))
                    {
                        var userNameList = TranslateUtils.StringCollectionToStringList(TbUserNameList.Text);
                        foreach (var userName in userNameList)
                        {
                            var cardSnInfo = new CardSnInfo();
                            cardSnInfo.PublishmentSystemId = PublishmentSystemId;
                            cardSnInfo.CardId     = _cardId;
                            cardSnInfo.Sn         = DataProviderWx.CardSnDao.GetNextCardSn(PublishmentSystemId, _cardId);
                            cardSnInfo.Amount     = 0;
                            cardSnInfo.UserName   = userName;
                            cardSnInfo.IsDisabled = true;
                            cardSnInfo.AddDate    = DateTime.Now;

                            var isExist = DataProviderWx.CardSnDao.IsExists(PublishmentSystemId, _cardId, userName);
                            if (!isExist)
                            {
                                DataProviderWx.CardSnDao.Insert(cardSnInfo);
                            }
                        }
                    }

                    LogUtils.AddAdminLog(Body.AdministratorName, "领取会员卡成功", $"会员卡:{TbUserNameList.Text}");
                    SuccessMessage("领取会员卡成功!");
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "领取会员卡失败!");
                }
            }
        }
Ejemplo n.º 10
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (IsPostBack && IsValid)
            {
                UserInfo   userInfo   = null;
                CardSnInfo cardSnInfo = null;

                if (_cardSnid > 0)
                {
                    cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(_cardSnid);
                }
                else
                {
                    if (DdlKeyWordType.SelectedValue == "cardSN")
                    {
                        cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(PublishmentSystemId, TranslateUtils.ToInt(DdlCard.SelectedValue), TbKeyWord.Text, string.Empty);
                    }
                    else if (DdlKeyWordType.SelectedValue == "mobile")
                    {
                        var userId = BaiRongDataProvider.UserDao.GetUserIdByEmailOrMobile(string.Empty, TbKeyWord.Text);
                        userInfo = BaiRongDataProvider.UserDao.GetUserInfo(userId);
                        if (userInfo != null)
                        {
                            cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(PublishmentSystemId, TranslateUtils.ToInt(DdlCard.SelectedValue), string.Empty, userInfo.UserName);
                        }
                    }
                }

                if (cardSnInfo == null)
                {
                    FailMessage("会员卡不存在");
                    return;
                }

                var consumeType = EConsumeTypeUtils.GetEnumType(DdlConsumeType.SelectedValue);

                if (consumeType == EConsumeType.CardAmount)
                {
                    var amount = DataProviderWx.CardSnDao.GetAmount(cardSnInfo.Id, cardSnInfo.UserName);
                    if (amount < TranslateUtils.ToDecimal(TbConsumeAmount.Text))
                    {
                        FailMessage("会员卡余额不足");
                        return;
                    }
                }

                var cardCashLogInfo = new CardCashLogInfo();
                cardCashLogInfo.PublishmentSystemId = PublishmentSystemId;
                cardCashLogInfo.UserName            = cardSnInfo.UserName;
                cardCashLogInfo.CardId    = cardSnInfo.CardId;
                cardCashLogInfo.CardSnId  = cardSnInfo.Id;
                cardCashLogInfo.Amount    = TranslateUtils.ToDecimal(TbConsumeAmount.Text);
                cardCashLogInfo.CurAmount = cardSnInfo.Amount;
                if (consumeType == EConsumeType.CardAmount)
                {
                    cardCashLogInfo.CurAmount = cardSnInfo.Amount - TranslateUtils.ToInt(TbConsumeAmount.Text);
                }

                cardCashLogInfo.CashType    = ECashTypeUtils.GetValue(ECashType.Consume);
                cardCashLogInfo.ConsumeType = DdlConsumeType.SelectedValue;
                cardCashLogInfo.Operator    = DdlOperator.SelectedValue;
                cardCashLogInfo.AddDate     = DateTime.Now;

                try
                {
                    DataProviderWx.CardCashLogDao.Insert(cardCashLogInfo);

                    if (consumeType == EConsumeType.CardAmount)
                    {
                        DataProviderWx.CardSnDao.Consume(cardSnInfo.Id, cardSnInfo.UserName, TranslateUtils.ToDecimal(TbConsumeAmount.Text));

                        if (PublishmentSystemInfo.Additional.WxCardIsClaimCardCredits)
                        {
                            var amount        = TranslateUtils.ToDecimal(TbConsumeAmount.Text);
                            var consumeAmount = PublishmentSystemInfo.Additional.WxCardConsumeAmount;
                            var giveCredits   = PublishmentSystemInfo.Additional.WxCardGiveCredits;

                            //var userCreditsLogInfo = new UserCreditsLogInfo();
                            //userCreditsLogInfo.UserName = cardSNInfo.UserName;
                            //userCreditsLogInfo.ProductId = AppManager.WeiXin.AppID;
                            //userCreditsLogInfo.Num = (int)Math.Round(amount * (giveCredits / consumeAmount), 0);
                            //userCreditsLogInfo.AddDate = DateTime.Now;
                            //userCreditsLogInfo.IsIncreased = true;
                            //userCreditsLogInfo.Action = "消费送积分";

                            //BaiRongDataProvider.UserCreditsLogDao.Insert(userCreditsLogInfo);
                            //BaiRongDataProvider.UserDao.AddCredits(cardSNInfo.UserName, (int)Math.Round(amount * (giveCredits / consumeAmount), 0));
                        }
                    }
                    TbConsumeAmount.Text = string.Empty;

                    SuccessMessage("操作成功!");

                    //PageUtils.CloseModalPage(Page);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "操作失败!");
                }
            }
        }
Ejemplo n.º 11
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (IsPostBack && IsValid)
            {
                UserInfo   userInfo   = null;
                CardSnInfo cardSnInfo = null;
                if (_cardSnid > 0)
                {
                    cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(_cardSnid);
                }
                else
                {
                    if (DdlKeyWordType.SelectedValue == "cardSN")
                    {
                        cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(PublishmentSystemId, TranslateUtils.ToInt(DdlCard.SelectedValue), TbKeyWord.Text, string.Empty);
                    }
                    else if (DdlKeyWordType.SelectedValue == "mobile")
                    {
                        var userId = BaiRongDataProvider.UserDao.GetUserIdByEmailOrMobile(string.Empty, TbKeyWord.Text);
                        userInfo = BaiRongDataProvider.UserDao.GetUserInfo(userId);
                        if (userInfo != null)
                        {
                            cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(PublishmentSystemId, TranslateUtils.ToInt(DdlCard.SelectedValue), string.Empty, userInfo.UserName);
                        }
                    }
                }

                if (cardSnInfo == null)
                {
                    FailMessage("会员卡不存在");
                    return;
                }

                var cardCashLogInfo = new CardCashLogInfo();
                cardCashLogInfo.PublishmentSystemId = PublishmentSystemId;
                cardCashLogInfo.UserName            = cardSnInfo.UserName;
                cardCashLogInfo.CardId      = cardSnInfo.CardId;
                cardCashLogInfo.CardSnId    = cardSnInfo.Id;
                cardCashLogInfo.Amount      = TranslateUtils.ToInt(TbRechargeAmount.Text);
                cardCashLogInfo.CurAmount   = cardSnInfo.Amount + TranslateUtils.ToDecimal(TbRechargeAmount.Text);
                cardCashLogInfo.CashType    = ECashTypeUtils.GetValue(ECashType.Recharge);
                cardCashLogInfo.Operator    = DdlOperator.SelectedValue;
                cardCashLogInfo.Description = TbDescription.Text;
                cardCashLogInfo.AddDate     = DateTime.Now;

                try
                {
                    DataProviderWx.CardCashLogDao.Insert(cardCashLogInfo);
                    DataProviderWx.CardSnDao.Recharge(cardSnInfo.Id, cardSnInfo.UserName, TranslateUtils.ToDecimal(TbRechargeAmount.Text));

                    TbRechargeAmount.Text = string.Empty;

                    SuccessMessage("充值成功!");

                    //PageUtils.CloseModalPage(Page);
                }
                catch (Exception ex)
                {
                    FailMessage(ex, "充值失败!");
                }
            }
        }
Ejemplo n.º 12
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (IsPostBack && IsValid)
            {
                UserInfo   userInfo   = null;
                CardSnInfo cardSnInfo = null;

                if (_cardSnid > 0)
                {
                    cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(_cardSnid);
                    userInfo   = BaiRongDataProvider.UserDao.GetUserInfoByUserName(cardSnInfo != null? cardSnInfo.UserName:string.Empty);
                }
                else
                {
                    if (DdlKeyWordType.SelectedValue == "cardSN")
                    {
                        cardSnInfo = DataProviderWx.CardSnDao.GetCardSnInfo(PublishmentSystemId, TranslateUtils.ToInt(DdlCard.SelectedValue), TbKeyWord.Text, string.Empty);
                        userInfo   = BaiRongDataProvider.UserDao.GetUserInfoByUserName(cardSnInfo != null ? cardSnInfo.UserName : string.Empty);
                    }
                    else if (DdlKeyWordType.SelectedValue == "mobile")
                    {
                        var userId = BaiRongDataProvider.UserDao.GetUserIdByEmailOrMobile(string.Empty, TbKeyWord.Text);
                        userInfo = BaiRongDataProvider.UserDao.GetUserInfo(userId);
                    }
                }

                if (userInfo == null)
                {
                    FailMessage("会员不存在");
                    return;
                }

                //var userCreditsLogInfo = new UserCreditsLogInfo();
                //userCreditsLogInfo.UserName = userInfo.UserName;
                //userCreditsLogInfo.ProductId = AppManager.WeiXin.AppID;
                //userCreditsLogInfo.Num = TranslateUtils.ToInt(TbCredits.Text);
                //userCreditsLogInfo.AddDate = DateTime.Now;

                //try
                //{
                //    if (DdlOperatType.SelectedValue == "add")
                //    {
                //        userCreditsLogInfo.IsIncreased = true;
                //        userCreditsLogInfo.Action = "手动添加积分";
                //        BaiRongDataProvider.UserCreditsLogDao.Insert(userCreditsLogInfo);
                //        BaiRongDataProvider.UserDao.AddCredits(userInfo.UserName, TranslateUtils.ToInt(TbCredits.Text));
                //    }
                //    else if (DdlOperatType.SelectedValue == "reduce")
                //    {
                //        userCreditsLogInfo.IsIncreased = false;
                //        userCreditsLogInfo.Action = "手动扣除积分";
                //        BaiRongDataProvider.UserCreditsLogDao.Insert(userCreditsLogInfo);
                //        BaiRongDataProvider.UserDao.AddCredits(userInfo.UserName, -TranslateUtils.ToInt(TbCredits.Text));
                //    }
                //    TbCredits.Text = string.Empty;

                //    SuccessMessage("操作成功!");

                //    //PageUtils.CloseModalPage(Page);

                //}
                //catch (Exception ex)
                //{
                //    FailMessage(ex, "操作失败!");
                //}
            }
        }