public int GetPlanta(string NumSerie) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); int num = 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(num); } SqlDataReader Lector = null; string strComandoC = "SELECT L.NumPlanta FROM CI INNER JOIN LOCALIZACION L ON CI.ID = L.ID WHERE 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(num); } if (Lector.HasRows) { while (Lector.Read()) { num = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); return(num); }
public int GetID(string Num) { 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 CI WHERE NumSerie LIKE '" + Num.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); }
public string GetFecha(string NumSerie) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); string Date = ""; 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(Date); } SqlDataReader Lector = null; string strComandoC = "SELECT FechaAdquisicion FROM CI WHERE 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(Date); } if (Lector.HasRows) { while (Lector.Read()) { Date = Lector.GetValue(0).ToString(); } } Connection.Close(); return(Date); }
public string GetDescUbi(string NumSerie) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); string Des = ""; 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(Des); } SqlDataReader Lector = null; string strComandoC = "SELECT L.Ubicacion FROM CI INNER JOIN LOCALIZACION L ON CI.ID_Localizacion = L.ID WHERE NumSerie LIKE '" + NumSerie.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(Des); } if (Lector.HasRows) { while (Lector.Read()) { Des = Lector.GetValue(0).ToString(); } } Connection.Close(); return(Des); }
public string GetNombreByCI(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 P.Nombre FROM PROVEEDOR P INNER JOIN CI ON P.ID = CI.ID_Proveedor 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); }
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; } if (Utileria.IsEmpty(txtDescripcion.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DESCRIPCION DEL PROBLEMA", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Utileria.IsEmpty(txtDescUbicacion.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA UBICACION", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AdmIn.AddInRed(txtDescripcion.Text, maskDate.Text, txtDescUbicacion.Text, Tipo, IDEmp); }
public bool UpdateCel(int ID, string Celular) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); bool Band = false; 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(Band); } string strComando = "UPDATE EMPLEADO SET Celular=@Celular WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@Celular", Celular); Update.Parameters.AddWithValue("@ID", ID); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return(Band); } Connection.Close(); // MessageBox.Show("CAMPO 'NUMERO CELULAR' ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); return(!Band); }
private void frmAltaIncidenciaCI_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 Nombre FROM CI WHERE ID_Encargado=" + 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()) { cmbNumCI.Items.Add(Lector.GetValue(0).ToString()); } } Connection.Close(); }
public bool UpdatePrioridad(int ID, int Pri) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); bool Band = false; 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(Band); } string strComando = "UPDATE INCIDENCIA SET ID_Prioridad=@ID_Prioridad WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@ID_Prioridad", Pri); Update.Parameters.AddWithValue("@ID", ID); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return(Band); } Connection.Close(); // MessageBox.Show("CAMPO PRIORIDAD ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); return(!Band); }
public bool UpdateDate(int ID, string Date) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); bool Band = false; 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(Band); } string strComando = "UPDATE CI SET FechaAdquisicion=@FechaAdquisicion WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@FechaAdquisicion", Date.Trim()); Update.Parameters.AddWithValue("@ID", ID); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return(Band); } Connection.Close(); // MessageBox.Show("CAMPO 'FECHA DE ADQUISICIÓN' ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); return(!Band); }
public bool UpdateEnc(int EncID, int ID) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); bool Band = false; 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(Band); } string strComando = "UPDATE DEPARTAMENTO SET ID_EmpEncar=@ID_EmpEncar WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@ID_EmpEncar", EncID); Update.Parameters.AddWithValue("@ID", ID); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return(Band); } Connection.Close(); return(!Band); }
private void btnAct_Click(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; } string strComando = "UPDATE INCIDENCIA SET FechaTerminacion=@FechaTerminacion WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@FechaTerminacion", maskDate.Text.Trim()); 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(); AdmIn.UpdateStatus(InID, 1); MessageBox.Show("TERMINACION DE LA INCIDENCIA " + InID + " EXITOSA", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void button1_Click(object sender, EventArgs e) { DialogResult Result = MessageBox.Show("¿DESEA AGREGAR ESTE DEPARTAMENTO?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.No) { return; } if (Utileria.IsEmpty(txtNombre.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL NOMBRE DEL DEPARTAMENTO", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int Rol = AdmEmp.GetIDNameByRol(cmbEncargado.SelectedItem.ToString()); if (AdmDept.AddDepto(txtNombre.Text, Rol)) { MessageBox.Show("DEPARTAMENTO AGREGADO EXITOSAMENRE", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void frmEditaPerfil_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); } } SqlDataReader Lector = null; string strComandoC = "SELECT Celular,Direccion FROM EMPLEADO WHERE 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()) { lblNumCel.Text = Lector.GetValue(0).ToString(); lblDir.Text = Lector.GetValue(1).ToString(); } } Connection.Close(); }
public bool CheckPass(string Email, string Pass) { 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); } SqlDataReader Lector = null; string strComandoC = "SELECT Contraseña FROM EMPLEADO WHERE Email LIKE '" + Email + "' AND Contraseña LIKE '" + Pass + "'"; 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(false); } if (Lector.HasRows) { Connection.Close(); return(true); } Connection.Close(); return(false); }
private void frmVerCambios_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 FROM CAMBIOS C INNER JOIN INCIDENCIA I ON C.IDInc=I.ID INNER JOIN ESTATUS_CAMBIO E ON C.Estatus=E.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()) this.dgwCI.Rows.Add(Lector.GetValue(0).ToString(), Lector.GetValue(1).ToString(), Lector.GetValue(2).ToString(), Lector.GetValue(3).ToString(), Lector.GetValue(4).ToString()); } Connection.Close(); }
private void frmEvaluarIncidencia_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 D1 = "", D2 = "", D3 = "", D4 = "", D5 = "", D6 = "", D7 = ""; string strComandoC2 = "SELECT I.ID,I.Descripcion,T.Descripcion,P.Descripcion, I.FechaInicio, I.FechaTerminacion, I.Tiempo_Respuesta, I.Califiacion 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_Stat=1 AND ID_Usuario=" + UsID; 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(7).ToString())) { D1 = Lector2.GetValue(0).ToString(); D2 = Lector2.GetValue(1).ToString(); D3 = Lector2.GetValue(2).ToString(); D4 = Lector2.GetValue(3).ToString(); D5 = Lector2.GetValue(4).ToString(); D6 = Lector2.GetValue(5).ToString(); D7 = Lector2.GetValue(6).ToString(); ListViewItem Registro = new ListViewItem(D1); Registro.SubItems.Add(D2); Registro.SubItems.Add(D3); Registro.SubItems.Add(D4); Registro.SubItems.Add(D5); Registro.SubItems.Add(D6); Registro.SubItems.Add(D7); lvIndicencias.Items.Add(Registro); } } } Connection2.Close(); }
private void btnEliminar_Click(object sender, EventArgs e) { if (lvCI.SelectedItems.Count == 0) { MessageBox.Show("NO HA SELECCIONADO NINGUN ELEMENTO", "SIN SELECCIONAR", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult R = MessageBox.Show("¿DESEA ELIMINAR EL CI SELECCIONADO?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (R == DialogResult.Yes) { string NU = ""; for (int i = 0; i < lvCI.Items.Count; i++) { if (lvCI.SelectedItems.Contains(lvCI.Items[i])) { NU = lvCI.Items[i].SubItems[2].Text; int IDCI = AdmCI.GetID(NU); AdmCI.UpdateEstatus(IDCI); if (true) { SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector3 = null; string strComandoC3 = "SELECT ID FROM INCIDENCIA I WHERE I.ID_CI=" + IDCI; Lector3 = UsoBD.Consulta(strComandoC3, Connection3); if (Lector3 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection3.Close(); return; } if (Lector3.HasRows) { while (Lector3.Read()) { MessageBox.Show("LA BAJA DEL CI SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information); lvCI.Items[i].Remove(); Connection3.Close(); return; } } Connection3.Close(); } 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 = "DELETE FROM CI WHERE NumSerie LIKE'" + NU + "'"; 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; } Connection.Close(); lvCI.Items[i].Remove(); MessageBox.Show("LA ELIMINACION DEL CI SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } }
private void frmBajaCI_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 = "", DE = "", NUM = "", FE = "", LO = "", EN = "", P = ""; string strComandoC = "SELECT CI.Nombre,CI.Descripcion,CI.NumSerie,CI.FechaAdquisicion,E.Nombre,EM.Nombre,P.Nombre FROM 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 AND CI.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(); DE = Lector.GetValue(1).ToString(); NUM = Lector.GetValue(2).ToString(); FE = Lector.GetValue(3).ToString(); LO = Lector.GetValue(4).ToString(); EN = Lector.GetValue(5).ToString(); P = Lector.GetValue(6).ToString(); ListViewItem Registro = new ListViewItem(NA); Registro.SubItems.Add(DE); Registro.SubItems.Add(NUM); Registro.SubItems.Add(FE); Registro.SubItems.Add(LO); Registro.SubItems.Add(EN); Registro.SubItems.Add(P); lvCI.Items.Add(Registro); } } Connection.Close(); }
private void btnActualizar_Click(object sender, EventArgs e) { DialogResult Result = MessageBox.Show("¿DESEA GUARDAR LOS CAMBIOS?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.No) { return; } string Nombre = cmbNombre.SelectedItem.ToString(); string NumSerie = AdmCI.GetNumSerie(Nombre); int ID = AdmCI.GetID(NumSerie); if (!(Utileria.IsEmpty(txtDescripcion.Text))) { AdmCI.UpdateDesc(ID, txtDescripcion.Text); } if (!(Utileria.IsEmpty(maskDate.Text))) { AdmCI.UpdateDate(ID, maskDate.Text); } if (!(Utileria.IsEmpty(txtUbicacion.Text))) { int LocID = AdmCI.GetIDLoc(NumSerie.Trim()); 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 LOCALIZACION SET Nombre=@Nombre WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@Nombre", txtUbicacion.Text); Update.Parameters.AddWithValue("@ID", LocID); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return; } Connection.Close(); //MessageBox.Show("CAMPO 'NOMBRE DE LA UBICACIÓN' ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (!(Utileria.IsEmpty(txtDescUbicacion.Text))) { int LocID = AdmCI.GetIDLoc(NumSerie.Trim()); 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 LOCALIZACION SET Ubicacion=@Ubicacion WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@Ubicacion", txtDescUbicacion.Text); Update.Parameters.AddWithValue("@ID", LocID); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return; } Connection.Close(); //MessageBox.Show("CAMPO 'DESCRIPCION DE LA UBICACIÓN' ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (cmbProveedor.SelectedIndex >= 0) { string Prov = cmbProveedor.SelectedItem.ToString(); int IDPro = AdmProv.GetID(Prov); int IDCI = AdmCI.GetID(NumSerie); 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; } string strComando2 = "UPDATE CI SET ID_Proveedor=@ID_Proveedor WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando2, Connection2); Update.Parameters.AddWithValue("@ID_Proveedor", IDPro); Update.Parameters.AddWithValue("@ID", IDCI); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection2.Close(); return; } Connection2.Close(); } if (cmbEncargado.SelectedIndex >= 0) { string Enc = cmbEncargado.SelectedItem.ToString(); int IDEm = AdmEmp.GetIDByName(Enc); int IDCI = AdmCI.GetID(NumSerie); 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; } string strComando2 = "UPDATE CI SET ID_Encargado=@ID_Encargado WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando2, Connection2); Update.Parameters.AddWithValue("@ID_Encargado", IDEm); Update.Parameters.AddWithValue("@ID", IDCI); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection2.Close(); return; } Connection2.Close(); } if (cmbEdificio.SelectedIndex >= 0) { string Ed = cmbEdificio.SelectedItem.ToString(); int IDLoc = AdmCI.GetIDLoc(NumSerie); int IDEd = 0; 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 EDIFICIO WHERE Nombre LIKE '" + Ed + "'"; 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()) { IDEd = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); 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; } string strComando2 = "UPDATE LOCALIZACION SET ID_Edificio=@ID_Edificio WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando2, Connection2); Update.Parameters.AddWithValue("@ID_Edificio", IDEd); Update.Parameters.AddWithValue("@ID", IDLoc); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection2.Close(); return; } Connection2.Close(); } if (nudPlanta.Value >= 1) { int num = Convert.ToInt32(nudPlanta.Value); int IDLoc = AdmCI.GetIDLoc(NumSerie); 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; } string strComando2 = "UPDATE LOCALIZACION SET NumPlanta=@NumPlanta WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando2, Connection2); Update.Parameters.AddWithValue("@NumPlanta", num); Update.Parameters.AddWithValue("@ID", IDLoc); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection2.Close(); return; } Connection2.Close(); } MessageBox.Show("ELEMENTO DE CONFIGURACION ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void frmAltaCI_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 Nombre FROM EMPLEADO 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()) { cmbEncargado.Items.Add(Lector.GetValue(0).ToString()); } } Connection.Close(); SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector2 = null; string strComandoC2 = "SELECT Nombre FROM PROVEEDOR"; 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()) { cmbProveedor.Items.Add(Lector2.GetValue(0).ToString()); } } Connection2.Close(); SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector3 = null; string strComandoC3 = "SELECT Nombre FROM EDIFICIO"; Lector3 = UsoBD.Consulta(strComandoC3, Connection3); if (Lector3 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection3.Close(); return; } if (Lector3.HasRows) { while (Lector3.Read()) { cmbEdificio.Items.Add(Lector3.GetValue(0).ToString()); } } Connection3.Close(); }
private void button1_Click(object sender, EventArgs e) { DialogResult Result = MessageBox.Show("¿DESEA AGREGAR ESTE ELEMENTO?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.No) { return; } if (Utileria.IsEmpty(txtNombre.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL NOMBRE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Utileria.IsEmpty(txtDescripcion.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DESCRIPCIÓN", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Utileria.IsEmpty(txtNumSerie.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL NÚMERO DE SERIE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int Edificio = 0; 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 EDIFICIO WHERE Nombre LIKE '" + cmbEdificio.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()) { Edificio = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); 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; } string strComando = "INSERT INTO LOCALIZACION(Nombre,NumPlanta,ID_Edificio,Ubicacion)"; strComando += " VALUES(@Nombre,@NumPlanta,@ID_Edificio,@Ubicacion)"; SqlCommand Insert = new SqlCommand(strComando, Connection2); Insert.Parameters.AddWithValue("@Nombre", txtUbicacion.Text.Trim()); Insert.Parameters.AddWithValue("@NumPlanta", nudPlanta.Text); Insert.Parameters.AddWithValue("@ID_Edificio", Edificio); Insert.Parameters.AddWithValue("@Ubicacion", txtDescUbicacion.Text.Trim()); try { Insert.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection2.Close(); return; } Connection2.Close(); int Loc = 0; SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection3 == 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 strComando2 = "SELECT ID FROM LOCALIZACION WHERE Ubicacion LIKE '" + txtDescUbicacion.Text.Trim() + "'"; Lector2 = UsoBD.Consulta(strComando2, Connection3); if (Lector2 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection3.Close(); return; } if (Lector2.HasRows) { while (Lector2.Read()) { Loc = Convert.ToInt32(Lector2.GetValue(0).ToString()); } } Connection3.Close(); int Enc = AdmEmp.GetIDByName(cmbEncargado.SelectedItem.ToString()); int Pov = AdmPro.GetID(cmbProveedor.SelectedItem.ToString()); AdmCI.AddCI(txtNombre.Text, txtDescripcion.Text, txtNumSerie.Text, maskDate.Text, Loc, Enc, Pov); }
private void btnAprobar_Click(object sender, EventArgs e) { if (Utileria.IsEmpty(txtCom.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL COMENTARIO A LA RESPUESTA 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 = "UPDATE CAMBIOS SET Comentario=@Comentario WHERE ID=@ID"; SqlCommand Update = new SqlCommand(strComando, Connection); Update.Parameters.AddWithValue("@Comentario", txtCom.Text); Update.Parameters.AddWithValue("@ID", IDCam); try { Update.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); return; } Connection.Close(); // 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; } string strComando2 = "UPDATE CAMBIOS SET FechaTer=@FechaTer WHERE ID=@ID"; SqlCommand Update2 = new SqlCommand(strComando2, Connection2); Update2.Parameters.AddWithValue("@FechaTer", maskDate.Text); Update2.Parameters.AddWithValue("@ID", IDCam); try { Update2.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection2.Close(); return; } Connection2.Close(); // SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection3 == 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 strComando3 = "UPDATE CAMBIOS SET Estatus=@Estatus WHERE ID=@ID"; SqlCommand Update3 = new SqlCommand(strComando3, Connection3); Update3.Parameters.AddWithValue("@Estatus", 2); Update3.Parameters.AddWithValue("@ID", IDCam); try { Update3.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection3.Close(); return; } Connection3.Close(); MessageBox.Show("CAMBIO APROBADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnAgregar_Click(object sender, EventArgs e) { DialogResult Result = MessageBox.Show("¿DESEA AGREGAR ESTE EMPLEADO?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.No) { return; } if (Utileria.IsEmpty(txtNombre.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL NOMBRE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Utileria.IsEmpty(txtEmail.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN EL EMAIL", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Utileria.IsEmpty(txtDireccion.Text)) { MessageBox.Show("NO SE ACEPTAN CAMPOS VACIOS EN LA DIRECCION", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (Utileria.ValidaTextoNum(txtCelular.Text)) { MessageBox.Show("EN ESTE CAMPO SOLO SE ACEPTAN NUMEROS", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int Rol = AdmEmp.GetIDByNameRol(cmbRol.SelectedItem.ToString()); if (AdmEmp.AddEmp(txtNombre.Text, txtEmail.Text, txtCelular.Text, txtDireccion.Text, Rol)) { MessageBox.Show("EMPLEADO AGREGADO EXITOSAMENRE", "INFORMACION", MessageBoxButtons.OK, MessageBoxIcon.Information); } int DepID = AdmDepto.GetID(cmbDepto.SelectedItem.ToString()); int EmpID = AdmEmp.GetIDByName(txtNombre.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 = "INSERT INTO EMPLEADO_DEPTO(ID_Empleado,ID_Depto)"; strComando += " VALUES(@ID_Empleado, @ID_Depto)"; SqlCommand Insert = new SqlCommand(strComando, Connection); Insert.Parameters.AddWithValue("@ID_Empleado", EmpID); Insert.Parameters.AddWithValue("@ID_Depto", DepID); try { Insert.ExecuteNonQuery(); } catch (SqlException Ex) { foreach (SqlError item in Ex.Errors) { MessageBox.Show(item.Message); } Connection.Close(); } Connection.Close(); }
private void frmAltaEmpleado_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 Nombre FROM ROL"; 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()) { cmbRol.Items.Add(Lector.GetValue(0).ToString()); } } Connection.Close(); SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector2 = null; string strComandoC2 = "SELECT Nombre FROM DEPARTAMENTO WHERE Estatus=1"; 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()) { cmbDepto.Items.Add(Lector2.GetValue(0).ToString()); } } Connection2.Close(); }
private void btnSelect_Click(object sender, EventArgs e) { for (int i = 0; i < lvIndicencias.Items.Count; i++) { if (lvIndicencias.SelectedItems.Contains(lvIndicencias.Items[i])) { InID = Convert.ToInt32(lvIndicencias.Items[i].SubItems[0].Text); int Tipo = 0, CI = 0; 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_Tipo FROM INCIDENCIA WHERE ID =" + InID; 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()) { Tipo = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); if (Tipo == 1) { string UB = "", NP = ""; 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 strComandoC2 = "SELECT CI.ID,I.ID_Tipo,CI.Nombre+', CON NUMERO DE SERIE: '+CI.NumSerie+', '+CI.Descripcion FROM INCIDENCIA I INNER JOIN CI ON I.ID_CI=CI.ID WHERE I.ID=" + InID; 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()) { CI = Convert.ToInt32(Lector2.GetValue(0).ToString()); if (Lector2.GetValue(1).ToString() == "1") { txtCI.Text = Lector2.GetValue(2).ToString(); } } } Connection2.Close(); SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection3 == 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 Lector3 = null; string strComandoC3 = "SELECT 'EDIFICIO: '+E.Nombre+', '+E.Ubicacion+'. '+L.Nombre+', '+L.Ubicacion+', PLANTA: ' FROM INCIDENCIA I INNER JOIN CI ON I.ID_CI=CI.ID INNER JOIN LOCALIZACION L ON CI.ID_Localizacion=L.ID INNER JOIN EDIFICIO E ON L.ID_Edificio=E.ID WHERE CI.ID=" + CI; Lector3 = UsoBD.Consulta(strComandoC3, Connection3); if (Lector3 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection3.Close(); return; } if (Lector3.HasRows) { while (Lector3.Read()) { UB = Lector3.GetValue(0).ToString(); } } Connection3.Close(); SqlConnection Connection4 = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection4 == 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 Lector4 = null; string strComandoC4 = "SELECT L.NumPlanta FROM INCIDENCIA I INNER JOIN CI ON I.ID_CI=CI.ID INNER JOIN LOCALIZACION L ON CI.ID_Localizacion=L.ID WHERE CI.ID=" + CI; Lector4 = UsoBD.Consulta(strComandoC4, Connection4); if (Lector4 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection4.Close(); return; } if (Lector4.HasRows) { while (Lector4.Read()) { NP = Lector4.GetValue(0).ToString(); richTextBox1.Text = UB + NP; } } Connection4.Close(); } else { txtCI.Text = ""; SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); if (Connection3 == 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 Lector3 = null; string strComandoC3 = "SELECT I.Ubicacion,I.ID_Tipo FROM INCIDENCIA I WHERE I.ID=" + InID; Lector3 = UsoBD.Consulta(strComandoC3, Connection3); if (Lector3 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection3.Close(); return; } if (Lector3.HasRows) { while (Lector3.Read()) { richTextBox1.Text = Lector3.GetValue(0).ToString(); if (Lector3.GetValue(1).ToString() == "3") { richTextBox1.Text = ""; } } } Connection3.Close(); } } } }
private void cmbEncargado_SelectedIndexChanged(object sender, EventArgs e) { cmbProveedor.Items.Clear(); cmbEncargado.Items.Clear(); cmbEdificio.Items.Clear(); string Nombre = cmbNombre.SelectedItem.ToString(); string NumSerie = AdmCI.GetNumSerie(Nombre); txtxNumSerie.Text = NumSerie; string Desc = AdmCI.GetDesc(NumSerie); txtDescripcion.Text = Desc; string Ubi = AdmCI.GetUbi(NumSerie); txtUbicacion.Text = Ubi; string DescUb = AdmCI.GetDescUbi(NumSerie); txtDescUbicacion.Text = DescUb; string Fecha = AdmCI.GetFecha(NumSerie); lblDate.Text = Fecha; int Num = AdmCI.GetPlanta(NumSerie); nudPlanta.Value = Num; string Pro = AdmProv.GetNombreByCI(NumSerie); lblProveedor.Text = Pro; string Enc = AdmEmp.GetIDNameByCI(NumSerie); lblEncargado.Text = Enc; int IDCI = AdmCI.GetID(NumSerie); 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 Nombre FROM EMPLEADO 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()) { cmbEncargado.Items.Add(Lector.GetValue(0).ToString()); } } Connection.Close(); SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector2 = null; string strComandoC2 = "SELECT Nombre FROM PROVEEDOR"; 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()) { cmbProveedor.Items.Add(Lector2.GetValue(0).ToString()); } } Connection2.Close(); SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector3 = null; string strComandoC3 = "SELECT Nombre FROM EDIFICIO"; Lector3 = UsoBD.Consulta(strComandoC3, Connection3); if (Lector3 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection3.Close(); return; } if (Lector3.HasRows) { while (Lector3.Read()) { cmbEdificio.Items.Add(Lector3.GetValue(0).ToString()); } } Connection3.Close(); SqlConnection Connection4 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector4 = null; string strComandoC4 = "SELECT E.Nombre FROM CI INNER JOIN LOCALIZACION L ON CI.ID_Localizacion = L.ID INNER JOIN EDIFICIO E ON L.ID_Edificio = E.ID WHERE L.ID_Edificio = E.ID AND CI.ID =" + IDCI + ""; Lector4 = UsoBD.Consulta(strComandoC4, Connection4); if (Lector4 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection4.Close(); return; } if (Lector4.HasRows) { while (Lector4.Read()) { lblEdificio.Text = Lector4.GetValue(0).ToString(); } } Connection4.Close(); }
private void btnActualizar_Click(object sender, EventArgs e) { DialogResult Result = MessageBox.Show("¿DESEA GUARDAR LOS CAMBIOS?", "PREGUNTA", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.No) { return; } int ID = AdmEmp.GetIDName(cmbEncargado.SelectedItem.ToString()); string Nombre = txtNombre.Text; string NumCel = txtNumCel.Text; string Email = txtEmail.Text; string Dir = txtDir.Text; if (!(Utileria.IsEmpty(Nombre))) { AdmEmp.UpdateNom(ID, Nombre); } if (!(Utileria.IsEmpty(NumCel))) { AdmEmp.UpdateCel(ID, NumCel); } if (!(Utileria.IsEmpty(Email))) { AdmEmp.UpdateEmail(ID, Email); } if (!(Utileria.IsEmpty(Dir))) { AdmEmp.UpdateDir(ID, Dir); } if (cmbRol.SelectedIndex >= 0) { SqlConnection Connection = UsoBD.ConectaBD(Utileria.GetConnectionString()); int Rol = 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; } SqlDataReader Lector = null; string strComandoC = "SELECT ID FROM ROL WHERE NOMBRE LIKE '" + cmbRol.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()) { Rol = Convert.ToInt32(Lector.GetValue(0).ToString()); } } Connection.Close(); AdmEmp.UpdateRolID(ID, Rol); } if (cmbDep.SelectedIndex >= 0) { int DepID = AdmDept.GetID(cmbDep.SelectedItem.ToString()); AdmDept.UpdateDep(ID, DepID); } MessageBox.Show("EMPLEADO ACTUALIZADO EXITOSAMENTE", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void btnEliminar_Click(object sender, EventArgs e) { if (lvEmpleados.SelectedItems.Count == 0) { MessageBox.Show("NO HA SELECCIONADO NINGUN EMPLEADO", "SIN SELECCIONAR", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult R = MessageBox.Show("¿DESEA ELIMINAR EL EMPLEADO SELECCIONADO?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (R == DialogResult.Yes) { string NA, EM; for (int i = 0; i < lvEmpleados.Items.Count; i++) { if (lvEmpleados.SelectedItems.Contains(lvEmpleados.Items[i])) { NA = lvEmpleados.Items[i].SubItems[0].Text; EM = lvEmpleados.Items[i].SubItems[1].Text; int EmpID = AdmEmp.GetIDByName(NA); if (true) { SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector3 = null; string strComandoC3 = "SELECT ID FROM DEPARTAMENTO WHERE ID_EmpEncar=" + EmpID; Lector3 = UsoBD.Consulta(strComandoC3, Connection3); if (Lector3 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection3.Close(); return; } if (Lector3.HasRows) { while (Lector3.Read()) { AdmEmp.UpdateEstatus(EmpID); MessageBox.Show("LA BAJA DEL EMPLEADO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information); lvEmpleados.Items[i].Remove(); Connection3.Close(); return; } } Connection3.Close(); SqlConnection Connection4 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector4 = null; string strComandoC4 = "SELECT I.ID FROM INCIDENCIA I WHERE I.ID_Tecnico=" + EmpID; Lector4 = UsoBD.Consulta(strComandoC4, Connection4); if (Lector4 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection4.Close(); return; } if (Lector4.HasRows) { while (Lector4.Read()) { AdmEmp.UpdateEstatus(EmpID); MessageBox.Show("LA BAJA DEL EMPLEADO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information); lvEmpleados.Items[i].Remove(); Connection4.Close(); return; } } Connection4.Close(); SqlConnection Connection5 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector5 = null; string strComandoC5 = "SELECT ID FROM INCIDENCIA WHERE ID_Usuario=" + EmpID; Lector5 = UsoBD.Consulta(strComandoC5, Connection5); if (Lector5 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection5.Close(); return; } if (Lector5.HasRows) { while (Lector5.Read()) { AdmEmp.UpdateEstatus(EmpID); MessageBox.Show("LA BAJA DEL EMPLEADO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information); lvEmpleados.Items[i].Remove(); Connection4.Close(); return; } } Connection4.Close(); } SqlConnection Connection2 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector2 = null; string strComandoC2 = "DELETE FROM EMPLEADO_DEPTO WHERE ID_Empleado=" + EmpID; 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; } Connection2.Close(); 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 = "DELETE FROM EMPLEADO WHERE Nombre LIKE '" + NA + "' AND Email LIKE '" + EM + "'"; 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; } Connection.Close(); lvEmpleados.Items[i].Remove(); MessageBox.Show("LA ELIMINACION DEL EMPLEADO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } }
private void btnEliminar_Click(object sender, EventArgs e) { if (lvDepartamentos.SelectedItems.Count == 0) { MessageBox.Show("NO HA SELECCIONADO NINGUN DEPARTAMENTO", "SIN SELECCIONAR", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } DialogResult R = MessageBox.Show("¿DESEA ELIMINAR EL DEPARTAMENTO SELECCIONADO?", "CONFIRMAR", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (R == DialogResult.Yes) { string NA; for (int i = 0; i < lvDepartamentos.Items.Count; i++) { if (lvDepartamentos.SelectedItems.Contains(lvDepartamentos.Items[i])) { NA = lvDepartamentos.Items[i].SubItems[0].Text; int DepID = AdmDept.GetID(NA); if (true) { SqlConnection Connection3 = UsoBD.ConectaBD(Utileria.GetConnectionString()); SqlDataReader Lector3 = null; string strComandoC3 = "SELECT ID_Empleado FROM EMPLEADO_DEPTO WHERE ID_Depto=" + DepID; Lector3 = UsoBD.Consulta(strComandoC3, Connection3); if (Lector3 == null) { MessageBox.Show("ERROR AL HACER LA CONSULTA"); foreach (SqlError E in UsoBD.ESalida.Errors) { MessageBox.Show(E.Message); } Connection3.Close(); return; } if (Lector3.HasRows) { while (Lector3.Read()) { AdmDept.UpdateEstatus(DepID); MessageBox.Show("LA BAJA DEL DEPARTAMENTO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information); lvDepartamentos.Items[i].Remove(); Connection3.Close(); return; } } Connection3.Close(); } 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 = "DELETE FROM DEPARTAMENTO WHERE Nombre LIKE '" + NA + "'"; 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; } Connection.Close(); lvDepartamentos.Items[i].Remove(); MessageBox.Show("LA ELIMINACION DEL DEPARTAMENTO SE HA REALIZADO CORRECTAMENTE", "ELIMINACION REALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } } }