Beispiel #1
0
        public static void CreateCells(this IRow row, object data)
        {
            Type t = data.GetType();
            int  i = 0;

            foreach (var Propertie in t.GetProperties())
            {
                var cell = row.CreateCell(i++);
                cell.SetCellValue(Convert.ChangeType(Propertie.GetValue(data), Propertie.PropertyType).ToString());
            }
        }
        public async Task <JsonResult> Edit([FromBody] BranchModel branchModel)
        {
            AppIdentityUser _user = await _userManager.FindByNameAsync(User.Identity.Name);

            BrhFrontDeskAccounts  brhFrontDeskAccounts = new BrhFrontDeskAccounts();
            BrhFrontPaymentDetial bfp = new BrhFrontPaymentDetial();
            var rtotal = _context.BrhFrontPaymentDetials.Where(x => x.FrontDeskAccountsId == branchModel.FrontDeskAccountsId).Sum(x => x.PayAmount);

            if (branchModel.PayAmount != 0)
            {
                bfp.FrontDeskAccountsId = branchModel.FrontDeskAccountsId;
                bfp.PayWay    = branchModel.PayWay;
                bfp.PayDate   = branchModel.PayDate;
                bfp.PayAmount = branchModel.PayAmount;
            }
            else
            {
                bfp.PayAmount = 0;
            }

            branchModel.Received = rtotal + bfp.PayAmount;
            if (branchModel.Receivable == branchModel.Received)
            {
                branchModel.IsFinish = true;
            }
            else
            {
                branchModel.IsFinish = false;
            }

            var ParentType = typeof(BrhFrontDeskAccounts);
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(brhFrontDeskAccounts, Propertie.GetValue(branchModel, null), null);
                }
            }
            if (branchModel.PayAmount != 0)
            {
                brhFrontDeskAccounts.BrhFrontPaymentDetial.Add(bfp);
            }
            _context.Update(brhFrontDeskAccounts);
            _context.SaveChanges();
            Event eve = branchModel;

            return(Json(eve));
        }
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="value"></param>
        /// <returns></returns>
        public static T ToChild <T>(this object value) where T : new()
        {
            T   model      = new T();
            var ParentType = value.GetType();
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    Propertie.SetValue(model, Propertie.GetValue(value, null), null);
                }
            }
            return(model);
        }
        /// <summary>
        /// ��������-���ำֵ������
        /// </summary>
        /// <typeparam name="TParent"></typeparam>
        /// <typeparam name="TChild"></typeparam>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static void AutoCopy <TParent, TChild>(TParent parent, TChild child) where TChild : TParent, new()
        {
            var ParentType = typeof(TParent);
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //ѭ����������
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //�������Կ���
                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// 父类转子类
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public virtual T Parse <T>() where T : new()
        {
            T   obj        = new T();
            var ParentType = this.GetType();
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    Propertie.SetValue(obj, Propertie.GetValue(this, null), null);
                }
            }
            return(obj);
        }
        public static TChild AutoCopy <TParent, TChild>(TParent parent) where TChild : TParent, new()
        {
            TChild child      = new TChild();
            var    ParentType = typeof(TParent);
            var    Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
                }
            }
            return(child);
        }
Beispiel #7
0
        /// <summary>
        /// 构造
        /// </summary>
        /// <param name="zhgd_Iot_discharge_Current"></param>
        //public static Zhgd_iot_discharge_working Get_Zhgd_iot_discharge_working(Zhgd_iot_discharge_current zhgd_Iot_discharge_Current)
        //{
        //    Zhgd_iot_discharge_working z = zhgd_Iot_discharge_Current as Zhgd_iot_discharge_working;
        //    return z;
        //}
        public static Zhgd_iot_discharge_working Get_Zhgd_iot_discharge_working(Zhgd_iot_discharge_current parent)
        {
            Zhgd_iot_discharge_working child = new Zhgd_iot_discharge_working();
            var ParentType = typeof(Zhgd_iot_discharge_current);
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
                }
            }
            return(child);
        }
        public async Task <IActionResult> Propertie_Add(Propertie propertie, IFormFile uploadedFile)
        {
            if (uploadedFile != null)
            {
                string path = "/files/" + uploadedFile.FileName;
                using (var fileStream = new FileStream(_appEnvironment.WebRootPath + path, FileMode.Create))
                {
                    await uploadedFile.CopyToAsync(fileStream);
                }
                propertie.Image = path;
            }
            db.Properties.Add(propertie);
            db.SaveChanges();

            return(RedirectToAction("Propertie_Index"));
        }
Beispiel #9
0
        public static T AutoCopy <T>(T source) where T : new()
        {
            T   target     = new T();
            var Properties = typeof(T).GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(target, Propertie.GetValue(source, null), null);
                }
            }
            return(target);
        }
Beispiel #10
0
        public static T1 PropertieCopy <T1>(this T1 t1, T1 t2)
        {
            var ParentType = typeof(T1);
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(t2, Propertie.GetValue(t1, null), null);
                }
            }
            return(t1);
        }
Beispiel #11
0
        /// <summary>
        /// 将系统时间转换成UTC时间
        /// </summary>
        /// <param name="device"></param>
        public static void ConventLocalToUTCTime <T>(T device)
        {
            var type       = device.GetType();
            var Properties = type.GetProperties();

            foreach (var Propertie in Properties)
            {
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    if (Propertie.PropertyType == typeof(DateTime?))
                    {
                        Propertie.SetValue(device, ((DateTime?)Propertie.GetValue(device, null))?.ToUniversalTime(), null);
                    }
                }
            }
        }
Beispiel #12
0
        public static TChild ToChild <TParent, TChild>(this TParent parent) where TChild : TParent, new()
        {
            TChild child      = new TChild();
            var    ParentType = typeof(TParent);
            var    Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
                }
            }
            return(child);
        }
Beispiel #13
0
        /// <summary>
        /// 复制对象副本
        /// </summary>
        /// <typeparam name="TObject"></typeparam>
        /// <param name="originalObj"></param>
        /// <returns></returns>
        public TObject AutoCopy <TObject>(TObject originalObj) where TObject : new()
        {
            TObject newObj       = new TObject();
            var     OriginalType = typeof(TObject);
            var     Properties   = OriginalType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(newObj, Propertie.GetValue(originalObj, null), null);
                }
            }
            return(newObj);
        }
Beispiel #14
0
        /// <summary>
        /// 自动将基类对象复制到扩展继承类中,左侧为父类(基类),右侧为子类(扩展类), 参数为父类(基类)对象,子类(扩展类)未赋值的属性默认为null
        /// </summary>
        /// <typeparam name="TParent">父类(基类)</typeparam>
        /// <typeparam name="TChild">扩展业务逻辑继承的子类</typeparam>
        /// <param name="parent">基类对象</param>
        /// <returns>返回扩展的子类</returns>
        public static TChild AutoCopyToChild <TParent, TChild>(TParent parent) where TChild : new()
        {
            TChild ext_model  = new TChild();
            var    ParentType = typeof(TParent);
            var    parentProp = ParentType.GetProperties();

            foreach (var Propertie in parentProp)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(ext_model, Propertie.GetValue(parent, null), null);
                }
            }
            return(ext_model);
        }
Beispiel #15
0
        /// <summary>
        /// 类型转换
        /// </summary>
        /// <typeparam name="TOrign"></typeparam>
        /// <typeparam name="TGoal"></typeparam>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static TGoal ConvertTo <TOrign, TGoal>(TOrign parent) where TGoal : TOrign, new()
        {
            var child      = new TGoal();
            var ParentType = typeof(TOrign);
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
                }
            }
            return(child);
        }
Beispiel #16
0
        /// <summary>
        /// 自动将子类对象复制到父类中,左侧为父类,右侧为子类, 参数为子类对象
        /// </summary>
        /// <typeparam name="TParent">父类</typeparam>
        /// <typeparam name="TChild">扩展业务逻辑继承的子类</typeparam>
        /// <param name="child">子类对象</param>
        /// <returns>返回基类对象</returns>
        public static TParent AutoCopyToBase <TParent, TChild>(TChild child) where TParent : new()
        {
            TParent base_model = new TParent();
            var     ParentType = typeof(TParent);
            var     Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(base_model, Propertie.GetValue(child, null), null);
                }
            }
            return(base_model);
        }
        public TChild EntityCopy <TParent, TChild>(TParent parent) where TChild : TParent, new()
        {
            // The following 1st line is not possible without new() constraint:
            TChild child      = new TChild();
            var    ParentType = typeof(TParent);
            var    Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
                }
            }
            return(child);
        }
Beispiel #18
0
        public async Task UpdateAsync(Propertie obj)
        {
            bool hasAny = await _context.Owner.AnyAsync(x => x.Id == obj.Id);

            if (!hasAny)
            {
                throw new NotFoundException("ID not found");
            }
            try
            {
                _context.Update(obj);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException e)
            {
                throw new DbConcurrencyException(e.Message);
            }
        }
        public ViewModelCourse AutoCopy(Course parent)
        {
            ViewModelCourse child = new ViewModelCourse();

            var ParentType = typeof(Course);

            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    Propertie.SetValue(child, Propertie.GetValue(parent, null), null);
                }
            }

            return(child);
        }
Beispiel #20
0
        public T Change <T>(SqlDataReader reader) where T : new()
        {
            var model = new T();

            try
            {
                var properties = typeof(T).GetProperties();
                foreach (var Propertie in properties)
                {
                    if (Propertie.CanRead && Propertie.CanWrite)
                    {
                        Propertie.SetValue(model, reader[Propertie.Name], null);
                    }
                }
                return(model);
            }
            catch (Exception ex)
            {
                return(model);
            }
        }
    public void StartSimulation()
    {
        LoaderInput.LoadArchive();

        totalRounds = 0;
        contTimeout = 0;

        for (int cont = 0; cont < propertiesArray.Length; cont++)
        {
            propertiesArray[cont] = new Propertie()
            {
                rentValue = LoaderInput.GetRentValue(cont),
                sellValue = LoaderInput.GetSellValue(cont)
            };
        }

        playerArray[0] = new PlayerCautious();
        playerArray[1] = new PlayerDemanding();
        playerArray[2] = new PlayerImpulsive();
        playerArray[3] = new PlayerRandom();

        for (int matchCont = 0; matchCont < 300; matchCont++)
        {
            ResetVariables();
            DefineStartOrder();
            RunSimulation();
        }

        for (int cont = 0; cont < playerArray.Length; cont++)
        {
            sliderList[cont].GetComponentInChildren <Slider>().value = playerArray[cont].GetWin();
            sliderList[cont].GetComponentInChildren <Text>().text    = playerArray[cont].GetType().ToString()
                                                                       + " win: " + playerArray[cont].GetWin()
                                                                       + " porcentagem %: " + (playerArray[cont].GetWin() * 100 / 300);
        }

        timeOutText.text     = "Timeout: " + contTimeout;
        mediaTurnosText.text = "Media de turnos: " + totalRounds / 300;
    }
Beispiel #22
0
        public async Task <JsonResult> Create([FromBody] Event2 event2)
        {
            AppIdentityUser _user = await _userManager.FindByNameAsync(User.Identity.Name);

            var ScalpId = Convert.ToInt64(_user.BranchId.ToString() + ConvertJson.DateTimeToStamp(DateTime.Now).ToString());

            event2.EnteringDate = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.FindSystemTimeZoneById("China Standard Time"));
            event2.ScalpId      = ScalpId;
            event2.id           = ScalpId.ToString();
            event2.resourceId   = event2.HouseNumber;
            event2.start        = event2.StartDate.ToShortDateString();
            event2.end          = event2.EndDate.ToShortDateString();
            var brhScalp   = new BrhScalp();
            var ParentType = typeof(BrhScalp);
            var Properties = ParentType.GetProperties();

            foreach (var Propertie in Properties)
            {
                //循环遍历属性
                if (Propertie.CanRead && Propertie.CanWrite)
                {
                    //进行属性拷贝
                    Propertie.SetValue(brhScalp, Propertie.GetValue(event2, null), null);
                }
            }
            _context.Add(brhScalp);
            await _context.SaveChangesAsync();

            var total             = _context.BrhScalp.Where(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId && !x.IsMove).Sum(x => x.TotalPrice);
            var brhImprestAccount = _context.BrhImprestAccounts.SingleOrDefault(x => x.ImprestAccountsId == brhScalp.ImprestAccountsId);

            brhImprestAccount.Equity = brhImprestAccount.Balance - total;
            _context.Update(brhImprestAccount);
            await _context.SaveChangesAsync();

            return(Json(event2));
        }
Beispiel #23
0
        public async Task <JsonResult> GetMonthData([FromBody] FncBranch fncBranch)
        {
            var frontList   = _context.BrhFrontDeskAccounts.Where(x => x.Branch == fncBranch.BranchName && x.State != StateType.已删除 && DateTime.Compare(x.StartDate.Date, DateTime.Now.Date) <= 0).ToList();
            var earningList = _context.BrhEarningRecord.Where(x => x.Branch == fncBranch.BranchName).ToList();
            var expendList  = _context.BrhExpendRecord.Where(x => x.Branch == fncBranch.BranchName).ToList();
            var stewardList = _context.BrhStewardAccounts.Where(x => x.Branch == fncBranch.BranchName).ToList();
            var start       = frontList.Select(x => x.StartDate).Min().Date;

            start = start.AddDays(1 - start.Day);
            var end = frontList.Select(x => x.EndDate).Max().Date;

            if (DateTime.Compare(end, DateTime.Now) < 0)
            {
                end = DateTime.Now.AddDays(1).Date;
            }
            end = end.AddDays(1 - end.Day);
            var ms = (end.Year * 12 + end.Month) - (start.Year * 12 + start.Month);

            if (ms == 0)
            {
                return(Json(new { }));
            }
            var monthDataList    = new List <MonthData>();
            var fncMonthDataList = _context.FncMonthData.Where(x => x.BranchId == fncBranch.BranchId).ToList();
            var monthData_Month  = fncMonthDataList.Select(x => x.Month.ToString("yyyy-MM")).ToList();

            for (var i = 0; i <= ms; i++)
            {
                var fncMonthData = new FncMonthData();
                var cFrontList   = frontList.Where(x => DateTime.Compare(start.AddMonths(i), x.StartDate) <= 0 && DateTime.Compare(x.StartDate, start.AddMonths(i + 1)) < 0).ToList();
                var cEarningList = earningList.Where(x => DateTime.Compare(start.AddMonths(i), x.EnteringDate) <= 0 && DateTime.Compare(x.EnteringDate, start.AddMonths(i + 1)) < 0).ToList();
                var cExpendList  = expendList.Where(x => DateTime.Compare(start.AddMonths(i), x.EnteringDate) <= 0 && DateTime.Compare(x.EnteringDate, start.AddMonths(i + 1)) < 0).ToList();
                var cStewardList = stewardList.Where(x => DateTime.Compare(start.AddMonths(i), x.EnteringDate) <= 0 && DateTime.Compare(x.EnteringDate, start.AddMonths(i + 1)) < 0).ToList();
                if (!monthData_Month.Contains(start.AddMonths(i).ToString("yyyy-MM")))
                {
                    fncMonthData.BranchId    = fncBranch.BranchId;
                    fncMonthData.Earning     = cEarningList.Select(x => x.Amount).Sum();
                    fncMonthData.Expend      = cExpendList.Select(x => x.Amount).Sum();
                    fncMonthData.HouseAmount = cFrontList.Select(x => x.TotalPrice).Sum();
                    fncMonthData.HouseCount  = cFrontList.Select(x => x.Count).Sum();
                    if (i != ms)
                    {
                        fncMonthData.HouseTotal = DateTime.DaysInMonth(start.AddMonths(i).Year, start.AddMonths(i).Month) * fncBranch.Count;
                    }
                    else
                    {
                        fncMonthData.HouseTotal = DateTime.Now.Day * fncBranch.Count;
                    }
                    if (fncMonthData.HouseTotal != 0)
                    {
                        fncMonthData.Rate         = (double)fncMonthData.HouseCount / (double)fncMonthData.HouseTotal;
                        fncMonthData.ValidAverage = fncMonthData.HouseAmount / fncMonthData.HouseTotal;
                    }
                    else
                    {
                        fncMonthData.Rate         = 0;
                        fncMonthData.ValidAverage = 0;
                    }
                    if (fncMonthData.HouseCount != 0)
                    {
                        fncMonthData.Average = fncMonthData.HouseAmount / fncMonthData.HouseCount;
                    }
                    else
                    {
                        fncMonthData.Average = 0;
                    }
                    fncMonthData.Month      = start.AddMonths(i);
                    fncMonthData.SaleAmount = cStewardList.Select(x => x.Amount).Sum();
                    fncMonthData.SaleProfit = cStewardList.Select(x => x.Profit).Sum();
                    _context.Add(fncMonthData);
                    fncMonthDataList.Add(fncMonthData);
                }
                else if (i == ms - 1)
                {
                    var tempMonthData = fncMonthDataList.SingleOrDefault(x => DateTime.Compare(x.Month, start.AddMonths(i)) == 0);
                    tempMonthData.BranchId    = fncBranch.BranchId;
                    tempMonthData.Earning     = cEarningList.Select(x => x.Amount).Sum();
                    tempMonthData.Expend      = cExpendList.Select(x => x.Amount).Sum();
                    tempMonthData.HouseAmount = cFrontList.Select(x => x.TotalPrice).Sum();
                    tempMonthData.HouseCount  = cFrontList.Select(x => x.Count).Sum();
                    tempMonthData.HouseTotal  = DateTime.DaysInMonth(start.AddMonths(i).Year, start.AddMonths(i).Month) * fncBranch.Count;
                    if (tempMonthData.HouseTotal != 0)
                    {
                        tempMonthData.Rate         = (double)tempMonthData.HouseCount / (double)tempMonthData.HouseTotal;
                        tempMonthData.ValidAverage = tempMonthData.HouseAmount / tempMonthData.HouseTotal;
                    }
                    else
                    {
                        tempMonthData.Rate         = 0;
                        tempMonthData.ValidAverage = 0;
                    }
                    if (tempMonthData.HouseCount != 0)
                    {
                        tempMonthData.Average = tempMonthData.HouseAmount / tempMonthData.HouseCount;
                    }
                    else
                    {
                        tempMonthData.Average = 0;
                    }
                    tempMonthData.Month      = start.AddMonths(i);
                    tempMonthData.SaleAmount = cStewardList.Select(x => x.Amount).Sum();
                    tempMonthData.SaleProfit = cStewardList.Select(x => x.Profit).Sum();
                    _context.Update(tempMonthData);
                }
                else if (i == ms)
                {
                    var tempMonthData = fncMonthDataList.SingleOrDefault(x => DateTime.Compare(x.Month, start.AddMonths(i)) == 0);
                    tempMonthData.BranchId    = fncBranch.BranchId;
                    tempMonthData.Earning     = cEarningList.Select(x => x.Amount).Sum();
                    tempMonthData.Expend      = cExpendList.Select(x => x.Amount).Sum();
                    tempMonthData.HouseAmount = cFrontList.Select(x => x.TotalPrice).Sum();
                    tempMonthData.HouseCount  = cFrontList.Select(x => x.Count).Sum();
                    tempMonthData.HouseTotal  = DateTime.Now.Day * fncBranch.Count;
                    if (tempMonthData.HouseTotal != 0)
                    {
                        tempMonthData.Rate         = (double)tempMonthData.HouseCount / (double)tempMonthData.HouseTotal;
                        tempMonthData.ValidAverage = tempMonthData.HouseAmount / tempMonthData.HouseTotal;
                    }
                    else
                    {
                        tempMonthData.Rate         = 0;
                        tempMonthData.ValidAverage = 0;
                    }
                    if (tempMonthData.HouseCount != 0)
                    {
                        tempMonthData.Average = tempMonthData.HouseAmount / tempMonthData.HouseCount;
                    }
                    else
                    {
                        tempMonthData.Average = 0;
                    }
                    tempMonthData.Month      = start.AddMonths(i);
                    tempMonthData.SaleAmount = cStewardList.Select(x => x.Amount).Sum();
                    tempMonthData.SaleProfit = cStewardList.Select(x => x.Profit).Sum();
                    _context.Update(tempMonthData);
                }
                await _context.SaveChangesAsync();
            }

            foreach (var fncMonthData1 in fncMonthDataList)
            {
                var monthData1 = new MonthData();
                var ParentType = typeof(FncMonthData);
                var Properties = ParentType.GetProperties();
                foreach (var Propertie in Properties)
                {
                    if (Propertie.CanRead && Propertie.CanWrite)
                    {
                        Propertie.SetValue(monthData1, Propertie.GetValue(fncMonthData1, null), null);
                    }
                }
                var fncMonthData2 = fncMonthDataList.SingleOrDefault(x => x.Month.ToString("yyyy-MM") == fncMonthData1.Month.AddMonths(-1).ToString("yyyy-MM"));
                if (fncMonthData2 != null)
                {
                    monthData1.环比增长额   = fncMonthData1.HouseAmount - fncMonthData2.HouseAmount;
                    monthData1.环比增长率   = (double)monthData1.环比增长额 / (double)fncMonthData2.HouseAmount;
                    monthData1.出环比增长额  = (decimal)(fncMonthData1.Rate - fncMonthData2.Rate);
                    monthData1.出环比增长率  = (double)monthData1.出环比增长额 / fncMonthData2.Rate;
                    monthData1.均环比增长额  = fncMonthData1.Average - fncMonthData2.Average;
                    monthData1.均环比增长率  = (double)monthData1.均环比增长额 / (double)fncMonthData2.Average;
                    monthData1.环比增长额   = fncMonthData1.ValidAverage - fncMonthData2.ValidAverage;
                    monthData1.环比增长率   = (double)monthData1.环比增长额 / (double)fncMonthData2.ValidAverage;
                    monthData1.支环比增长额  = fncMonthData1.Expend - fncMonthData2.Expend;
                    monthData1.支环比增长率  = (double)monthData1.支环比增长额 / (double)fncMonthData2.Expend;
                    monthData1.外环比增长额  = fncMonthData1.SaleAmount - fncMonthData2.SaleAmount;
                    monthData1.外环比增长率  = (double)monthData1.外环比增长额 / (double)fncMonthData2.SaleAmount;
                    monthData1.外利环比增长额 = fncMonthData1.SaleProfit - fncMonthData2.SaleProfit;
                    monthData1.外利环比增长率 = (double)monthData1.外利环比增长额 / (double)fncMonthData2.SaleProfit;
                }
                else
                {
                    monthData1.环比增长额   = 0;
                    monthData1.环比增长率   = 0;
                    monthData1.出环比增长额  = 0;
                    monthData1.出环比增长率  = 0;
                    monthData1.均环比增长额  = 0;
                    monthData1.均环比增长率  = 0;
                    monthData1.环比增长额   = 0;
                    monthData1.环比增长率   = 0;
                    monthData1.支环比增长额  = 0;
                    monthData1.支环比增长率  = 0;
                    monthData1.外环比增长额  = 0;
                    monthData1.外环比增长率  = 0;
                    monthData1.外利环比增长额 = 0;
                    monthData1.外利环比增长率 = 0;
                }
                var fncMonthData3 = fncMonthDataList.SingleOrDefault(x => x.Month.ToString("yyyy-MM") == fncMonthData1.Month.AddYears(-1).ToString("yyyy-MM"));
                if (fncMonthData3 != null)
                {
                    monthData1.比增长额    = fncMonthData1.HouseAmount - fncMonthData3.HouseAmount;
                    monthData1.比增长率    = (double)monthData1.比增长额 / (double)fncMonthData3.HouseAmount;
                    monthData1.出同比增长额  = (decimal)(fncMonthData1.Rate - fncMonthData3.Rate);
                    monthData1.出同比增长率  = (double)monthData1.出同比增长额 / fncMonthData3.Rate;
                    monthData1.均同比增长额  = fncMonthData1.Average - fncMonthData3.Average;
                    monthData1.均同比增长率  = (double)monthData1.均同比增长额 / (double)fncMonthData3.Average;
                    monthData1.比增长额    = fncMonthData1.ValidAverage - fncMonthData3.ValidAverage;
                    monthData1.比增长率    = (double)monthData1.比增长额 / (double)fncMonthData3.ValidAverage;
                    monthData1.支同比增长额  = fncMonthData1.Expend - fncMonthData3.Expend;
                    monthData1.支同比增长率  = (double)monthData1.支同比增长额 / (double)fncMonthData3.Expend;
                    monthData1.外同比增长额  = fncMonthData1.SaleAmount - fncMonthData3.SaleAmount;
                    monthData1.外同比增长率  = (double)monthData1.外同比增长额 / (double)fncMonthData3.SaleAmount;
                    monthData1.外利同比增长额 = fncMonthData1.SaleProfit - fncMonthData3.SaleProfit;
                    monthData1.外利同比增长率 = (double)monthData1.外利同比增长额 / (double)fncMonthData3.SaleProfit;
                }
                else
                {
                    monthData1.比增长额    = 0;
                    monthData1.比增长率    = 0;
                    monthData1.出同比增长额  = 0;
                    monthData1.出同比增长率  = 0;
                    monthData1.均同比增长额  = 0;
                    monthData1.均同比增长率  = 0;
                    monthData1.比增长额    = 0;
                    monthData1.比增长率    = 0;
                    monthData1.支同比增长额  = 0;
                    monthData1.支同比增长率  = 0;
                    monthData1.外同比增长额  = 0;
                    monthData1.外同比增长率  = 0;
                    monthData1.外利同比增长额 = 0;
                    monthData1.外利同比增长率 = 0;
                }
                monthDataList.Add(monthData1);
            }
            monthDataList = monthDataList.OrderBy(x => x.Month).ToList();

            var front2List = _context.BrhFrontDeskAccounts.Where(x => x.Branch == fncBranch.BranchName && x.State != StateType.已删除 && x.StartDate.Month != x.EndDate.AddDays(-1).Month).ToList();

            return(Json(new { monthDataList, monthData_Month, front2List }));
        }
Beispiel #24
0
        public async Task Create([FromBody] Propertie propertie, [FromServices] ApplicationContext context)
        {
            context.Set <Propertie>().Add(propertie);

            await context.SaveChangesAsync();
        }
 public IActionResult Propertie_Edit(Propertie propertie)
 {
     db.Entry(propertie).State = EntityState.Modified;
     db.SaveChanges();
     return(RedirectToAction("Propertie_Index"));
 }
        public IActionResult Propertie_Edit(int id)
        {
            Propertie propertie = db.Properties.Find(id);

            return(View(propertie));
        }
Beispiel #27
0
 public async Task InsertAsync(Propertie obj)
 {
     _context.Add(obj);
     await _context.SaveChangesAsync();
 }
Beispiel #28
0
        public async Task <IActionResult> Get()
        {
            try
            {
                var Imoveis = await _repo.GetAllImoveisAtivosAsync(true);

                var Vendedores = await _repo.GetAllVendedoresAsync();

                var listaLocations  = new List <Locations>();
                var listaProperties = new List <Propertie>();
                foreach (var imovel in Imoveis)
                {
                    var lat = "";
                    var lng = "";
                    if (imovel.oEndereco != null)
                    {
                        lat = imovel.oEndereco.Latitude;
                    }
                    else
                    {
                        lat = imovel.oEdificio.oEndereco.Latitude;
                    }
                    if (imovel.oEndereco != null)
                    {
                        lng = imovel.oEndereco.Longitude;
                    }
                    else
                    {
                        lng = imovel.oEdificio.oEndereco.Longitude;
                    }

                    listaLocations.Add(new Locations
                    {
                        propertyId = imovel.Id,
                        id         = imovel.Id,
                        lat        = lat,
                        lng        = lng
                    });

                    var oEndereco = new Endereco();
                    if (imovel.EdificioId > 0)
                    {
                        if (imovel.oEdificio.oEndereco != null)
                        {
                            oEndereco = new Endereco
                            {
                                Bairro      = imovel.oEdificio.oEndereco.Bairro,
                                CEP         = imovel.oEdificio.oEndereco.CEP,
                                Cidade      = imovel.oEdificio.oEndereco.Cidade,
                                Complemento = imovel.oEdificio.oEndereco.Complemento + " " + imovel.Complemento,
                                Logradouro  = imovel.oEdificio.oEndereco.Logradouro,
                                Numero      = imovel.oEdificio.oEndereco.Numero,
                                UF          = imovel.oEdificio.oEndereco.UF
                            };
                        }
                    }
                    else
                    {
                        oEndereco = new Endereco
                        {
                            Bairro      = imovel.oEndereco.Bairro,
                            CEP         = imovel.oEndereco.CEP,
                            Cidade      = imovel.oEndereco.Cidade,
                            Complemento = imovel.oEndereco.Complemento + " " + imovel.Complemento,
                            Logradouro  = imovel.oEndereco.Logradouro,
                            Numero      = imovel.oEndereco.Numero,
                            UF          = imovel.oEndereco.UF
                        };
                    }

                    var listGalery   = new List <Gallery>();
                    var listPlans    = new List <Plan>();
                    var fotosImoveis = await _repo.GetFotosImovelByIdAsync(imovel.Id);

                    if (fotosImoveis.Count() > 0)
                    {
                        foreach (var foto in fotosImoveis)
                        {
                            listGalery.Add(new Gallery
                            {
                                small  = foto.Caminho,
                                medium = foto.Caminho,
                                big    = foto.Caminho
                            });
                        }
                    }
                    var fotosAreaImoveis = await _repo.GetFotosAreaImovelByIdAsync(imovel.Id);

                    if (fotosAreaImoveis.Count() > 0)
                    {
                        foreach (var foto in fotosAreaImoveis)
                        {
                            listGalery.Add(new Gallery
                            {
                                small  = foto.Caminho,
                                medium = foto.Caminho,
                                big    = foto.Caminho
                            });
                        }
                    }

                    var fotosPlantaImoveis = await _repo.GetFotosPlantaImovelByIdAsync(imovel.Id);

                    if (fotosPlantaImoveis.Count() > 0)
                    {
                        foreach (var foto in fotosPlantaImoveis)
                        {
                            listPlans.Add(new Plan
                            {
                                image = foto.Caminho,
                            });
                        }
                    }

                    if (imovel.EdificioId != null && imovel.EdificioId > 0)
                    {
                        var fotosEdificio = await _repo.GetFotosEdificioByIdAsync(imovel.Id);

                        if (fotosEdificio.Count() > 0)
                        {
                            foreach (var foto in fotosImoveis)
                            {
                                listGalery.Add(new Gallery
                                {
                                    small  = foto.Caminho,
                                    medium = foto.Caminho,
                                    big    = foto.Caminho
                                });
                            }
                        }
                        var fotosAreaEdificio = await _repo.GetFotosAreaEdificioByIdAsync(imovel.Id);

                        if (fotosAreaImoveis.Count() > 0)
                        {
                            foreach (var foto in fotosAreaImoveis)
                            {
                                listGalery.Add(new Gallery
                                {
                                    small  = foto.Caminho,
                                    medium = foto.Caminho,
                                    big    = foto.Caminho
                                });
                            }
                        }

                        var fotosPlantaEdificio = await _repo.GetFotosPlantaEdificioByIdAsync(imovel.Id);

                        if (fotosPlantaEdificio.Count() > 0)
                        {
                            foreach (var foto in fotosPlantaEdificio)
                            {
                                listPlans.Add(new Plan
                                {
                                    image = foto.Caminho,
                                });
                            }
                        }
                    }
                    var videos = await _repo.GetAllVideosByImovelIdAsync(imovel.Id);

                    var listaVideos = new List <Video>();

                    if (videos.Count() > 0)
                    {
                        foreach (var video in videos)
                        {
                            listaVideos.Add(new Video
                            {
                                link = video.Link,
                                name = video.Nome
                            });
                        }
                    }
                    var listaBairro   = new List <string>();
                    var listaRua      = new List <string>();
                    var listaStatus   = new List <string>();
                    var listaFeatures = RetonaListaFeatures(imovel);

                    if (imovel.PrecoVenda > 0)
                    {
                        listaStatus.Add("À Venda");
                    }
                    else
                    {
                        listaStatus.Add("Para Alugar");
                    }
                    listaBairro.Add(oEndereco.Bairro);
                    listaRua.Add(oEndereco.Logradouro);

                    var oPropertie = new Propertie
                    {
                        area = new Area
                        {
                            unit  = "m2",
                            value = imovel.AreaUtil
                        },
                        bathrooms   = imovel.QtdBanheiros,
                        bedrooms    = imovel.QtdDormitorios,
                        city        = oEndereco.Cidade,
                        gallery     = listGalery,
                        videos      = listaVideos,
                        garages     = imovel.QtdVagas,
                        id          = imovel.Id,
                        desc        = imovel.Descricao,
                        reference   = imovel.Referencia,
                        priceDollar = new PriceDollar
                        {
                            rent = imovel.PrecoLocacao,
                            sale = imovel.PrecoVenda
                        },
                        priceEuro = new PriceEuro
                        {
                            rent = imovel.PrecoLocacao,
                            sale = imovel.PrecoVenda
                        },
                        neighborhood = listaBairro,
                        location     = new Location
                        {
                            lat = lat,
                            lng = lng
                        },
                        title              = imovel.Nome,
                        street             = listaRua,
                        yearBuilt          = imovel.AnoConstrucao,
                        lastUpdate         = imovel.DataAlteracao.ToString(),
                        published          = imovel.DataAlteracao.ToString(),
                        zipCode            = oEndereco.CEP,
                        ratingsValue       = 5,
                        ratingsCount       = 100,
                        views              = 1000,
                        propertyType       = imovel.Tipo,
                        formattedAddress   = oEndereco.Logradouro + " " + oEndereco.Numero + " " + oEndereco.Complemento,
                        additionalFeatures = new List <AdditionalFeature>(),
                        featured           = false,
                        propertyStatus     = listaStatus,
                        features           = listaFeatures,
                        plans              = listPlans
                    };

                    listaProperties.Add(oPropertie);
                }
                var retorno = new HomeReturn
                {
                    agents     = Vendedores.ToList(),
                    locations  = listaLocations,
                    properties = listaProperties
                };
                return(Ok(retorno));
            }
            catch (System.Exception ex)
            {
                return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Ocorreu um erro no banco de Dados.{ex.Message}"));
            }
        }
        public IActionResult Propertie_Delete(int id)
        {
            Propertie b = db.Properties.Find(id);

            return(View(b));
        }
Beispiel #30
0
        /// <summary>
        /// 1.获取交叉数据绑定后台视图模型
        /// -- 基本数据从Ticket表中获取
        /// -- 再依据外键进行相应数据列匹配和选取(根据FORM请求进行数据筛选后再绑定)
        /// -- 取出所有数据后绑定报表文件展示
        /// </summary>
        /// <returns></returns>
        public IActionResult CrossReport()
        {
            TDContext context = new TDContext();

            List <Ticket> tickets = new List <Ticket>();

            if (searchCondition.DateFrom != null && searchCondition.DateFrom.ToString() != "" && searchCondition.DateTo.ToString() != "" && searchCondition.DateTo != null)
            {
                tickets = context.Ticket.Where(t => t.TicketDate <searchCondition.DateTo && t.TicketDate> searchCondition.DateFrom).ToList();
            }
            else
            {
                tickets = context.Ticket.FromSql("select * from Ticket").ToList();
            }

            List <TicketView> tList = new List <TicketView>();

            foreach (Ticket tic in tickets)
            {
                TicketView tView = new TicketView();
                # region 产品过滤
                Product product = new Product();
                if (searchCondition.Product != null && searchCondition.Product != "")
                {
                    product = context.Product.Where(p => p.ProductID == tic.ProductID && p.ProductName == searchCondition.Product).FirstOrDefault();
                    if (product == null)
                    {
                        continue;                  //问题 - 没有要不要显示?
                    }
                }
                else
                {
                    product = context.Product.Where(p => p.ProductID == tic.ProductID).FirstOrDefault();
                }
                tView.Product = product;
                #endregion

                #region 区域过滤 办事处过滤
                Corp issuer = context.Corp.Where(c => c.CorpID == tic.IssuerID).FirstOrDefault();
                if (issuer.CorpLevel != "办事处")
                {
                    //父企业
                    Corp parentCorp = context.Corp.Where(c => c.CorpID == issuer.ParentCorpID).FirstOrDefault();
                    if (searchCondition.Office != null && searchCondition.Office != "" && searchCondition.Office != parentCorp.CorpName)
                    {
                        continue;
                    }
                    //区域信息
                    Area areaInfo = context.Area.Where(a => a.AreaId == parentCorp.AreaID).FirstOrDefault();
                    if (searchCondition.Area != null && searchCondition.Area != "" && searchCondition.Area != areaInfo.AreaName)
                    {
                        continue;
                    }
                    //组合信息
                    IssuerArea i = new IssuerArea();
                    i.IssuerID         = issuer.CorpID;
                    i.IssuerParentArea = areaInfo.AreaName;
                    i.IssuerParentName = parentCorp.CorpName;
                    tView.IssuerArea   = i;
                }
                else
                {
                    //无父企业直接获得
                    IssuerArea i = new IssuerArea();
                    i.IssuerID         = issuer.CorpID;
                    i.IssuerParentArea = issuer.AreaName;
                    if (searchCondition.Area != null && searchCondition.Area != "" && searchCondition.Area != issuer.AreaName)
                    {
                        continue;
                    }
                    i.IssuerParentName = issuer.CorpName;
                    if (searchCondition.Office != null && searchCondition.Office != "" && searchCondition.Office != issuer.CorpName)
                    {
                        continue;
                    }
                    tView.IssuerArea = i;
                }
                #endregion

                #region 补全
                var ParentType = typeof(Ticket);
                var Properties = ParentType.GetProperties();
                foreach (var Propertie in Properties)
                {
                    //循环遍历属性
                    if (Propertie.CanRead && Propertie.CanWrite)
                    {
                        //进行属性拷贝
                        Propertie.SetValue(tView, Propertie.GetValue(tic, null), null);
                    }
                }
                #endregion

                tList.Add(tView);
            }