Пример #1
0
        public KeHu UpdateSingle(int id, KeHuReq data)
        {
            KeHu model = db.KeHu.Find(id);

            SetKeHu(model, data);
            db.SaveChanges();
            return(model);
        }
Пример #2
0
        /// <summary>
        /// 设置model,如果不为空就设置,如果为空则和之前一样
        /// </summary>
        /// <param name="target"></param>
        /// <param name="source"></param>
        /// <returns></returns>
        public KeHu SetKeHu(KeHu model, KeHuReq data)
        {
            if (!string.IsNullOrEmpty(data.KhName))
            {
                model.KhName = data.KhName;
            }
            if (!string.IsNullOrEmpty(data.KhPhone))
            {
                model.KhPhone = data.KhPhone;
            }
            if (data.KhYuChanQi != null && data.KhYuChanQi != DateTime.MinValue &&
                data.KhYuChanQi != SqlDateTime.MinValue.Value)
            {
                model.KhYuChanQi = data.KhYuChanQi.Value;
            }
            if (!string.IsNullOrEmpty(data.KhHospital))
            {
                model.KhHospital = data.KhHospital;
            }
            if (!string.IsNullOrEmpty(data.KhIDCardNumber))
            {
                model.KhIDCardNumber = data.KhIDCardNumber;
            }
            if (!string.IsNullOrEmpty(data.KhAddress))
            {
                model.KhAddress = data.KhAddress;
            }
            if (!string.IsNullOrEmpty(data.KhFamilyName))
            {
                model.KhFamilyName = data.KhFamilyName;
            }
            if (!string.IsNullOrEmpty(data.KhFamilyPhone))
            {
                model.KhFamilyPhone = data.KhFamilyPhone;
            }
            if (!string.IsNullOrEmpty(data.KhFamilyShouRu))
            {
                model.KhFamilyShouRu = data.KhFamilyShouRu;
            }
            if (!string.IsNullOrEmpty(data.KhXueXing))
            {
                model.KhXueXing = data.KhXueXing;
            }
            if (!string.IsNullOrEmpty(data.KhXingZuo))
            {
                model.KhXingZuo = data.KhXingZuo;
            }
            if (!string.IsNullOrEmpty(data.KhXingGe))
            {
                model.KhXingGe = data.KhXingGe;
            }
            if (!string.IsNullOrEmpty(data.KhGuanZhuWangZhan))
            {
                model.KhGuanZhuWangZhan = data.KhGuanZhuWangZhan;
            }
            if (!string.IsNullOrEmpty(data.KhXiuXianFangShi))
            {
                model.KhXiuXianFangShi = data.KhXiuXianFangShi;
            }
            if (!string.IsNullOrEmpty(data.KhYinShiXiGuan))
            {
                model.KhYinShiXiGuan = data.KhYinShiXiGuan;
            }
            if (!string.IsNullOrEmpty(data.KhGuoMinLeiFood))
            {
                model.KhGuoMinLeiFood = data.KhGuoMinLeiFood;
            }
            if (!string.IsNullOrEmpty(data.KhFamilyYCBS))
            {
                model.KhFamilyYCBS = data.KhFamilyYCBS;
            }
            if (!string.IsNullOrEmpty(data.KhQiTaBingLi))
            {
                model.KhQiTaBingLi = data.KhQiTaBingLi;
            }
            if (!string.IsNullOrEmpty(data.KhSales))
            {
                model.KhSales = data.KhSales;
            }
            if (data.projectid != null)
            {
                model.ProjectID = data.projectid.Value;
            }
            if (!string.IsNullOrEmpty(data.KhRemarks))
            {
                model.KhRemarks = data.KhRemarks;
            }
            if (!string.IsNullOrEmpty(data.optName))
            {
                model.optName = data.optName;
            }
            if (!string.IsNullOrEmpty(data.ValidState))
            {
                model.ValidState = data.ValidState;
            }
            if (data.KhSalesId != null)
            {
                model.KhSalesId = data.KhSalesId;
            }
            if (data.KhSalesSystemId != null)
            {
                model.KhSalesSystemId = data.KhSalesSystemId;
            }
            if (data.optDateTime != null && data.optDateTime != DateTime.MinValue &&
                data.optDateTime != SqlDateTime.MinValue.Value)
            {
                model.optDateTime = data.optDateTime.Value;
            }

            if (!string.IsNullOrEmpty(data.KhState))
            {
                model.KhState = data.KhState;
            }
            return(model);
        }
Пример #3
0
        //同步喜喜会所客户到扫e嫂客户表(设置此客户为喜喜VIP并同步会所信息)
        public Seskehu SyncXixiKhToSes(KeHu xxKh)
        {
            var ysDb = new YueSaoErpContext();
            var ysKh = ysDb.Seskehu.FirstOrDefault(n => n.KhPhoneNumber == xxKh.KhPhone || n.KeFuKhPhoneNumber == xxKh.KhPhone);

            if (ysKh == null)
            {
                var huisuoId = ysDb.yuezihuiSuoInfo.Where(n => n.xixiHuisuoId == xxKh.ProjectID).Select(n => n.id).FirstOrDefault();

                if (xxKh != null)
                {
                    ysKh = new Seskehu
                    {
                        FuWuYueSaoID            = 0,
                        FuWuYueSaoName          = string.Empty,
                        huisuoID                = huisuoId,
                        KeFuKhPhoneNumber       = xxKh.KhPhone,
                        KhAddress               = xxKh.KhAddress,
                        KhAge                   = 30,
                        KhBabyMonth             = 0,
                        KhCallClassName         = string.Empty,
                        KhCallDateTime          = null,
                        KhCity                  = string.Empty,
                        KhClassName             = "会所客户",
                        KhCreateTime            = DateTime.Now,
                        KhCreateTimeEnd         = DateTime.Now,
                        KhCreateTimeStart       = DateTime.Now,
                        KhInfos                 = xxKh.KhRemarks,
                        KhLaiYuan               = xxKh.KhSales,
                        KhName                  = xxKh.KhName,
                        KhPhoneNumber           = xxKh.KhPhone,
                        KhPsd                   = BinaryUtil.Md5(xxKh.KhPhone).Substring(6, 20),
                        KhPsdNew                = string.Empty,
                        KhState                 = string.Empty,
                        KhWeiXin                = string.Empty,
                        KhWeiXinID              = string.Empty,
                        KhYeWu                  = string.Empty,
                        KhYuChanHospital        = xxKh.KhHospital,
                        KhYuChanHospitalAddress = string.Empty,
                        KhYuChanQi              = xxKh.KhYuChanQi,
                        KhYuChanQiEnd           = DateTime.Now,
                        KhYuChanQiStart         = DateTime.Now,
                        OptName                 = xxKh.optName,
                        ProjectId               = 1, //默认为上海
                        SalesName               = xxKh.KhSales,
                        xixiVip                 = 1
                    }
                }
                ;

                ysDb.Seskehu.Add(ysKh);
            }
            else
            {
                ysKh.xixiVip  = 1;
                ysKh.huisuoID =
                    ysDb.yuezihuiSuoInfo.Where(n => n.xixiHuisuoId == xxKh.ProjectID).Select(n => n.id).FirstOrDefault();
                if (string.IsNullOrWhiteSpace(ysKh.KhPhoneNumber))
                {
                    ysKh.KhPhoneNumber = ysKh.KeFuKhPhoneNumber;
                    ysKh.KhPsd         = BinaryUtil.Md5(ysKh.KeFuKhPhoneNumber).Substring(6, 20);
                }
                ysKh.KhName = xxKh.KhName;
            }
            ysDb.SaveChanges();
            return(ysKh);
        }