// Modify default (Update all attributes of the class) public void ModifyDefault(ContenedorEN contenedor) { try { SessionInitializeTransaction(); ContenedorEN contenedorEN = (ContenedorEN)session.Load(typeof(ContenedorEN), contenedor.Id); contenedorEN.Tipo = contenedor.Tipo; session.Update(contenedorEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is ReciclaUAGenNHibernate.Exceptions.ModelException) { throw ex; } throw new ReciclaUAGenNHibernate.Exceptions.DataLayerException("Error in ContenedorCAD.", ex); } finally { SessionClose(); } }
public static ContenedorDTOA Convert(ContenedorEN en, NHibernate.ISession session = null) { ContenedorDTOA dto = null; ContenedorRESTCAD contenedorRESTCAD = null; ContenedorCEN contenedorCEN = null; ContenedorCP contenedorCP = null; if (en != null) { dto = new ContenedorDTOA(); contenedorRESTCAD = new ContenedorRESTCAD(session); contenedorCEN = new ContenedorCEN(contenedorRESTCAD); contenedorCP = new ContenedorCP(session); // // Attributes dto.Id = en.Id; dto.Tipo = en.Tipo; // // TravesalLink // // Service } return(dto); }
public int Crear(ContenedorEN contenedor) { try { SessionInitializeTransaction(); if (contenedor.Punto != null) { // Argumento OID y no colección. contenedor.Punto = (ReciclaUAGenNHibernate.EN.ReciclaUA.PuntoReciclajeEN)session.Load(typeof(ReciclaUAGenNHibernate.EN.ReciclaUA.PuntoReciclajeEN), contenedor.Punto.Id); contenedor.Punto.Contenedores .Add(contenedor); } session.Save(contenedor); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is ReciclaUAGenNHibernate.Exceptions.ModelException) { throw ex; } throw new ReciclaUAGenNHibernate.Exceptions.DataLayerException("Error in ContenedorCAD.", ex); } finally { SessionClose(); } return(contenedor.Id); }
private void dgvLista_DoubleClick(object sender, EventArgs e) { if (ActivarFiltros == true) { int a = 0; this.Cursor = Cursors.WaitCursor; dgvLista.CurrentRow.Cells["Seleccionar"].Value = true; foreach (DataGridViewRow Fila in dgvLista.Rows) { if (Convert.ToBoolean(Fila.Cells["Seleccionar"].Value) == true) { a++; Array.Resize(ref oContenedor, a); oContenedor[a - 1] = new ContenedorEN(); oContenedor[a - 1].idContenedor = Convert.ToInt32(Fila.Cells["idContenedor"].Value); oContenedor[a - 1].Nombre = Fila.Cells["Nombre"].Value.ToString(); oContenedor[a - 1].Descripcion = Fila.Cells["Descripcion"].Value.ToString(); oContenedor[a - 1].Codigo = Fila.Cells["Codigo"].Value.ToString(); } } this.Cursor = Cursors.Default; this.Close(); } }
public ContenedorEN ReadOIDDefault(int id ) { ContenedorEN contenedorEN = null; try { SessionInitializeTransaction(); contenedorEN = (ContenedorEN)session.Get(typeof(ContenedorEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is ReciclaUAGenNHibernate.Exceptions.ModelException) { throw ex; } throw new ReciclaUAGenNHibernate.Exceptions.DataLayerException("Error in ContenedorCAD.", ex); } finally { SessionClose(); } return(contenedorEN); }
public void Borrar(int id ) { try { SessionInitializeTransaction(); ContenedorEN contenedorEN = (ContenedorEN)session.Load(typeof(ContenedorEN), id); session.Delete(contenedorEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is ReciclaUAGenNHibernate.Exceptions.ModelException) { throw ex; } throw new ReciclaUAGenNHibernate.Exceptions.DataLayerException("Error in ContenedorCAD.", ex); } finally { SessionClose(); } }
private string InformacionDelRegistro(ContenedorEN oRegistroEN) { string Cadena = @"idContenedor: {0}, Codigo: {7}, Nombre: {1}, Descripcion: {2}, idUsuarioDeCreacion: {3}, FechaDeCreacion: {4}, idUsuarioModificacion: {5}, FechaDeModificacion: {6}"; Cadena = string.Format(Cadena, oRegistroEN.idContenedor, oRegistroEN.Nombre, oRegistroEN.Descripcion, oRegistroEN.idUsuarioDeCreacion, oRegistroEN.FechaDeCreacion, oRegistroEN.idUsuarioModificacion, oRegistroEN.FechaDeModificacion, oRegistroEN.Codigo); Cadena = Cadena.Replace(",", Environment.NewLine); return(Cadena); }
public ContenedorEN BuscarPorId(int id ) { ContenedorEN contenedorEN = null; contenedorEN = _IContenedorCAD.BuscarPorId(id); return(contenedorEN); }
public bool Eliminar(ContenedorEN oRegistroEN, DatosDeConexionEN oDatos) { oTransaccionesAD = new TransaccionesAD(); try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = @"Delete from Contenedor Where idContenedor = @idContenedor;"; Comando.CommandText = Consultas; Comando.Parameters.Add(new MySqlParameter("@idContenedor", MySqlDbType.Int32)).Value = oRegistroEN.idContenedor; Comando.ExecuteNonQuery(); DescripcionDeOperacion = string.Format("El registro fue Eliminado Correctamente. {0} {1}", Environment.NewLine, InformacionDelRegistro(oRegistroEN)); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Eliminar", "Elminar Registro", "CORRECTO"); oTransaccionesAD.Agregar(oTran, oDatos); return(true); } catch (Exception ex) { this.Error = ex.Message; DescripcionDeOperacion = string.Format("Se produjo el seguiente error: '{2}' al eliminar el registro. {0} {1} ", Environment.NewLine, InformacionDelRegistro(oRegistroEN), ex.Message); //Agregamos la Transacción.... TransaccionesEN oTran = InformacionDelaTransaccion(oRegistroEN, "Eliminar", "Eliminar Registro", "ERROR"); oTransaccionesAD.Agregar(oTran, oDatos); return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; oTransaccionesAD = null; } }
public bool ListadoParaReportes(ContenedorEN oRegistroEN, DatosDeConexionEN oDatos) { try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = string.Format(@"Select c.idContenedor, c.idSeccion,l.idLocacion,l.idBodega, b.idAlmacen, concat(a.Codigo,'-', b.Codigo, '-', l.Codigo,'-',s.Codigo,'-',c.Codigo) as 'CodigoDeAlmacenaje', c.Codigo, c.Nombre, c.Descripcion, concat(a.Codigo, '-', a.Nombre) as 'Almacen', concat(b.Codigo, '-',b.Nombre) as 'Bodega', concat(l.Codigo, '-',l.Nombre) as 'Locacion', concat(s.Codigo, '-',s.Nombre) as 'Seccion' from contenedor as c inner join seccion as s on s.idSeccion = c.idSeccion inner join locacion as l on l.idLocacion = s.idLocacion inner join bodega as b on b.idAlmacen = l.idBodega inner join almacen as a on a.idAlmacen = b.idAlmacen Where c.idContenedor > 0 {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy); Comando.CommandText = Consultas; Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); return(true); } catch (Exception ex) { this.Error = ex.Message; return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; } }
private ContenedorEN InformacionDelRegistroLocal() { ContenedorEN oRegistroEN = new ContenedorEN(); oRegistroEN.idContenedor = Convert.ToInt32((txtIdentificador.Text.Length > 0 ? txtIdentificador.Text : "0")); oRegistroEN.Codigo = txtCodigo.Text.Trim(); oRegistroEN.Nombre = txtContenedor.Text.Trim(); oRegistroEN.Descripcion = txtDescripcion.Text.Trim(); return(oRegistroEN); }
public void WhenBuscoEdificiosPorEsteTipo() { try { contenedor = contenedorCEN.BuscarContenedoresPorTipo(TipoContenedorEnum.organico)[0]; Assert.Fail(); } catch (Exception) { } }
public void Modificar(int p_Contenedor_OID, ReciclaUAGenNHibernate.Enumerated.ReciclaUA.TipoContenedorEnum p_tipo) { ContenedorEN contenedorEN = null; //Initialized ContenedorEN contenedorEN = new ContenedorEN(); contenedorEN.Id = p_Contenedor_OID; contenedorEN.Tipo = p_tipo; //Call to ContenedorCAD _IContenedorCAD.Modificar(contenedorEN); }
private void LlenarCamposDesdeBaseDatosSegunID() { this.Cursor = Cursors.WaitCursor; ContenedorEN oRegistrosEN = new ContenedorEN(); ContenedorLN oRegistrosLN = new ContenedorLN(); oRegistrosEN.idContenedor = ValorLlavePrimariaEntidad; if (oRegistrosLN.ListadoPorIdentificador(oRegistrosEN, Program.oDatosDeConexion)) { if (oRegistrosLN.TraerDatos().Rows.Count > 0) { //idContenedor, DesContenedor, Debitos, Creditos DataRow Fila = oRegistrosLN.TraerDatos().Rows[0]; txtDescripcion.Text = Fila["Descripcion"].ToString(); txtCodigo.Text = Fila["Codigo"].ToString(); txtContenedor.Text = Fila["Nombre"].ToString(); cmbAlmacen.SelectedValue = Convert.ToInt32(Fila["idAlmacen"]); cmbBodega.SelectedValue = Convert.ToInt32(Fila["idBodega"]); cmbLocacion.SelectedValue = Convert.ToInt32(Fila["idLocacion"]); cmbSeccion.SelectedValue = Convert.ToInt32(Fila["idSeccion"]); 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 tsbRegistroLocal_Click(object sender, EventArgs e) { try { oContenedor = InformacionDelRegistroLocal(); VariableLocal = true; this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Registro local", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public bool Agregar(ContenedorEN oREgistroEN, DatosDeConexionEN oDatos) { if (oContenedorAD.Agregar(oREgistroEN, oDatos)) { Error = string.Empty; return(true); } else { Error = oContenedorAD.Error; return(false); } }
public bool ValidarSiElRegistroEstaVinculado(ContenedorEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion) { if (oContenedorAD.ValidarSiElRegistroEstaVinculado(oREgistroEN, oDatos, TipoDeOperacion)) { Error = oContenedorAD.Error; return(true); } else { Error = string.Empty; return(false); } }
public bool ListadoPorIdSeccion(ContenedorEN oREgistroEN, DatosDeConexionEN oDatos) { if (oContenedorAD.ListadoPorIdSeccion(oREgistroEN, oDatos)) { Error = string.Empty; return(true); } else { Error = oContenedorAD.Error; return(false); } }
public bool VerificarSiLaEntidadEstaAsociadaAProducto(ContenedorEN oREgistroEN, DatosDeConexionEN oDatos, string TipoDeOperacion) { if (oContenedorAD.VerificarSiLaEntidadEstaAsociadaAProducto(oREgistroEN, oDatos, TipoDeOperacion)) { Error = oContenedorAD.Error; return(true); } else { Error = string.Empty; return(false); } }
private void tsbSeleccionarTodos_Click(object sender, EventArgs e) { try { this.Cursor = Cursors.WaitCursor; tsbSeleccionarTodos.Checked = !tsbMarcarTodos.Checked; if (tsbSeleccionarTodos.Checked == true) { tsbSeleccionarTodos.Image = Properties.Resources.unchecked16x16; } else { tsbSeleccionarTodos.Image = Properties.Resources.checked16x16; } int a = 0; this.Cursor = Cursors.WaitCursor; if (dgvLista.Rows.Count > 0) { foreach (DataGridViewRow Fila in dgvLista.Rows) { if (Convert.ToBoolean(Fila.Cells["Seleccionar"].Value) == true) { a++; Array.Resize(ref oContenedor, a); oContenedor[a - 1] = new ContenedorEN(); oContenedor[a - 1].idContenedor = Convert.ToInt32(Fila.Cells["idContenedor"].Value); oContenedor[a - 1].Nombre = Fila.Cells["Nombre"].Value.ToString(); oContenedor[a - 1].Descripcion = Fila.Cells["Descripcion"].Value.ToString(); oContenedor[a - 1].Codigo = Fila.Cells["Codigo"].Value.ToString(); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Seleccionar registros", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { AgregarRegistrosAlDTUsuario(); this.Cursor = Cursors.Default; this.Close(); } }
public bool ListadoParaCombos(ContenedorEN oRegistroEN, DatosDeConexionEN oDatos) { try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = string.Format(@"Select idContenedor, cr.Nombre, concat(cr.Codigo, '', cr.Nombre) as 'Contenedor' from Contenedor as cr where idContenedor > 0 {0} {1} ; ", oRegistroEN.Where, oRegistroEN.OrderBy); Comando.CommandText = Consultas; System.Diagnostics.Debug.Print("Consultas de Tipo de transaccion: " + Consultas); Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); return(true); } catch (Exception ex) { this.Error = ex.Message; return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; } }
public bool ListadoPorInclusionDeSecciones(ContenedorEN oRegistroEN, DatosDeConexionEN oDatos) { try { Cnn = new MySqlConnection(TraerCadenaDeConexion(oDatos)); Cnn.Open(); Comando = new MySqlCommand(); Comando.Connection = Cnn; Comando.CommandType = CommandType.Text; Consultas = string.Format(@"Select idContenedor, idSeccion, Codigo, Nombre, Descripcion from contenedor Where idContenedor > 0 {0} {1} ", oRegistroEN.Where, oRegistroEN.OrderBy); Comando.CommandText = Consultas; System.Diagnostics.Debug.Print(Consultas); Adaptador = new MySqlDataAdapter(); DT = new DataTable(); Adaptador.SelectCommand = Comando; Adaptador.Fill(DT); return(true); } catch (Exception ex) { this.Error = ex.Message; return(false); } finally { if (Cnn != null) { if (Cnn.State == ConnectionState.Open) { Cnn.Close(); } } Cnn = null; Comando = null; Adaptador = null; } }
private ContenedorEN InformacionDelRegistro() { ContenedorEN oRegistroEN = new ContenedorEN(); oRegistroEN.idContenedor = Convert.ToInt32((txtIdentificador.Text.Length > 0 ? txtIdentificador.Text : "0")); oRegistroEN.Codigo = txtCodigo.Text.Trim(); oRegistroEN.Nombre = txtContenedor.Text.Trim(); oRegistroEN.Descripcion = txtDescripcion.Text.Trim(); oRegistroEN.oSeccionEN.idSeccion = Convert.ToInt32(cmbSeccion.SelectedValue); oRegistroEN.oSeccionEN.Nombre = cmbSeccion.Text; //partes generales. oRegistroEN.oLoginEN = Program.oLoginEN; oRegistroEN.idUsuarioDeCreacion = Program.oLoginEN.idUsuario; oRegistroEN.idUsuarioModificacion = Program.oLoginEN.idUsuario; oRegistroEN.FechaDeCreacion = System.DateTime.Now; oRegistroEN.FechaDeCreacion = System.DateTime.Now; return(oRegistroEN); }
private TransaccionesEN InformacionDelaTransaccion(ContenedorEN oContenedor, String TipoDeOperacion, String Descripcion, String Estado) { TransaccionesEN oRegistroEN = new TransaccionesEN(); oRegistroEN.idregistro = oContenedor.idContenedor; oRegistroEN.Modelo = "General"; oRegistroEN.Modulo = "ContenedorAD"; oRegistroEN.Tabla = "Contenedor"; oRegistroEN.tipodeoperacion = TipoDeOperacion; oRegistroEN.Estado = Estado; oRegistroEN.ip = oContenedor.oLoginEN.NumeroIP; oRegistroEN.idusuario = oContenedor.oLoginEN.idUsuario; oRegistroEN.idusuarioaprueba = oContenedor.oLoginEN.idUsuario; oRegistroEN.descripciondelusuario = DescripcionDeOperacion; oRegistroEN.descripcioninterna = Descripcion; oRegistroEN.NombreDelEquipo = oContenedor.oLoginEN.NombreDelComputador; return(oRegistroEN); }
public bool Eliminar(ContenedorEN oREgistroEN, DatosDeConexionEN oDatos) { if (string.IsNullOrEmpty(oREgistroEN.idContenedor.ToString()) || oREgistroEN.idContenedor == 0) { this.Error = @"Se debe de seleccionar un elemento de la lista"; return(false); } if (oContenedorAD.Eliminar(oREgistroEN, oDatos)) { Error = string.Empty; return(true); } else { Error = oContenedorAD.Error; return(false); } }
private void LLenarListado() { try { this.Cursor = Cursors.WaitCursor; ContenedorEN oRegistrosEN = new ContenedorEN(); ContenedorLN oRegistrosLN = new ContenedorLN(); oRegistrosEN.Where = WhereDinamico(); 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; } }
public static ContenedorEN Convert(ContenedorDTO dto) { ContenedorEN newinstance = null; try { if (dto != null) { newinstance = new ContenedorEN(); newinstance.Id = dto.Id; newinstance.Tipo = dto.Tipo; if (dto.Punto_oid != -1) { ReciclaUAGenNHibernate.CAD.ReciclaUA.IPuntoReciclajeCAD puntoReciclajeCAD = new ReciclaUAGenNHibernate.CAD.ReciclaUA.PuntoReciclajeCAD(); newinstance.Punto = puntoReciclajeCAD.ReadOIDDefault(dto.Punto_oid); } if (dto.Acciones_oid != null) { ReciclaUAGenNHibernate.CAD.ReciclaUA.IAccionReciclarCAD accionReciclarCAD = new ReciclaUAGenNHibernate.CAD.ReciclaUA.AccionReciclarCAD(); newinstance.Acciones = new System.Collections.Generic.List <ReciclaUAGenNHibernate.EN.ReciclaUA.AccionReciclarEN>(); foreach (int entry in dto.Acciones_oid) { newinstance.Acciones.Add(accionReciclarCAD.ReadOIDDefault(entry)); } } } } catch (Exception ex) { throw ex; } return(newinstance); }
public int Crear(ReciclaUAGenNHibernate.Enumerated.ReciclaUA.TipoContenedorEnum p_tipo, int p_punto) { ContenedorEN contenedorEN = null; int oid; //Initialized ContenedorEN contenedorEN = new ContenedorEN(); contenedorEN.Tipo = p_tipo; if (p_punto != -1) { // El argumento p_punto -> Property punto es oid = false // Lista de oids id contenedorEN.Punto = new ReciclaUAGenNHibernate.EN.ReciclaUA.PuntoReciclajeEN(); contenedorEN.Punto.Id = p_punto; } //Call to ContenedorCAD oid = _IContenedorCAD.Crear(contenedorEN); return(oid); }
public ContenedorEN ContenedorAccion(int id) { ContenedorEN result = null; try { SessionInitializeTransaction(); String sql = @"select self.Contenedor FROM AccionReciclarEN self " + "where self.Id = :p_Id"; IQuery query = session.CreateQuery(sql).SetParameter("p_Id", id); result = query.UniqueResult <ContenedorEN>(); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is ReciclaUAGenNHibernate.Exceptions.ModelException) { throw ex; } throw new ReciclaUAGenNHibernate.Exceptions.DataLayerException("Error in AccionReciclarRESTCAD.", ex); } finally { SessionClose(); } return(result); }
public void ThenNoSeBorraElContenedor() { contenedor = contenedorCEN.BuscarPorId(id_contenedor); Assert.IsNull(contenedor); }