当前位置: 首页>>代码示例>>C#>>正文


C# List.Sum方法代码示例

本文整理汇总了C#中Data.List.Sum方法的典型用法代码示例。如果您正苦于以下问题:C# List.Sum方法的具体用法?C# List.Sum怎么用?C# List.Sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Data.List的用法示例。


在下文中一共展示了List.Sum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ThemMoi

        private int ThemMoi(BOXuLyKho item, List<BOXuLyKhoChiTiet> lsArray, Transit mTransit)
        {
            if (lsArray != null)
            {
                List<Data.TONKHOTONG> lsTonKhoTong = new List<TONKHOTONG>();
                List<Data.TONKHO> lsTonKho = new List<TONKHO>();
                foreach (BOXuLyKhoChiTiet line in lsArray)
                {
                    IQueryable<Data.TONKHO> lsArrayLine = null;
                    switch (item.XuLyKho.LoaiID)
                    {
                        case 1:
                            lsArrayLine = frmTonKho.Query().Where(s => s.DonViID == line.TonKho.DonViID && s.MonID == line.TonKho.MonID && s.KhoID == item.XuLyKho.KhoID && s.SoLuongTon > 0).OrderBy(s => s.NgayHetHan).ThenBy(s => s.TonKhoID);
                            if (lsArrayLine.Count() > 0 && line.TonKho.SoLuongNhap < lsArrayLine.Sum(s => s.SoLuongTon) && line.TonKho.SoLuongNhap > 0)
                            {
                                foreach (var l in lsArrayLine)
                                {
                                    if (line.TonKho.SoLuongNhap > 0)
                                    {
                                        Data.TONKHOTONG tonkhotong = null;
                                        if (lsTonKhoTong.Exists(s => s.KhoID == item.XuLyKho.KhoID && s.MonID == line.TonKho.MonID && s.DonViID == line.TonKho.DonViID))
                                        {
                                            tonkhotong = lsTonKhoTong.Find(s => s.KhoID == item.XuLyKho.KhoID && s.MonID == line.TonKho.MonID && s.DonViID == line.TonKho.DonViID);
                                        }
                                        else
                                        {
                                            tonkhotong = KiemTraTonKhoTong(frmTonKhoTong, (int)item.XuLyKho.KhoID, (int)line.TonKho.MonID, (int)line.TonKho.DonViID);
                                            lsTonKhoTong.Add(tonkhotong);
                                        }
                                        tonkhotong.SoLuongTon += line.TonKho.SoLuongNhap;
                                        tonkhotong.SoLuongDieuChinh += line.TonKho.SoLuongNhap;
                                        Data.TONKHO tonkho = null;
                                        if (lsTonKho.Exists(s => s.TonKhoID == l.TonKhoID))
                                        {
                                            tonkho = lsTonKho.Find(s => s.TonKhoID == l.TonKhoID);
                                        }
                                        else
                                        {
                                            tonkho = l;
                                            lsTonKho.Add(tonkho);
                                        }
                                        line.XuLyKhoChiTiet.TONKHO = new TONKHO();
                                        line.XuLyKhoChiTiet.TONKHO.PhatSinhTuTonKhoID = tonkho.TonKhoID;
                                        line.XuLyKhoChiTiet.TONKHO.LoaiPhatSinhID = (int)item.XuLyKho.LoaiID;
                                        CopyTonKho(line.XuLyKhoChiTiet.TONKHO, tonkho);

                                        if (tonkho.SoLuongTon > line.TonKho.SoLuongNhap)
                                        {
                                            line.XuLyKhoChiTiet.TONKHO.SoLuongPhatSinh = tonkho.SoLuongTon - line.TonKho.SoLuongNhap;
                                            tonkho.SoLuongTon += line.TonKho.SoLuongNhap;
                                            line.TonKho.SoLuongNhap = 0;
                                        }
                                        else
                                        {
                                            line.XuLyKhoChiTiet.TONKHO.SoLuongPhatSinh = line.TonKho.SoLuongNhap - tonkho.SoLuongTon;
                                            line.TonKho.SoLuongNhap += tonkho.SoLuongTon;
                                            tonkho.SoLuongTon = 0;
                                        }
                                    }
                                }
                            }
                            break;
                        case 2:
                        case 3:
                            lsArrayLine = frmTonKho.Query().Where(s => s.DonViID == line.TonKho.DonViID && s.MonID == line.TonKho.MonID && s.KhoID == item.XuLyKho.KhoID && s.SoLuongTon > 0).OrderBy(s => s.NgayHetHan).ThenBy(s => s.TonKhoID);
                            if (lsArrayLine.Count() > 0 && line.TonKho.SoLuongNhap < lsArrayLine.Sum(s => s.SoLuongTon) && line.TonKho.SoLuongNhap > 0)
                            {
                                foreach (var l in lsArrayLine)
                                {
                                    if (line.TonKho.SoLuongNhap > 0)
                                    {
                                        Data.TONKHOTONG tonkhotong = null;
                                        if (lsTonKhoTong.Exists(s => s.KhoID == item.XuLyKho.KhoID && s.MonID == line.TonKho.MonID && s.DonViID == line.TonKho.DonViID))
                                        {
                                            tonkhotong = lsTonKhoTong.Find(s => s.KhoID == item.XuLyKho.KhoID && s.MonID == line.TonKho.MonID && s.DonViID == line.TonKho.DonViID);
                                        }
                                        else
                                        {
                                            tonkhotong = KiemTraTonKhoTong(frmTonKhoTong, (int)item.XuLyKho.KhoID, (int)line.TonKho.MonID, (int)line.TonKho.DonViID);
                                            lsTonKhoTong.Add(tonkhotong);
                                        }
                                        tonkhotong.SoLuongTon -= line.TonKho.SoLuongNhap;
                                        if (item.XuLyKho.LoaiID == 2)
                                        {
                                            tonkhotong.SoLuongMat += line.TonKho.SoLuongNhap;
                                        }
                                        if (item.XuLyKho.LoaiID == 3)
                                        {
                                            tonkhotong.SoLuongHu += line.TonKho.SoLuongNhap;
                                        }

                                        Data.TONKHO tonkho = null;
                                        if (lsTonKho.Exists(s => s.TonKhoID == l.TonKhoID))
                                        {
                                            tonkho = lsTonKho.Find(s => s.TonKhoID == l.TonKhoID);
                                        }
                                        else
                                        {
                                            tonkho = l;
                                            lsTonKho.Add(tonkho);
//.........这里部分代码省略.........
开发者ID:MisterTobi,项目名称:restaurant-cafe,代码行数:101,代码来源:BOXuLyKho.cs

示例2: getResumenFinal

        public static ResumenFinal getResumenFinal(edificio e, DateTime fechaDesde, DateTime fechaHasta)
        {
            try
            {
                admEntities db = Datos.getDB();
                ResumenFinal resumenFinal = new ResumenFinal();
                fechaHasta = DateTime.Parse(fechaHasta.AddMonths(1).AddDays(-fechaHasta.Day).Day + "/" + fechaHasta.Month + "/" + fechaHasta.Year);

                var sectoresDB = db.sector.ToList();

                var facturas = db.factura.Where(x => x.dir_edificio == e.direccion && x.fecha >= fechaDesde && x.fecha <= fechaHasta).ToList();

                //var facturasAgrupadas = facturas.GroupBy(x => x.fecha.ToString("MM yyyy")).Select(x=> new { Importe = x.Sum(y=> y.importe) });

                DateTime tmpFecha = fechaDesde;
                List<Periodo> periodos = new List<Periodo>();
                bool seguir = true;

                do
                {
                    List<Sector> sectores = new List<Sector>();
                    var Conceptos = db.Database.SqlQuery<Conceptos>(@"select  s.descripcion 'Sector', f.numero_factura 'NumeroFactura', p.razon_social 'Proveedor', concat(tg.descripcion, ' ', f.detalle) 'concepto', f.importe from factura f                                                     left join provedor p                            on p.razon_social = f.razon_provedor   join sector s on id_sector = s.idsector      join tipo_gasto tg  on f.id_tipogasto = tg.idtipo_gasto                    where dir_edificio = '" + e.direccion + "' and month(f.fecha) = " + tmpFecha.Month + " and year(f.fecha) = " + tmpFecha.Year).ToList();
                    foreach(var c in Conceptos.OrderBy(x=> x.Sector))
                    {
                        var s = sectores.Where(x => x.Nombre == c.Sector).SingleOrDefault();
                        if (s == null)
                        {
                            Sector sect = new Sector();
                            sect.Nombre = c.Sector;
                            sect.Importe += c.Importe;
                            sectores.Add(sect);
                        }
                        else
                            s.Importe += c.Importe;
                    }

                    sectores = OrdenarSectores(sectores,sectoresDB);

                    Periodo p = new Periodo();
                    p.Sectores = sectores;
                    p.Total = sectores.Sum(x => x.Importe);
                    p.Nombre = tmpFecha.Month + "/" + tmpFecha.Year;

                    if (sectores.Count > 0)
                        periodos.Add(p);

                    if (tmpFecha <= fechaHasta)
                        seguir = true;
                    else
                        seguir = false;

                    tmpFecha = tmpFecha.AddMonths(1);
                }
                while (seguir);

                resumenFinal.Periodos = periodos;

                var deudaDelEdificio = CatalogoDeudores.getDeudoresFromEdificioRegenerarUnidad(e, fechaHasta).Sum(x=> x.Importe);
                var totalExpensas = periodos.Sum(x => x.Total);

                var entradasDeCaja = getMovimientosCaja(e, fechaDesde, fechaHasta).Sum(x => x.importe > 0 ? (Double)x.importe : 0);

                var salidasDeCaja = getMovimientosCaja(e, fechaDesde, fechaHasta).Sum(x => x.importe < 0 ? (Double)x.importe : 0);

                if (salidasDeCaja < 0)
                    salidasDeCaja *= -1;

                resumenFinal.CobroDeExpensas = totalExpensas - deudaDelEdificio;
                resumenFinal.CobroFondosEspeciales = entradasDeCaja;
                resumenFinal.TotalIngresos = totalExpensas - deudaDelEdificio + entradasDeCaja;

                resumenFinal.GastosComunes = totalExpensas;
                resumenFinal.GastosEspeciales = salidasDeCaja;
                resumenFinal.TotalEgresos = totalExpensas + salidasDeCaja;

                resumenFinal.SaldoEnCaja = resumenFinal.TotalIngresos - resumenFinal.TotalEgresos;

                return resumenFinal;

            }
            catch (Exception ex)
            {
                Logger.Log.write(ex.InnerException == null ? ex.Message : ex.InnerException.Message);
                throw ex;
            }
        }
开发者ID:fedec93,项目名称:Administracion,代码行数:86,代码来源:CatalogoResumenAnual.cs

示例3: DamageReceived

        public long DamageReceived(Entity target, Entity source, bool timed)
        {
            var sourceString = source?.Id.ToString() ?? "";
            var key = "damage_received/" + target + "/" + sourceString + "/" + timed;
            if (_caching.ContainsKey(key)) return (long) _caching[key];
            IEnumerable<long> result = new List<long>();

            if (TargetSourceSkill.ContainsKey(target))
            {
                if (!timed && source != null)
                 {
                    if (TargetSourceSkill[target].ContainsKey(source))
                    {
                        result = from skills in TargetSourceSkill[target][source]
                            where skills.Type == Database.Type.Damage
                            select skills.Amount;
                    }
                }
                else
                {
                    result = from skills in TargetSourceSkill[target].Values
                        from skill in skills
                        where skill.Type == Database.Type.Damage
                        select skill.Amount;
                }

            }

            var sum = result.Sum();
            _caching.Add(key, sum);
            return sum;
        }
开发者ID:neowutran,项目名称:ShinraMeter,代码行数:32,代码来源:Skills.cs


注:本文中的Data.List.Sum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。