private void gcReparaciones_DoubleClick(object sender, EventArgs e) { try { if (this.gridView1.GetSelectedRows().Count() == 0) { return; } this._activoSelRepara = new Modelos.Reparaciones(); foreach (int i in this.gridView1.GetSelectedRows()) { var dr1 = this.gridView1.GetRow(i); this._activoSelRepara = (Modelos.Reparaciones)dr1; } // seleccionar los activos this._activos = this._activosNegocio.getActivoSinEstatus((long)this._activoSelRepara.idActivo); // buscar los responsables y la sucursal this._activo = this._activosNegocio.getActivoDesc(this._activoSelRepara.idActivo); this.tbActivo.Text = this._activoSelRepara.activo; this.tbFechaIni.Text = this._activoSelRepara.fechaInicio; this.tbFechaFin.Text = this._activoSelRepara.fechaFin; this.tbCausaObserv.Text = this._activoSelRepara.causa; this.tbObservAct.Text = this._activoSelRepara.observActivacion; } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Reimpresión Bajas/Reparaciones", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void btnBuscaActivo_Click(object sender, EventArgs e) { try { frmBuscaActReparacion form = new frmBuscaActReparacion(); var result = form.ShowDialog(); if (result == DialogResult.OK) { // muestra los datos del activo Modelos.Reparaciones reparado = form._activoSelecc; this.tbActivo.Text = reparado.activo; this.tbUsuario.Text = reparado.usuario; this.tbFechaIni.Text = reparado.fechaInicio; this.tbCausa.Text = reparado.causa; this._idReparacion = reparado.idReparacion; this._idActivo = reparado.idActivo; this.dtpFechaFin.Value = DateTime.Today; this.tbObservAct.Text = string.Empty; } if (result == DialogResult.Cancel) { MessageBox.Show("Operación Cancelada", "Activos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Activos", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void gcReparaciones_DoubleClick(object sender, EventArgs e) { try { if (this.gridView1.GetSelectedRows().Count() == 0) { return; } this._activoSelecc = new Modelos.Reparaciones(); foreach (int i in this.gridView1.GetSelectedRows()) { var dr1 = this.gridView1.GetRow(i); this._activoSelecc = (Modelos.Reparaciones)dr1; } this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close(); } catch (Exception Ex) { MessageBox.Show(Ex.Message, "Responsivas", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
private void _reiniciaControles() { this.tbActivo.Text = string.Empty; this.tbFechaFin.Text = string.Empty; this.tbFecha.Text = string.Empty; this.tbFechaIni.Text = string.Empty; this.tbCausaObserv.Text = string.Empty; this.tbObservAct.Text = string.Empty; this.gcBajas.DataSource = null; this.gcReparaciones.DataSource = null; this._activo = null; this._activos = new List <Modelos.Activos>(); this._activoSelBajas = null; this._activoSelRepara = null; }
// obtiene las reparaciones de los activos enviados public List <Reparaciones> getActivosEnRepar(List <int> activosIds) { List <Modelos.Reparaciones> result = new List <Modelos.Reparaciones>(); Modelos.Reparaciones ent; string sql = "select r.idreparacion, r.idactivo, r.idusuarioresponsable, r.fechainicio, r.observacionesactivacion, " + "r.fechafin, r.causa, r.status, a.nombrecorto as activo, a.idtipo, p.nombrecompleto as usuario " + "from activos_reparacion r " + "left join activos_activos a on (r.idactivo = a.idactivo) " + "left join activos_usuarios u on (r.idusuarioresponsable = u.idusuario) " + "left join activos_personas p on (u.idpersona = p.idpersona) " + "where FIND_IN_SET(r.idactivo, @parameter) != 0 and r.status = 'A' order by a.nombrecorto"; string wherIn = string.Join(",", activosIds); // define conexion con la cadena de conexion using (var conn = this._conexion.getConexion()) { // abre la conexion conn.Open(); using (var cmd = new MySqlCommand()) { cmd.Connection = conn; // define parametros cmd.Parameters.AddWithValue("@parameter", wherIn); ManejoSql res = Utilerias.EjecutaSQL(sql, cmd); if (res.ok) { if (res.reader.HasRows) { while (res.reader.Read()) { ent = new Modelos.Reparaciones(); ent.idReparacion = Convert.ToInt16(res.reader["idreparacion"]); ent.idActivo = Convert.ToInt16(res.reader["idactivo"]); ent.idUsuarioResp = Convert.ToInt16(res.reader["idusuarioresponsable"]); ent.usuario = Convert.ToString(res.reader["usuario"]); ent.usuario = ent.usuario.Replace("&", " "); ent.activo = Convert.ToString(res.reader["activo"]); if (res.reader["fechainicio"] is DBNull) { ent.fechaInicio = null; } else { DateTime dt = DateTime.Parse(Convert.ToString(res.reader["fechainicio"])); ent.fechaInicio = dt.ToString("dd/MM/yyyy"); } if (res.reader["fechafin"] is DBNull) { ent.fechaFin = null; } else { ent.fechaFin = Convert.ToString(res.reader["fechafin"]); } ent.causa = Convert.ToString(res.reader["causa"]); ent.observActivacion = Convert.ToString(res.reader["observacionesactivacion"]); ent.status = Convert.ToString(res.reader["status"]); result.Add(ent); } } } else { throw new Exception(res.numErr + ": " + res.descErr); } // cerrar el reader res.reader.Close(); } } return(result); }
// obtiene los activos que se encuentran en reparacion por sucursal public List <Reparaciones> getReparaciones(int idSuc) { List <Modelos.Reparaciones> result = new List <Modelos.Reparaciones>(); Modelos.Reparaciones ent; string sql = "select are.idreparacion, a.idactivo, a.nombrecorto, are.idusuarioresponsable, pu.nombrecompleto, " + "are.fechainicio, are.fechafin, are.causa, are.observacionesactivacion, are.status, s.idsucursal " + "from activos_reparacion are " + "left join activos_activos a on (are.idactivo = a.idactivo) " + "left join activos_areas ar on (a.idarea = ar.idarea) " + "left join activos_sucursales s on (ar.idsucursal = s.idsucursal) " + "left join activos_usuarios u on (are.idusuarioresponsable = u.idusuario) " + "left join activos_personas pu on (u.idpersona = pu.idpersona) " + "where s.idsucursal = @idsuc "; // define conexion con la cadena de conexion using (var conn = this._conexion.getConexion()) { // abre la conexion conn.Open(); using (var cmd = new MySqlCommand()) { cmd.Connection = conn; // define parametros cmd.Parameters.AddWithValue("@idsuc", idSuc); ManejoSql res = Utilerias.EjecutaSQL(sql, cmd); if (res.ok) { if (res.reader.HasRows) { while (res.reader.Read()) { ent = new Modelos.Reparaciones(); ent.idReparacion = Convert.ToInt16(res.reader["idreparacion"]); ent.idActivo = Convert.ToInt16(res.reader["idactivo"]); ent.activo = Convert.ToString(res.reader["nombrecorto"]); ent.idUsuarioResp = Convert.ToInt16(res.reader["idusuarioresponsable"]); ent.usuario = Convert.ToString(res.reader["nombrecompleto"]); if (res.reader["fechainicio"] is DBNull) { ent.fechaInicio = null; } else { DateTime dt = DateTime.Parse(Convert.ToString(res.reader["fechainicio"])); ent.fechaInicio = dt.ToString("dd/MM/yyyy"); } if (res.reader["fechafin"] is DBNull) { ent.fechaFin = null; } else { DateTime dt = DateTime.Parse(Convert.ToString(res.reader["fechafin"])); ent.fechaFin = dt.ToString("dd/MM/yyyy"); } ent.observActivacion = Convert.ToString(res.reader["observacionesactivacion"]); ent.causa = Convert.ToString(res.reader["causa"]); ent.status = Convert.ToString(res.reader["status"]); result.Add(ent); } } } else { throw new Exception(res.numErr + ": " + res.descErr); } // cerrar el reader res.reader.Close(); } } return(result); }