private void Generar() { string UltimoPeriodo=""; pgbProgreso.Value = 0; pgbProgreso.Minimum = 0; pgbProgreso.Visible = true; DateTime StartDate = new DateTime(int.Parse(this.mtbDesde.Text.Substring(0, 4)),int.Parse( this.mtbDesde.Text.Substring(5, 2)), 1); DateTime EndDate = new DateTime(int.Parse(this.mtbHasta.Text.Substring(0, 4)), int.Parse(this.mtbHasta.Text.Substring(5, 2)), 1); //Calculo diferencia de meses para utilizar en la barra de progreso pgbProgreso.Maximum = Math.Abs((EndDate.Month - StartDate.Month) + 12 * (EndDate.Year - StartDate.Year)); int MonthInterval = 1; PeriodosImplement oPeriodoImplement = new PeriodosImplement(); SysConfigImplement oSysConfigImplement = new SysConfigImplement(); sys_configuracion oSysUltimoPeriodo = new sys_configuracion(); oSysUltimoPeriodo = oSysConfigImplement.GetByNombre("UltimoPeriodo"); UltimoPeriodo = oSysUltimoPeriodo.valor; //voy sumando meses hasta llegar a iguales fechas while (StartDate.AddMonths(MonthInterval) <= EndDate) { StartDate = StartDate.AddMonths(MonthInterval); periodos oPeriodo = new periodos(); oPeriodo.id_periodo = StartDate.Date.ToString("yyyyMMdd").Substring(0,6); DateTime PrimerVencimiento = DateTime.Parse(oPeriodo.id_periodo.Substring(0, 4) + "/" + oPeriodo.id_periodo.Substring(4, 2)+"/" + this.txtPrimerVenc.Text); // incremento el dia mientra no sea fin de semana(se puede agregar para feriados - primer vencimiento while (PrimerVencimiento.DayOfWeek == DayOfWeek.Saturday || PrimerVencimiento.DayOfWeek == DayOfWeek.Sunday) { PrimerVencimiento=PrimerVencimiento.Date.AddDays(1); } DateTime segundoVencimiento = PrimerVencimiento.Date.AddDays(int.Parse(this.txtDiasEntre.Text)); // incremento el dia mientra no sea fin de semana(se puede agregar para feriados - segundo vencimiento while (segundoVencimiento.DayOfWeek == DayOfWeek.Saturday || segundoVencimiento.DayOfWeek == DayOfWeek.Sunday) { segundoVencimiento = segundoVencimiento.Date.AddDays(1); } oPeriodo.fecha_primer_venc = PrimerVencimiento; oPeriodo.fecha_segundo_venc = segundoVencimiento; oPeriodo.fecha_tercer_venc = null; oPeriodo.fecha_facturacion = null; oPeriodo.facturado = false; oPeriodoImplement.Save(oPeriodo); UltimoPeriodo=oPeriodo.id_periodo; pgbProgreso.Value += 1; } if (oSysUltimoPeriodo.valor != UltimoPeriodo) { oSysUltimoPeriodo.valor = UltimoPeriodo; oSysConfigImplement.Update(oSysUltimoPeriodo); MessageBox.Show("La Generación se realizo Exitosamente"); Inicializar(); } else { MessageBox.Show("La Generación fue nula"); } }
public DateTime? ObtenerFechaVenc(int idFactura) { periodos oPeriodo = new periodos(); PeriodosImplement oPeriososImplement = new PeriodosImplement(); FacturasImplement oFacturasImplement = new FacturasImplement(); oPeriodo = oPeriososImplement.Get(oFacturasImplement.Get(idFactura).id_periodo.ToString()); return oPeriodo.fecha_primer_venc; }
public int ObtenerDiasDeVencimiento(int idFactura) { periodos oPeriodo = new periodos(); PeriodosImplement oPeriososImplement = new PeriodosImplement(); FacturasImplement oFacturasImplement = new FacturasImplement(); oPeriodo = oPeriososImplement.Get(oFacturasImplement.Get(idFactura).id_periodo.ToString()); TimeSpan diferencia; if (oPeriodo.fecha_primer_venc < DateTime.Today) { diferencia = DateTime.Today - DateTime.Parse(oPeriodo.fecha_primer_venc.ToString()); } else { diferencia = DateTime.Today - DateTime.Today; } return diferencia.Days; }
/// <summary> /// Create a new periodos object. /// </summary> /// <param name="id_periodo">Initial value of the id_periodo property.</param> public static periodos Createperiodos(global::System.String id_periodo) { periodos periodos = new periodos(); periodos.id_periodo = id_periodo; return periodos; }
/// <summary> /// Deprecated Method for adding a new object to the periodos EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToperiodos(periodos periodos) { base.AddObject("periodos", periodos); }