//导入操作
        //读取excel文件
        public void ReadExcel(string path)
        {
            //流
            using (FileStream fsRead = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                List <MemberInfo> list = new List <MemberInfo>();

                //获取工作表
                IWorkbook wookbook = WorkbookFactory.Create(fsRead);
                //获取页
                ISheet sheet = wookbook.GetSheetAt(0);
                //遍历该页的所有行
                for (int i = 0; i <= sheet.LastRowNum; i++)
                {
                    MemberInfo member = new MemberInfo();
                    //获取行
                    IRow row = sheet.GetRow(i);
                    //第一行是id   =======0
                    member.MemName        = row.GetCell(1).StringCellValue;                   //名字
                    member.MemMobilePhone = row.GetCell(2).StringCellValue;                   //电话
                    member.DelFlag        = Convert.ToInt32(row.GetCell(3).NumericCellValue); //删除标识   注意转换。把表格数据看成string(实际有string和numeric),不是string的member属性全部要转换


                    list.Add(member);
                    //把Excel文件的数据插入到数据库中
                }//end for
                 //循环结束---list集合中有很多会员对象了---传到DAL中
                memDal.AddMemberInfo(list);
            }  //end using
        }
Beispiel #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="memberInfo">会员对象</param>
 /// <param name="flag">标识  1 新增 2修改</param>
 /// <returns>成功或者失败</returns>
 public bool AddOrUpdateMemberInfo(MemberInfo memberInfo, int flag)
 {
     if (flag == 1)
     {
         return(dal.AddMemberInfo(memberInfo) > 0);
     }
     else if (flag == 2)
     {
         return(dal.UpdateMemberInfo(memberInfo) > 0);
     }
     return(false);
 }
Beispiel #3
0
        /// <summary>
        /// 保存新增或者修改会员的信息
        /// </summary>
        /// <param name="mem"></param>
        /// <param name="temp">1-> Add; 2-> Modify</param>
        /// <returns>成功或者失败</returns>
        public bool SaveMemberInfo(MemberInfo mem, int temp)
        {
            int r = -1;

            if (temp == 1)//新增
            {
                r = dal.AddMemberInfo(mem);
            }
            else if (temp == 2)//修改
            {
                r = dal.UpdateMemberInfo(mem);
            }

            return(r > 0);
        }
Beispiel #4
0
        /// <summary>
        ///注册会员(已追加注册返还金额功能)
        /// </summary>
        public string AddMemberInfo(MemberInfoModel model)
        {
            string result = "1";
            string value  = SysAdminConfigDAL.GetConfigsByID(4);//得到注册返还金额

            #region 验证用户真实姓名 和手机
            int rows = MemberInfoDAL.GetMemberCountInfoByName(model.TruethName.Trim());
            if (rows > 2)
            {
                return("0用户姓名重复");
            }
            rows = MemberInfoDAL.GetMemberCountInfoByMobile(model.MobileNum.Trim());
            if (rows > 0)
            {
                return("0手机号已被注册");
            }
            //rows = MemberInfoDAL.GetMemberCountInfoByAlipayNum(model.AliPayNum.Trim());
            //if (rows > 0)
            //{
            //    return "0支付宝ID已被注册";
            //}
            rows = MemberInfoDAL.GetMemberCountInfoByAliPayName(model.AliPayName.Trim());
            if (rows > 0)
            {
                return("0支付宝账户已被注册");
            }
            #endregion
            using (TransactionScope scope = new TransactionScope())
            {
                int memberid = dal.AddMemberInfo(model);
                if (memberid < 1)
                {
                    return("0注册失败");
                }
                decimal amont = 0;
                if (!string.IsNullOrWhiteSpace(value))
                {
                    if (!decimal.TryParse(value, out amont))
                    {
                        return("0注册失败");
                    }
                    int row = MemberCapitalDetailDAL.UpdateMemberStaticFreezeMoney(memberid, amont, model.TruethName, model.MobileNum);
                    if (row < 1)
                    {
                        return("0注册失败");
                    }
                }
                //返还激活码金额
                AmountChangeLogModel logmodel = new AmountChangeLogModel();
                logmodel.MemberID     = memberid;
                logmodel.MemberName   = model.TruethName;
                logmodel.MemberPhone  = model.MobileNum;
                logmodel.ProduceMoney = amont;
                logmodel.Remark       = "会员注册激活码" + amont.ToString() + "元";
                logmodel.Type         = 5;
                int rowcount = OperateLogDAL.AddAmountChangeLog(logmodel);
                if (rowcount < 1)
                {
                    return("0注册失败");
                }
                if (model.MemberPhone != model.MobileNum)
                {
                    //插入推荐人信息表
                    MemberInfoModel soucemember = MemberInfoDAL.GetMember(model.MemberPhone);
                    if (soucemember.MStatus == 3)
                    {
                        return("0推荐人账户被冻结");
                    }
                    ReMemberRelationModel remodel = new ReMemberRelationModel();
                    remodel.MemberID         = soucemember.ID;
                    remodel.MemberTruthName  = soucemember.TruethName;
                    remodel.MemberPhone      = soucemember.MobileNum;
                    remodel.RecommMID        = memberid;
                    remodel.RecommMPhone     = model.MobileNum;
                    remodel.RecommMTruthName = model.TruethName;
                    rowcount = ReMemberRelationDAL.AddReMemberRelation(remodel);
                    if (rowcount < 1)
                    {
                        return("0注册失败");
                    }
                }
                //初始化会员扩展信息表
                MemberExtendInfoModel extendinfo = new MemberExtendInfoModel();
                extendinfo.MemberID        = memberid;
                extendinfo.MemberHelpCount = 0;
                extendinfo.LastHelpMoney   = 0;
                extendinfo.LastHelperTime  = DateTime.Now.AddYears(-1);
                rowcount = MemberExtendInfoDAL.AddModelExtendinfo(extendinfo);
                if (rowcount < 1)
                {
                    return("0注册失败");
                }
                scope.Complete();
                result = "1";
            }
            return(result);
        }