private void frmTiempoRespuestaIncidencia_Load(object sender, EventArgs e) { SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection2 == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector2 = null; string ID = "", DE = "", TI = "", PR = "", FE = ""; string strComandoC2 = "SELECT I.ID,I.Descripcion,T.Descripcion,P.Descripcion, I.FechaInicio, I.Tiempo_Respuesta, I.ID_Stat FROM INCIDENCIA I INNER JOIN PRIORIDAD P ON I.ID_Prioridad=P.ID INNER JOIN TIPO_INCIDENCIA T ON I.ID_Tipo=T.ID WHERE I.ID_Tecnico=" + TecID; Lector2 = UsoBD.Consulta(strComandoC2, Connection2); if (Lector2 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection2.Close(); return; } if (Lector2.HasRows) { while (Lector2.Read()) { if (Utileria.IsEmpty(Lector2.GetValue(5).ToString())) { if (Lector2.GetValue(6).ToString() != "1" && Lector2.GetValue(5).ToString() != "5") { ID = Lector2.GetValue(0).ToString(); DE = Lector2.GetValue(1).ToString(); TI = Lector2.GetValue(2).ToString(); PR = Lector2.GetValue(3).ToString(); FE = Lector2.GetValue(4).ToString(); ListViewItem Registro = new ListViewItem(ID); Registro.SubItems.Add(DE); Registro.SubItems.Add(TI); Registro.SubItems.Add(PR); Registro.SubItems.Add(FE); lvIndicencias.Items.Add(Registro); } } } } Connection2.Close(); }
private void button2_Click(object sender, EventArgs e) { if (Utileria.IsEmpty(txtDesc.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DESCRIPCIÓN DEL PROBLEMA", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Utileria.IsEmpty(txtSol.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA SOLUCIÓN DEL PROBLEMA", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Utileria.IsEmpty(txtTime.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL TIEMPO DE SOLUCIÓN DEL PROBLEMA", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } string strComando = "INSERT INTO PROBLEMAS_CONOCIDOS(Descripcion,Solucion,Tiempo)"; strComando += " VALUES(@Descripcion,@Solucion,@Tiempo)"; SqlCommand Insert = new SqlCommand(strComando, Connection); Insert.Parameters.AddWithValue("@Descripcion", txtDesc.Text); Insert.Parameters.AddWithValue("@Solucion", txtSol.Text); Insert.Parameters.AddWithValue("@Tiempo", txtTime.Text); try { Insert.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return; } MessageBox.Show("SOLUCION A PROBLEMA CONOCIDO AGREGADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); Connection.Close(); }
private void btnGuardar_Click(object sender, EventArgs e) { DialogResult Result = MessageBox.Show("¿DESEA AGREGAR ESTE ELEMENTO?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.No) { return; } int IDCI = 0; if (Utileria.IsEmpty(txtDescripcion.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DESCRIPCION", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComandoC = "SELECT ID FROM CI WHERE NumSerie LIKE '" + lbl.Text + "'"; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { IDCI = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); AdmIn.AddInCI(txtDescripcion.Text, maskDate.Text, IDCI, Tipo, IDEmp); }
private void frmBajaEmpleado_Load(object sender, EventArgs e) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string NA = "", EM = "", CE = "", DI = "", RO = ""; string strComandoC = "SELECT E.Nombre,Email,Celular,Direccion,R.Nombre FROM EMPLEADO E INNER JOIN ROL R ON E.ID_Rol=R.ID WHERE Estatus=1"; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { NA = Lector.GetValue(0).ToString(); EM = Lector.GetValue(1).ToString(); CE = Lector.GetValue(2).ToString(); DI = Lector.GetValue(3).ToString(); RO = Lector.GetValue(3).ToString(); ListViewItem Registro = new ListViewItem(NA); Registro.SubItems.Add(EM); Registro.SubItems.Add(CE); Registro.SubItems.Add(DI); Registro.SubItems.Add(RO); lvEmpleados.Items.Add(Registro); } } Connection.Close(); }
private void btnAprobar_Click(object sender, EventArgs e) { if (lvIndicencias.SelectedItems.Count == 0) { MessageBox.Show("NO HA SELECCIONADO NINGUNA INCIDENCIA", "SIN SELECCIONAR", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else { int PrioID = 0, Stat = 3; SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComandoC = "SELECT ID FROM PRIORIDAD WHERE Descripcion LIKE '" + cmbPrioridad.SelectedItem.ToString() + "'"; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { PrioID = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); AdmIn.UpdatePrioridad(InID, PrioID); AdmIn.UpdateStatus(InID, Stat); MessageBox.Show("INCIDENCIA APROBADA EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void frmVerProblemasConocidos_Load(object sender, EventArgs e) { SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection2 == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector2 = null; string ID = "", DE = "", SO = "", TM = ""; string strComandoC2 = "SELECT * FROM PROBLEMAS_CONOCIDOS"; Lector2 = UsoBD.Consulta(strComandoC2, Connection2); if (Lector2 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection2.Close(); return; } if (Lector2.HasRows) { while (Lector2.Read()) { ID = Lector2.GetValue(0).ToString(); DE = Lector2.GetValue(1).ToString(); SO = Lector2.GetValue(2).ToString(); TM = Lector2.GetValue(3).ToString(); ListViewItem Registro = new ListViewItem(ID); Registro.SubItems.Add(DE); Registro.SubItems.Add(SO); Registro.SubItems.Add(TM); lvInci.Items.Add(Registro); } } Connection2.Close(); }
private void frmAutorizaCambios_Load(object sender, EventArgs e) { SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection2 == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector2 = null; string FE = "", IN = "", DE = "", ID = ""; string strComandoC2 = "SELECT C.ID,I.Descripcion,C.Descripcion,C.FechaSol FROM CAMBIOS C INNER JOIN INCIDENCIA I ON C.IDInc=I.ID WHERE C.Estatus=1 ORDER BY C.FechaSol "; Lector2 = UsoBD.Consulta(strComandoC2, Connection2); if (Lector2 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection2.Close(); return; } if (Lector2.HasRows) { while (Lector2.Read()) { ID = Lector2.GetValue(0).ToString(); IN = Lector2.GetValue(1).ToString(); DE = Lector2.GetValue(2).ToString(); FE = Lector2.GetValue(3).ToString(); ListViewItem Registro = new ListViewItem(ID); Registro.SubItems.Add(IN); Registro.SubItems.Add(DE); Registro.SubItems.Add(FE); lvCam.Items.Add(Registro); } } Connection2.Close(); }
private void btnActualizar_Click(object sender, EventArgs e) { string Dep = cmbDepartamentos.SelectedItem.ToString(); int DepID = AdmDep.GetID(Dep); string Nom = txtNombre.Text; if (!(Utileria.IsEmpty(Nom))) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } string strComando = "UPDATE DEPARTAMENTO SET Nombre=@Nombre WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@Nombre", Nom); Update.Parameters.AddWithValue("@ID", DepID); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return; } Connection.Close(); } if (cmbEncargado.SelectedIndex >= 0) { string Enc = cmbEncargado.SelectedItem.ToString(); int EncID = AdmEmp.GetIDByName(Enc); AdmDep.UpdateEnc(EncID, DepID); } MessageBox.Show("DEPARTAMENTO ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnSelectTec_Click(object sender, EventArgs e) { int ID = 0; for (int i = 0; i < lvInci.Items.Count; i++) { if (lvInci.SelectedItems.Contains(lvInci.Items[i])) { ID = Convert.ToInt32(lvInci.Items[i].SubItems[0].Text); SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComandoC = "SELECT Descripcion,Solucion,Tiempo FROM PROBLEMAS_CONOCIDOS WHERE ID=" + ID; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { txtDesc.Text = Lector.GetValue(0).ToString(); txtSol.Text = Lector.GetValue(1).ToString(); txtTime.Text = Lector.GetValue(2).ToString(); } } Connection.Close(); } } }
public bool AddCI(string Nombre, string Descripcion, string NumSerie, string FechaAdqui, int LocID, int EncaID, int ProvID) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return(false); } string strComando = "INSERT INTO CI(Nombre,Descripcion,NumSerie,FechaAdquisicion,ID_Localizacion,ID_Encargado,ID_Proveedor,Estatus)"; strComando += " VALUES(@Nombre,@Descripcion,@NumSerie,@FechaAdqui,@LocID,@EncaID,@ProvID,@Estatus)"; SqlCommand Insert = new SqlCommand(strComando, Connection); Insert.Parameters.AddWithValue("@Nombre", Nombre.Trim()); Insert.Parameters.AddWithValue("@Descripcion", Descripcion.Trim()); Insert.Parameters.AddWithValue("@NumSerie", NumSerie.Trim()); Insert.Parameters.AddWithValue("@FechaAdqui", FechaAdqui.Trim()); Insert.Parameters.AddWithValue("@LocID", LocID); Insert.Parameters.AddWithValue("@EncaID", EncaID); Insert.Parameters.AddWithValue("@ProvID", ProvID); Insert.Parameters.AddWithValue("@Estatus", 1); try { Insert.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return(false); } MessageBox.Show("ELEMENTO AGREGADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); Connection.Close(); AddUpCI(Nombre, Descripcion, NumSerie, FechaAdqui, LocID, EncaID, ProvID); return(true); }
private void btnGuardar_Click(object sender, EventArgs e) { if (Utileria.IsEmpty(txtCambio.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DESCRIPCION DE LA SOLICITUD DEL CAMBIO", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } string strComando = "INSERT INTO CAMBIOS(IDInc,Descripcion,FechaSol,Estatus)"; strComando += " VALUES(@Inc,@Desc,@Fec,@Est)"; SqlCommand Insert = new SqlCommand(strComando, Connection); Insert.Parameters.AddWithValue("@Inc", IDInc); Insert.Parameters.AddWithValue("@Desc", txtCambio.Text); Insert.Parameters.AddWithValue("@Fec", maskDate.Text); Insert.Parameters.AddWithValue("@Est", 1); try { Insert.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return; } MessageBox.Show("CAMBIO SOLICITADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); Connection.Close(); }
private void frmActualizacionCI_Load(object sender, EventArgs e) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComando = "SELECT CI.IDCI,CI.Nombre,CI.Descripcion,CI.NumSerie,CI.FechaAdquisicion,E.Nombre,EM.Nombre,P.Nombre,CI.Estatus FROM CAMBIOS_CI CI INNER JOIN LOCALIZACION L ON CI.ID_Localizacion = L.ID INNER JOIN EDIFICIO E ON L.ID_Edificio = E.ID INNER JOIN EMPLEADO EM ON CI.ID_Encargado = EM.ID INNER JOIN PROVEEDOR P ON CI.ID_Proveedor = P.ID"; Lector = UsoBD.Consulta(strComando, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { string Estatus = "Activo"; if (Lector.GetValue(8).ToString() == "False") { Estatus = "Inactivo"; } this.dgwCI.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString(), Lector.GetValue(3).ToString(), Lector.GetValue(4).ToString(), Lector.GetValue(5).ToString(), Lector.GetValue(6).ToString(), Lector.GetValue(7).ToString(), Estatus); } } Connection.Close(); }
public bool AddInRed(string Descripcion, string FechaInicio, string Ubicacion, int ID_Tipo, int IDEmp) { int ID_Stat = 2; SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return(false); } string strComando = "INSERT INTO INCIDENCIA(Descripcion,FechaInicio,ID_Stat,ID_Tipo,Ubicacion,ID_Usuario)"; strComando += " VALUES(@Descripcion,@FechaInicio,@ID_Stat,@ID_Tipo,@Ubicacion,@ID_Usuario)"; SqlCommand Insert = new SqlCommand(strComando, Connection); Insert.Parameters.AddWithValue("@Descripcion", Descripcion.Trim()); Insert.Parameters.AddWithValue("@FechaInicio", FechaInicio.Trim()); Insert.Parameters.AddWithValue("@ID_Stat", ID_Stat); Insert.Parameters.AddWithValue("@ID_Tipo", ID_Tipo); Insert.Parameters.AddWithValue("@Ubicacion", Ubicacion.Trim()); Insert.Parameters.AddWithValue("@ID_Usuario", IDEmp); try { Insert.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return(false); } MessageBox.Show("INCIDENCIA DE RED REPORTADA EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); Connection.Close(); return(true); }
public bool AddEmp(string Nombre, string Email, string Celular, string Direc, int Rol) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); string Pass = "******"; if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return(false); } string strComando = "INSERT INTO EMPLEADO(Nombre,Email,Celular,Direccion,ID_Rol,Contraseña,Estatus)"; strComando += " VALUES(@Nombre, @Email, @Celular, @Direc, @Rol, @Contraseña, @Estatus)"; SqlCommand Insert = new SqlCommand(strComando, Connection); Insert.Parameters.AddWithValue("@Nombre", Nombre.Trim()); Insert.Parameters.AddWithValue("@Email", Email.Trim()); Insert.Parameters.AddWithValue("@Celular", Celular.Trim()); Insert.Parameters.AddWithValue("@Direc", Direc.Trim()); Insert.Parameters.AddWithValue("@Rol", Rol); Insert.Parameters.AddWithValue("@Contraseña", Pass); Insert.Parameters.AddWithValue("@Estatus", 1); try { Insert.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return(false); } Connection.Close(); return(true); }
private void frmBajaDepartamento_Load(object sender, EventArgs e) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string NA = "", EN = ""; string strComandoC = "SELECT D.Nombre,E.Nombre FROM DEPARTAMENTO D INNER JOIN EMPLEADO E ON D.ID_EmpEncar=E.ID AND D.Estatus=1"; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { NA = Lector.GetValue(0).ToString(); EN = Lector.GetValue(1).ToString(); ListViewItem Registro = new ListViewItem(NA); Registro.SubItems.Add(EN); lvDepartamentos.Items.Add(Registro); } } Connection.Close(); }
private void btnSelectTec_Click(object sender, EventArgs e) { for (int i = 0; i < lvTecnicos.Items.Count; i++) { if (lvTecnicos.SelectedItems.Contains(lvTecnicos.Items[i])) { txtTecnico.Text = lvTecnicos.Items[i].SubItems[0].Text; SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComandoC = "SELECT ID FROM EMPLEADO WHERE Nombre LIKE '" + txtTecnico.Text.Trim() + "'"; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { TecID = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); } } }
private void frmSolicitaCambio_Load(object sender, EventArgs e) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComandoC = "SELECT Descripcion, ID_Stat, Tiempo_Respuesta FROM INCIDENCIA WHERE ID_Tecnico=" + IDEmp; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { if (!(Utileria.IsEmpty(Lector.GetValue(2).ToString()))) { if (Lector.GetValue(1).ToString() != "1" && Lector.GetValue(1).ToString() != "5") { cmbInc.Items.Add(Lector.GetValue(0).ToString()); } } } } Connection.Close(); }
private void Cargar() { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } } SqlDataReader Lector = null; string strComandoC = "SELECT E.Nombre,R.Nombre,ND.Nombre,E.Email,E.Celular,E.Direccion FROM EMPLEADO E " + "INNER JOIN EMPLEADO_DEPTO D ON E.ID = D.ID_Empleado " + "INNER JOIN DEPARTAMENTO ND ON D.ID_Depto = ND.ID " + "INNER JOIN ROL R ON E.ID_Rol = R.ID WHERE E.ID =" + IDEmp; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); } if (Lector.HasRows) { while (Lector.Read()) { lblNombre.Text = Lector.GetValue(0).ToString(); lblRol.Text = Lector.GetValue(1).ToString(); lblDepto.Text = Lector.GetValue(2).ToString(); lblEmail.Text = Lector.GetValue(3).ToString(); lblNumCel.Text = Lector.GetValue(4).ToString(); lblDir.Text = Lector.GetValue(5).ToString(); } } Connection.Close(); }
public bool AddDepto(string Nombre, int Encargado) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return(false); } string strComando = "INSERT INTO DEPARTAMENTO(Nombre,ID_EmpEncar,Estatus)"; strComando += " VALUES(@Nombre, @Encargado,@Estatus)"; SqlCommand Insert = new SqlCommand(strComando, Connection); Insert.Parameters.AddWithValue("@Nombre", Nombre.Trim()); Insert.Parameters.AddWithValue("@Encargado", Encargado); Insert.Parameters.AddWithValue("@Estatus", 1); try { Insert.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return(false); } Connection.Close(); return(true); }
private void cmbEncargado_SelectedIndexChanged(object sender, EventArgs e) { int ID = AdmEmp.GetIDName(cmbEncargado.SelectedItem.ToString()); SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } } SqlDataReader Lector = null; string strComandoC = "SELECT E.Nombre,E.Celular,E.Email,E.Direccion,D.Nombre FROM EMPLEADO E INNER JOIN EMPLEADO_DEPTO ED ON E.ID=ED.ID_Empleado INNER JOIN DEPARTAMENTO D ON D.ID=ED.ID_Depto WHERE E.ID=" + ID; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); } if (Lector.HasRows) { while (Lector.Read()) { txtNombre.Text = Lector.GetValue(0).ToString(); txtNumCel.Text = Lector.GetValue(1).ToString(); txtEmail.Text = Lector.GetValue(2).ToString(); txtDir.Text = Lector.GetValue(3).ToString(); lblRol.Text = AdmEmp.GetRol(ID); lblDep.Text = Lector.GetValue(4).ToString(); } } Connection.Close(); }
private void btnActualizar_Click(object sender, EventArgs e) { if (!(Utileria.IsEmpty(txtTiempo.Text))) { string Time = txtTiempo.Text; SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } string strComando = "UPDATE INCIDENCIA SET Tiempo_Respuesta=@Tiempo_Respuesta WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@Tiempo_Respuesta", Time); Update.Parameters.AddWithValue("@ID", InID); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return; } Connection.Close(); MessageBox.Show("TIEMPO DE RESPUESTA ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void frmMisSolicitudesCambio_Load(object sender, EventArgs e) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComando = "SELECT I.Descripcion,C.Descripcion,E.Descripcion,C.FechaSol,FechaTer,C.Comentario FROM CAMBIOS C INNER JOIN INCIDENCIA I ON C.IDInc=I.ID INNER JOIN ESTATUS_CAMBIO E ON C.Estatus=E.ID WHERE I.ID_Tecnico=" + UsID; Lector = UsoBD.Consulta(strComando, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { this.dgwCI.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString(), Lector.GetValue(3).ToString(), Lector.GetValue(4).ToString(), Lector.GetValue(5).ToString()); } } Connection.Close(); }
private void frmRetroalimentacion_Load(object sender, EventArgs e) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComando = "SELECT I.ID, I.Descripcion, T.Descripcion, I.FechaInicio,I.FechaTerminacion, I.Tiempo_Respuesta,I.Califiacion,I.Comentario FROM INCIDENCIA I INNER JOIN TIPO_INCIDENCIA T ON I.ID_Tipo=T.ID WHERE I.ID_Tecnico=" + TecID; Lector = UsoBD.Consulta(strComando, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { this.dgvIncidencias.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString(), Lector.GetValue(3).ToString(), Lector.GetValue(4).ToString(), Lector.GetValue(5).ToString(), Lector.GetValue(6).ToString(), Lector.GetValue(7).ToString()); } } Connection.Close(); }
private void frmConsultaEmpleado_Load(object sender, EventArgs e) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComando = "SELECT E.Nombre,Email,Celular,Direccion,R.Nombre,D.Nombre FROM EMPLEADO E INNER JOIN ROL R ON E.ID_Rol=R.ID INNER JOIN EMPLEADO_DEPTO ED ON E.ID=ED.ID_Empleado INNER JOIN DEPARTAMENTO D ON D.ID=ED.ID_Depto AND E.Estatus=1 ORDER BY E.Nombre"; Lector = UsoBD.Consulta(strComando, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { this.dgwEmpleado.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString(), Lector.GetValue(3).ToString(), Lector.GetValue(4).ToString(), Lector.GetValue(5).ToString()); } } Connection.Close(); }
private void cmbNumCI_SelectedIndexChanged(object sender, EventArgs e) { string Nom = cmbNumCI.SelectedItem.ToString(); SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComandoC = "SELECT NumSerie FROM CI WHERE Nombre LIKE '" + Nom + "'"; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { lbl.Text = Lector.GetValue(0).ToString(); } } Connection.Close(); }
private void frmConsultaDepartamento_Load(object sender, EventArgs e) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return; } SqlDataReader Lector = null; string strComando = "SELECT D.Nombre,E.Nombre FROM DEPARTAMENTO D INNER JOIN EMPLEADO E ON D.ID_EmpEncar=E.ID AND D.Estatus=1 ORDER BY D.Nombre"; Lector = UsoBD.Consulta(strComando, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return; } if (Lector.HasRows) { while (Lector.Read()) { this.dgwDepartamento.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString()); } } Connection.Close(); }
public string EncDep(int ID) { string Enc = ""; SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return(Enc); } SqlDataReader Lector = null; string strComandoC = "SELECT E.NOMBRE FROM DEPARTAMENTO D INNER JOIN EMPLEADO E ON D.ID_EmpEncar=E.ID WHERE D.ID=" + ID; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return(Enc); } if (Lector.HasRows) { while (Lector.Read()) { Enc = Lector.GetValue(0).ToString(); } } Connection.Close(); return(Enc); }
public string GetIDNameByCI(string NumSerie) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); string Name = ""; if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return(Name); } SqlDataReader Lector = null; string strComandoC = "SELECT E.Nombre FROM EMPLEADO E INNER JOIN CI ON E.ID = CI.ID_Encargado WHERE CI.NumSerie LIKE'" + NumSerie + "'"; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return(Name); } if (Lector.HasRows) { while (Lector.Read()) { Name = Lector.GetValue(0).ToString(); } } Connection.Close(); return(Name); }
public string GetRol(int ID) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); string Rol = ""; if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return(Rol); } SqlDataReader Lector = null; string strComandoC = "SELECT R.Nombre FROM EMPLEADO E INNER JOIN ROL R ON E.ID_Rol = R.ID WHERE E.ID =" + ID; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return(Rol); } if (Lector.HasRows) { while (Lector.Read()) { Rol = Lector.GetValue(0).ToString(); } } Connection.Close(); return(Rol); }
public int GetIDName(string Name) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); int ID = 0; if (Connection == null) { MessageBox.Show("ERROR DE CONEXIÓN CON LA BASE DE DATOS"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } return(ID); } SqlDataReader Lector = null; string strComandoC = "SELECT ID FROM EMPLEADO WHERE Nombre LIKE'" + Name.Trim() + "'"; Lector = UsoBD.Consulta(strComandoC, Connection); if (Lector == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection.Close(); return(ID); } if (Lector.HasRows) { while (Lector.Read()) { ID = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); return(ID); }