private void TraerFechaParaElInicioDelPeriodo() { PeriodoLN oPeriodoLN = new PeriodoLN(); try { if (oPeriodoLN.ListarFechaInicialDelPeriodo(Program.oDatosDeConexion)) { if (oPeriodoLN.TraerDatos().Rows.Count > 0) { DataRow Fila = oPeriodoLN.TraerDatos().Rows[0]; DateTime FechaActual = Convert.ToDateTime(Fila["Res"].ToString()); dtpDesde.Value = FechaActual.AddDays(1); System.Globalization.DateTimeFormatInfo mfi = new System.Globalization.DateTimeFormatInfo(); txtNombre.Text = string.Format("Periodo de Cierre al Mes de: '{0}'", mfi.GetMonthName(dtpDesde.Value.Month)); txtObservacion.Text = string.Format("Periodo de Cierre al Mes de: '{0}', con rago de fecha: '{1}' -{2}", mfi.GetMonthName(dtpDesde.Value.Month), dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString()); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Información de la fecha de inicio del periodo", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { oPeriodoLN = null; } }
private void EvaluarCuantosMovimientosCeranAfectadosporElCierre() { PeriodoEN oPeriodoEN = new PeriodoEN(); PeriodoLN oPeriodoLN = new PeriodoLN(); try { DateTime Desde = new DateTime(dtpDesde.Value.Year, dtpDesde.Value.Month, dtpDesde.Value.Day); DateTime Hasta = new DateTime(dtpHasta.Value.Year, dtpHasta.Value.Month, dtpHasta.Value.Day); oPeriodoEN.Desde = Desde; oPeriodoEN.Hasta = Hasta; System.Globalization.DateTimeFormatInfo mfi = new System.Globalization.DateTimeFormatInfo(); if (Desde.Year == Hasta.Year && Desde.Month == Hasta.Month) { txtNombre.Text = string.Format("Periodo de Cierre al Mes de: '{0}'", mfi.GetMonthName(dtpDesde.Value.Month)); } else if (Desde.Year == Hasta.Year && Desde.Month != Hasta.Month) { txtNombre.Text = string.Format("Periodo de Cierre del Mes: '{0}', Hasta el mes: {1}", mfi.GetMonthName(dtpDesde.Value.Month), mfi.GetMonthName(dtpHasta.Value.Month)); } else if (Desde.Year != Hasta.Year && Desde.Month == Hasta.Month) { txtNombre.Text = string.Format("Periodo de Cierre se aplicara Desde: '{0}-{2}', Hasta: '{1}-{3}'", mfi.GetMonthName(dtpDesde.Value.Month), mfi.GetMonthName(dtpHasta.Value.Month), dtpDesde.Value.Year, dtpHasta.Value.Year); } else if (Desde.Year != Hasta.Year && Desde.Month != Hasta.Month) { txtNombre.Text = string.Format("Periodo de Cierre se aplicara: '{0}-{2}', hasta: '{1}-{3}'", mfi.GetMonthName(dtpDesde.Value.Month), mfi.GetMonthName(dtpHasta.Value.Month), dtpDesde.Value.Year, dtpHasta.Value.Year); } txtObservacion.Text = string.Format("Periodo de Cierre al Mes de: '{0}', con rago de fecha: '{1}' -{2}", mfi.GetMonthName(dtpDesde.Value.Month), dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString()); if (oPeriodoLN.EvaluarCuantosMovimientosCeranAfectadosPorElCierreDePeriodo(oPeriodoEN, Program.oDatosDeConexion)) { if (oPeriodoLN.TraerDatos().Rows.Count > 0) { lbContar.Text = string.Format("Número ({0}) de registros incluidos en el periodo: '{1}' en el Rago de Fechas: {2} - {3} ", oPeriodoLN.TraerDatos().Rows[0]["TotalDeRegistros"].ToString(), txtNombre.Text, dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString()); } else { lbContar.Text = string.Format("Número ({0}) de registros incluidos en el periodo: '{1}' en el Rago de Fechas: {2} - {3} ", 0, txtNombre.Text, dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString()); } } else { lbContar.Text = string.Format("Número ({0}) de registros incluidos en el periodo: '{1}' en el Rago de Fechas: {2} - {3} ", 0, txtNombre.Text, dtpDesde.Value.ToLongDateString(), dtpHasta.Value.ToLongDateString()); } } catch (Exception ex) { MessageBox.Show(ex.Message, string.Format("Evaluar cuantos movimientos de cuentas se van afectar con el '{0}' ", cmbEstado.Text), MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { oPeriodoLN = null; } }
private void tsbGuardar_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (LosDatosIngresadosSonCorrectos()) { PeriodoEN oRegistroEN = InformacionDelRegistro(); PeriodoLN oRegistroLN = new PeriodoLN(); if (oRegistroLN.ValidarRegistroDuplicado(oRegistroEN, Program.oDatosDeConexion, "AGREGAR")) { MessageBox.Show(oRegistroLN.Error, "Guardar información", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (oRegistroLN.Agregar(oRegistroEN, Program.oDatosDeConexion)) { txtIdentificador.Text = oRegistroEN.idPeriodo.ToString(); txtCodigo.Text = oRegistroEN.Codigo; ValorLlavePrimariaEntidad = oRegistroEN.idPeriodo; EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Guardar"); oRegistroEN = null; oRegistroLN = null; this.Cursor = Cursors.Default; if (CerrarVentana == true) { this.Close(); } else { OperacionARealizar = "Modificar"; ObtenerValoresDeConfiguracion(); LlamarMetodoSegunOperacion(); EstablecerTituloDeVentana(); DeshabilitarControlesSegunOperacionesARealizar(); } } else { throw new ArgumentException(oRegistroLN.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Guardar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
private void LlenarCamposDesdeBaseDatosSegunID() { this.Cursor = Cursors.WaitCursor; PeriodoEN oRegistrosEN = new PeriodoEN(); PeriodoLN oRegistrosLN = new PeriodoLN(); oRegistrosEN.idPeriodo = ValorLlavePrimariaEntidad; if (oRegistrosLN.ListadoPorIdentificador(oRegistrosEN, Program.oDatosDeConexion)) { if (oRegistrosLN.TraerDatos().Rows.Count > 0) { //idPeriodo, Codigo, Desde, Hasta, Nombre, Obsevaciones, Estado, DataRow Fila = oRegistrosLN.TraerDatos().Rows[0]; txtCodigo.Text = Fila["Codigo"].ToString(); txtNombre.Text = Fila["Nombre"].ToString(); txtObservacion.Text = Fila["Obsevaciones"].ToString(); cmbEstado.Text = Fila["Estado"].ToString(); dtpDesde.Value = Convert.ToDateTime(Fila["Desde"]); dtpHasta.Value = Convert.ToDateTime(Fila["Hasta"]); oRegistrosEN = null; oRegistrosLN = null; } else { string Mensaje; Mensaje = string.Format("El registro solicitado de {0} no ha sido encontrado." + "\n\r-----Causas---- " + "\n\r1. Este registro pudo haber sido eliminado por otro usuario." + "\n\r2. El listado no está actualizado.", NombreEntidad); MessageBox.Show(Mensaje, "Listado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); oRegistrosEN = null; oRegistrosLN = null; this.Close(); } } else { this.Cursor = Cursors.Default; MessageBox.Show(oRegistrosLN.Error, "Listado", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); oRegistrosEN = null; oRegistrosLN = null; } this.Cursor = Cursors.Default; }
private void EvaluarSiExistenTransacciones() { try { PeriodoLN oRegistroLN = new PeriodoLN(); if (oRegistroLN.EvaluarSiHayRegistrosEnTransacciones(Program.oDatosDeConexion) == false) { MessageBox.Show("No se encontraron movimientos de cuentas a afectar", "Evaluar si existen movimientos de cuentas", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Evaluar si Existen transacciones", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void LLenarListado() { try { this.Cursor = Cursors.WaitCursor; PeriodoEN oRegistrosEN = new PeriodoEN(); PeriodoLN oRegistrosLN = new PeriodoLN(); oRegistrosEN.Where = WhereDinamico(); oRegistrosEN.OrderBy = " Order by Hasta desc "; if (oRegistrosLN.Listado(oRegistrosEN, Program.oDatosDeConexion)) { dgvLista.Columns.Clear(); System.Diagnostics.Debug.Print(oRegistrosLN.TraerDatos().Rows.Count.ToString()); if (ActivarFiltros == true) { dgvLista.DataSource = AgregarColumnaSeleccionar(oRegistrosLN.TraerDatos()); } else { dgvLista.DataSource = oRegistrosLN.TraerDatos(); } FormatearDGV(); this.dgvLista.ClearSelection(); tsbNoRegistros.Text = "No. Registros: " + oRegistrosLN.TotalRegistros().ToString(); } else { throw new ArgumentException(oRegistrosLN.Error); } }catch (Exception ex) { MessageBox.Show(ex.Message, "Llenar listado de registro en la lista", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }
private void tsbEliminar_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; if (LosDatosIngresadosSonCorrectos()) { if (txtIdentificador.Text.Length == 0 || txtIdentificador.Text == "0") { MessageBox.Show("No se puede continuar. Ha ocurrido un error y el registro no ha sido cargado correctamente.", OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (MessageBox.Show("¿Está seguro que desea eliminar el registro?", "Eliminar la Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3) == System.Windows.Forms.DialogResult.No) { return; } PeriodoEN oRegistroEN = InformacionDelRegistro(); PeriodoLN oRegistroLN = new PeriodoLN(); if (oRegistroLN.ValidarSiElRegistroEstaVinculado(oRegistroEN, Program.oDatosDeConexion, "ELIMINAR")) { this.Cursor = Cursors.Default; MessageBox.Show(oRegistroLN.Error, this.OperacionARealizar, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } if (oRegistroLN.Eliminar(oRegistroEN, Program.oDatosDeConexion)) { txtIdentificador.Text = oRegistroEN.idPeriodo.ToString(); ValorLlavePrimariaEntidad = oRegistroEN.idPeriodo; EvaluarErrorParaMensajeAPantalla(oRegistroLN.Error, "Eliminar"); oRegistroEN = null; oRegistroLN = null; this.Cursor = Cursors.Default; if (CerrarVentana == true) { this.Close(); } } else { throw new ArgumentException(oRegistroLN.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Eliminar la información del registro", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { this.Cursor = Cursors.Default; } }