/// <summary> /// Agregar la pestaña de tipo de aganado como catalogo y ayuda en el excel /// </summary> /// <param name="pck"></param> private void AgregarPestañaTipoGanado(ExcelPackage pck) { try { // get the handle to the existing worksheet var wsData = pck.Workbook.Worksheets.Add(ResourceServices.ConfigurarFormula_PestañaTipoGanado); wsData.Cells["A1"].Value = ResourceServices.ConfigurarFormula_PestañaTipoGanado; using (ExcelRange r = wsData.Cells["A1:B1"]) { r.Merge = true; r.Style.Font.SetFromFont(new Font("Arial Bold", 16, FontStyle.Regular)); r.Style.Font.Color.SetColor(Color.White); r.Style.HorizontalAlignment = ExcelHorizontalAlignment.CenterContinuous; r.Style.Fill.PatternType = ExcelFillStyle.Solid; r.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 178, 34, 34)); //FromArgb(100, 0, 150) } IList <TipoGanadoInfo> tipoGanadoList = new List <TipoGanadoInfo>(); TipoGanadoBL tipoGanadoBL = new TipoGanadoBL(); tipoGanadoList = tipoGanadoBL.ObtenerTodos(); //var i = 0; var dataRange = wsData.Cells["A2"].LoadFromCollection( from s in tipoGanadoList orderby s.TipoGanadoID select new { //Identificador = i++, Identificador = s.TipoGanadoID, Descripcion = s.Descripcion }, true, TableStyles.None); using (ExcelRange r = wsData.Cells["A2:B2"]) { r.Style.VerticalAlignment = ExcelVerticalAlignment.Center; r.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center; r.Style.Font.SetFromFont(new Font("Arial Bold", 11, FontStyle.Regular)); r.Style.Font.Color.SetColor(Color.White); r.Style.Fill.PatternType = ExcelFillStyle.Solid; r.Style.Fill.BackgroundColor.SetColor(Color.FromArgb(255, 178, 34, 34)); } dataRange.AutoFitColumns(); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene una Interface de Salida por SalidaID y OrganizacionID /// </summary> /// <param name="entradaGanado"></param> /// <returns></returns> internal EntradaGanadoCosteoInfo ObtenerPorSalidaOrganizacion(EntradaGanadoInfo entradaGanado) { var entradaGanadoCosteo = new EntradaGanadoCosteoInfo(); try { Logger.Info(); var interfaceSalidaDAL = new InterfaceSalidaDAL(); var interfacesSalidaInfo = interfaceSalidaDAL.ObtenerPorSalidaOrganizacion(entradaGanado); entradaGanadoCosteo.ListaEntradaDetalle = new List <EntradaDetalleInfo>(); entradaGanadoCosteo.ListaCostoEntrada = new List <EntradaGanadoCostoInfo>(); var diasEstancia = new List <double>(); var listaEntradaGanadoCostoAuxiliar = new List <EntradaGanadoCostoInfo>(); var tipoGanadoBL = new TipoGanadoBL(); List <TipoGanadoInfo> tiposGanado = tipoGanadoBL.ObtenerTodos(); if (interfacesSalidaInfo == null) { return(entradaGanadoCosteo); } interfacesSalidaInfo.ListaInterfaceDetalle.ForEach(det => { var entradaGanadoDetalle = new EntradaDetalleInfo { TipoGanado = det.TipoGanado, Cabezas = det.Cabezas, Importe = det.Importe, PrecioKilo = det.PrecioKG, PesoOrigen = det.ListaInterfaceSalidaAnimal.Sum(ani => ani.PesoOrigen), ListaTiposGanado = tiposGanado, FechaSalidaInterface = interfacesSalidaInfo.FechaSalida, }; entradaGanadoCosteo.ListaEntradaDetalle.Add(entradaGanadoDetalle); if (det.ListaInterfaceSalidaAnimal != null) { det.ListaInterfaceSalidaAnimal.ForEach(animal => { if (animal.ListaSalidaCostos != null) { var listaCostosAnimal = (from costo in animal.ListaSalidaCostos select new EntradaGanadoCostoInfo { Costo = costo.Costo, Importe = costo.Importe, TieneCuenta = true, //CuentaProvision = claveContable.Valor, //DescripcionCuenta = claveContable.Descripcion }); listaEntradaGanadoCostoAuxiliar.AddRange(listaCostosAnimal); var span = interfacesSalidaInfo.FechaSalida - animal.FechaCompra; diasEstancia.Add(span.TotalDays); } }); } }); var costosAgrupados = (from costos in listaEntradaGanadoCostoAuxiliar group costos by costos.Costo.CostoID into costoAgrupado let interfaceSalidaCostoInfo = costoAgrupado.FirstOrDefault() let claveContable = ObtenerCuentaInventario(interfaceSalidaCostoInfo.Costo, entradaGanado. OrganizacionOrigenID, ClaveCuenta.CuentaInventarioTransito) where interfaceSalidaCostoInfo != null select new EntradaGanadoCostoInfo { Costo = interfaceSalidaCostoInfo.Costo, TieneCuenta = true, Importe = costoAgrupado.Sum(cos => cos.Importe), CuentaProvision = claveContable.Valor, DescripcionCuenta = claveContable.Descripcion, Origen = true }).ToList(); entradaGanadoCosteo.ListaCostoEntrada.AddRange(costosAgrupados); entradaGanadoCosteo.DiasEstancia = Convert.ToInt32(diasEstancia.Average()); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } return(entradaGanadoCosteo); }