コード例 #1
0
        public ArrayList GetCardEntitySNInfoArrayList(string filePath)
        {
            var index = 0;
            var cardEntitySNInfoArrayList = new ArrayList();

            var cardEntitySNInfoList = CSVUtils.Import(filePath);

            if (cardEntitySNInfoList.Count > 0)
            {
                foreach (var info in cardEntitySNInfoList)
                {
                    index++;
                    if (index == 1)
                    {
                        continue;
                    }
                    if (string.IsNullOrEmpty(info))
                    {
                        continue;
                    }
                    var value = info.Split(',');

                    var cardEntitySNInfo = new CardEntitySNInfo();

                    cardEntitySNInfo.PublishmentSystemID = PublishmentSystemID;
                    cardEntitySNInfo.CardID    = cardID;
                    cardEntitySNInfo.SN        = value[0];
                    cardEntitySNInfo.UserName  = value[1];
                    cardEntitySNInfo.Mobile    = value[2];
                    cardEntitySNInfo.Email     = value[3];
                    cardEntitySNInfo.Address   = value[4];
                    cardEntitySNInfo.Amount    = TranslateUtils.ToDecimal(value[5]);
                    cardEntitySNInfo.Credits   = TranslateUtils.ToInt(value[6]);
                    cardEntitySNInfo.IsBinding = false;
                    cardEntitySNInfo.AddDate   = DateTime.Now;
                    cardEntitySNInfoArrayList.Add(cardEntitySNInfo);
                }
            }
            return(cardEntitySNInfoArrayList);
        }
コード例 #2
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            var isChanged = false;

            try
            {
                if (flg == 0)
                {
                    var totalNum = TranslateUtils.ToInt(tbTotalNum.Text);
                    if (totalNum > 1000)
                    {
                        FailMessage("新增失败,一次最多只能新增1000张优惠劵");
                    }
                    else
                    {
                        DataProviderWX.CouponSNDAO.Insert(PublishmentSystemID, couponID, totalNum);

                        StringUtility.AddLog(PublishmentSystemID, "新增优惠劵数量", $"数量:{totalNum}");
                        isChanged = true;
                    }
                }
                if (flg == 1)
                {
                    //string filehou = this.hifUpload.PostedFile.FileName.Split('.')[1].ToString();

                    //if (filehou != "xls" || filehou != "xlsx")
                    //{
                    //    base.FailMessage("请检查上传文件的类型.必须为EXCEL文件.");
                    //}

                    var filePath = PathUtils.GetTemporaryFilesPath("coupon_sn_upload.csv");
                    FileUtils.DeleteFileIfExists(filePath);

                    hifUpload.PostedFile.SaveAs(filePath);

                    try
                    {
                        var snList = CSVUtils.Import(filePath);

                        if (snList.Count > 0)
                        {
                            DataProviderWX.CouponSNDAO.Insert(PublishmentSystemID, couponID, snList);
                            StringUtility.AddLog(PublishmentSystemID, "新增优惠劵数量", $"数量:{snList.Count}");
                            isChanged = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "失败:" + ex.Message);
                    }
                }
            }
            catch (Exception ex)
            {
                FailMessage(ex, "失败:" + ex.Message);
            }

            if (isChanged)
            {
                JsUtils.OpenWindow.CloseModalPage(Page);
            }
        }