public List<RutasBE> Eliminarut() { RutasBE rutasBE; List<RutasBE> listaResult = new List<RutasBE>(); Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader rrrutas; comando.CommandText = "DESACTIVA_RUTA"; comando.CommandType = CommandType.StoredProcedure; conexion.Open(); rrrutas = comando.ExecuteReader(); while (rrrutas.Read()) { rutasBE = new RutasBE(); rutasBE.Ruta = rrrutas["RUTA"].ToString(); listaResult.Add(rutasBE); } conexion.Close(); return listaResult; }
public List<GeneroBE> CONSULTAGENERO() { GeneroBE generoBE; List<GeneroBE> listaResult = new List<GeneroBE>(); Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader generos; comando.CommandText = "CONSULTAGENERO"; comando.CommandType = CommandType.StoredProcedure; conexion.Open(); generos = comando.ExecuteReader(); while (generos.Read()) { generoBE = new GeneroBE(); generoBE.IDGENERO = int.Parse(generos["IDGENERO"].ToString()); generoBE.GENERO = generos["GENERO"].ToString(); listaResult.Add(generoBE); } conexion.Close(); return listaResult; }
//public static ConductorBE ObtenerConductor(int pPlaca) //{ // ConductorBE pConductor = new ConductorBE(); // Conexion myConnection = new Conexion(); // SqlConnection conexion = myConnection.CreateConnection(); // SqlCommand comando = new SqlCommand(String.Format("SELECT PLACA, AñO, COLOR, NOMBRES,APELLIDOS, DNI, EDAD, DIRECCION, PROVINCIA FROM CONDUCTOR where PLACA ='{0}'", pPlaca), conexion); // SqlDataReader cconductor; // conexion.Open(); // cconductor = comando.ExecuteReader(); // while (cconductor.Read()) // { // pConductor.Placa = cconductor.GetString(0); // pConductor.Año = cconductor.GetString(1); // pConductor.Color = cconductor.GetString(2); // pConductor.Nombres = cconductor.GetString(3); // pConductor.Apellidos = cconductor.GetString(4); // pConductor.DNI = cconductor.GetString(5); // pConductor.Edad = cconductor.GetString(6); // pConductor.Direccion = cconductor.GetString(7); // pConductor.Provincia = cconductor.GetString(8); // } // conexion.Close(); // return pConductor; //} public bool REGISTRAR_SERVICIO(SolicitudBE solicitud) { bool result = false; try { Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); comando.CommandText = "REGISTRAR_SERVICIO"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("CED_CLIENTE", solicitud.CED_CLIENTE); comando.Parameters.AddWithValue("NOMBRE_CLIENTE", solicitud.NOMBRE_CLIENTE); comando.Parameters.AddWithValue("APELLIDOS_CLIENTE", solicitud.APELLIDOS_CLIENTE); comando.Parameters.AddWithValue("PLACA", solicitud.PLACA); comando.Parameters.AddWithValue("COLOR", solicitud.COLOR); comando.Parameters.AddWithValue("CED_CONDUCTOR", solicitud.CED_CONDUCTOR); comando.Parameters.AddWithValue("NOMBRE_CONDUCTOR", solicitud.NOMBRE_CONDUCTOR); comando.Parameters.AddWithValue("APELLIDO_CONDUCTOR", solicitud.APELLIDO_CONDUCTOR); comando.Parameters.AddWithValue("RUTA", solicitud.RUTA); comando.Parameters.AddWithValue("MONTO", solicitud.MONTO); conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); result = true; } catch (SqlException e) { //insert error in a log result = false; } return result; }
public List<RutasBE> Agregarut() { RutasBE rutasBE; List<RutasBE> listaResult = new List<RutasBE>(); Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader rrutas; comando.CommandText = "REGISTRA_RUTAS"; comando.CommandType = CommandType.StoredProcedure; conexion.Open(); rrutas = comando.ExecuteReader(); while (rrutas.Read()) { rutasBE = new RutasBE(); rutasBE.Ruta = rrutas["RUTA"].ToString(); rutasBE.Distanciakm = rrutas["DISTANCIAKM"].ToString(); rutasBE.Monto = rrutas["MONTO"].ToString(); listaResult.Add(rutasBE); } conexion.Close(); return listaResult; }
//metodos para agregar una ruta--------------------------------------------------------- public bool AgregaRuta(RutasBE RutaAgrega) { bool result = false; try { Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); comando.CommandText = "REGISTRA_RUTAS"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@RUTA", RutaAgrega.Ruta); comando.Parameters.AddWithValue("@DISTANCIAKM", RutaAgrega.Distanciakm); comando.Parameters.AddWithValue("@MONTO", RutaAgrega.Monto); conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); result = true; } catch (SqlException e) { //insert error in a log result = false; } return result; }
public bool AgregaConductor(ConductorBE ConductorBk) { bool result = false; try { Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); comando.CommandText = "REGISTRAR_CONDUCTOR"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@PLACA", ConductorBk.Placa); comando.Parameters.AddWithValue("@AñO", ConductorBk.Año); comando.Parameters.AddWithValue("@COLOR", ConductorBk.Color); comando.Parameters.AddWithValue("@NOMBRES", ConductorBk.Nombres); comando.Parameters.AddWithValue("@APELLIDOS", ConductorBk.Apellidos); comando.Parameters.AddWithValue("@DNI", ConductorBk.DNI); comando.Parameters.AddWithValue("@EDAD", ConductorBk.Edad); comando.Parameters.AddWithValue("@DIRECCION", ConductorBk.Direccion); comando.Parameters.AddWithValue("@PROVINCIA", ConductorBk.Provincia); conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); result = true; } catch (SqlException e) { //insert error in a log result = false; } return result; }
public List<ProvinciaBE> CONSULTAPROVINCIA() { ProvinciaBE provinciaBE; List<ProvinciaBE> listaResulta = new List<ProvinciaBE>(); Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader provincias; comando.CommandText = "CONSULTAPROVINCIA"; comando.CommandType = CommandType.StoredProcedure; conexion.Open(); provincias = comando.ExecuteReader(); while (provincias.Read()) { provinciaBE = new ProvinciaBE(); provinciaBE.IDPROVINCIAS = int.Parse(provincias["IDPROVINCIAS"].ToString()); provinciaBE.PROVINCIA = provincias["PROVINCIA"].ToString(); listaResulta.Add(provinciaBE); } conexion.Close(); return listaResulta; }
public List<SolicitudBE> VER_SERVICIOS() { List<SolicitudBE> listResult = new List<SolicitudBE>(); try { Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader solicitudReader; comando.CommandText = "VER_SERVICIOS"; comando.CommandType = CommandType.StoredProcedure; conexion.Open(); solicitudReader = comando.ExecuteReader(); while (solicitudReader.Read()) { SolicitudBE solicitudBE = new SolicitudBE(); solicitudBE.CED_CLIENTE = solicitudReader["CED_CLIENTE"].ToString(); solicitudBE.NOMBRE_CLIENTE = solicitudReader["NOMBRE_CLIENTE"].ToString(); solicitudBE.APELLIDOS_CLIENTE = solicitudReader["APELLIDOS_CLIENTE"].ToString(); solicitudBE.CED_CONDUCTOR = solicitudReader["CED_CONDUCTOR"].ToString(); solicitudBE.NOMBRE_CONDUCTOR = solicitudReader["NOMBRE_CONDUCTOR"].ToString(); solicitudBE.APELLIDO_CONDUCTOR = solicitudReader["APELLIDO_CONDUCTOR"].ToString(); solicitudBE.COLOR = solicitudReader["COLOR"].ToString(); solicitudBE.PLACA = solicitudReader["PLACA"].ToString(); solicitudBE.MONTO = solicitudReader["MONTO"].ToString(); solicitudBE.RUTA = solicitudReader["RUTA"].ToString(); listResult.Add(solicitudBE); } conexion.Close(); } catch (SqlException e) { //insert error in a log } return listResult; }
public List<ConductorBE> Agregaconduct() { ConductorBE conductorBE; List<ConductorBE> listaResult = new List<ConductorBE>(); Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader cconduct; comando.CommandText = "REGISTRAR_CONDUCTOR"; comando.CommandType = CommandType.StoredProcedure; conexion.Open(); cconduct = comando.ExecuteReader(); while (cconduct.Read()) { conductorBE = new ConductorBE(); conductorBE.Placa = Convert.ToInt32(cconduct["PLACA"]); conductorBE.Año = Convert.ToInt16(cconduct["AñO"]); conductorBE.Color = cconduct["COLOR"].ToString(); conductorBE.Nombres = cconduct["NOMBRES"].ToString(); conductorBE.Apellidos = cconduct["APELLIDOS"].ToString(); conductorBE.DNI = Convert.ToInt16(cconduct["DNI"]); conductorBE.Edad = Convert.ToInt16(cconduct["EDAD"]); conductorBE.Direccion = cconduct["DIRECCION"].ToString(); conductorBE.Provincia = cconduct["PROVINCIA"].ToString(); listaResult.Add(conductorBE); } conexion.Close(); return listaResult; }
private void button1_Click(object sender, EventArgs e) { if (txtnombre.Text == "") { MessageBox.Show("Digite un Nombre para Continuar"); txtnombre.Focus(); } else if (txtapellido.Text == "") { MessageBox.Show("Digite un Apellido para Continuar"); txtapellido.Focus(); } else if (txtcedula.Text == "") { MessageBox.Show("Digite la Cédula para Continuar"); txtcedula.Focus(); } else if (txtdireccion.Text == "") { MessageBox.Show("Digite Direccion para Continuar"); txtdireccion.Focus(); } else if (txtexaminar.Text == "") { MessageBox.Show("Cargue una fotografia para Continuar"); btnbuscarfoto.Focus(); } else { //almacenar////////////////////////////////////////////////////////7 Conexion myconexion = new Conexion(); SqlConnection conexion = myconexion.CreateConnection(); SqlCommand comando = myconexion.CreateCommand(conexion); //pasos FileStream stream = new FileStream(txtexaminar.Text, FileMode.Open, FileAccess.Read); //Se inicailiza un flujo de archivo con la imagen seleccionada desde el disco. BinaryReader br = new BinaryReader(stream); FileInfo fi = new FileInfo(txtexaminar.Text); //Se inicializa un arreglo de Bytes del tamaño de la imagen byte[] binData = new byte[stream.Length]; //Se almacena en el arreglo de bytes la informacion que se obtiene del flujo de archivos(foto) //Lee el bloque de bytes del flujo y escribe los datos en un búfer dado. stream.Read(binData, 0, Convert.ToInt32(stream.Length)); ////Se muetra la imagen obtenida desde el flujo de datos picfoto.Image = Image.FromStream(stream); conexion.Open(); comando.CommandText = "REGISTRAR_CLIENTE"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@NOMBRES", txtnombre.Text.ToString()); comando.Parameters.AddWithValue("@APELLIDOS", txtapellido.Text.ToString()); comando.Parameters.AddWithValue("@DNI", txtcedula.Text.ToString()); comando.Parameters.AddWithValue("@EDAD",numedad.Text.ToString()); comando.Parameters.AddWithValue("@DIRECCION", txtdireccion.Text); comando.Parameters.AddWithValue("@PROVINCIA", cmbprovincia.Text); comando.Parameters.AddWithValue("@GENERO", cmbgenero.Text); comando.Parameters.AddWithValue("@FOTO", binData); int result = comando.ExecuteNonQuery(); if (result > 0) MessageBox.Show("!!!!!DATOS ALMACENADOS CORRECTAMENTE¡¡¡¡¡"); else MessageBox.Show("INSERCIÓN FALLO"); conexion.Close(); txtnombre.Clear(); txtapellido.Clear(); txtdireccion.Clear(); picfoto.Image = null; txtcedula.Clear(); txtnombre.Focus(); } }
//metodos para eliminar un conductor--------------------------------------------------- public bool EliminaConductor(ConductorBE ConductorElimina) { bool result = false; try { Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); comando.CommandText = "BORRAR_CONDUCTOR"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@DNI", ConductorElimina.DNI); conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); result = true; } catch (SqlException e) { //insert error in a log result = false; } return result; }
public List<ConductorBE> Eliminaconduct() { ConductorBE conductorBE; List<ConductorBE> listaResult = new List<ConductorBE>(); Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); SqlDataReader cconduct; comando.CommandText = "BORRAR_CONDUCTOR"; comando.CommandType = CommandType.StoredProcedure; conexion.Open(); cconduct = comando.ExecuteReader(); while (cconduct.Read()) { conductorBE = new ConductorBE(); conductorBE.DNI = cconduct["DNI"].ToString(); listaResult.Add(conductorBE); } conexion.Close(); return listaResult; }
//metodos para eliminar una ruta --------------------------------------------------------------- public bool EliminaRuta(RutasBE RutaElimina) { bool result = false; try { Conexion myConnection = new Conexion(); SqlConnection conexion = myConnection.CreateConnection(); SqlCommand comando = myConnection.CreateCommand(conexion); comando.CommandText = "DESACTIVA_RUTA"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@RUTA", RutaElimina.Ruta); conexion.Open(); comando.ExecuteNonQuery(); conexion.Close(); result = true; } catch (SqlException e) { //insert error in a log result = false; } return result; }
//almacenar////////////////////////////////////////////////////////7 public bool REGISTRARCLIENTE() { ClienteBE REGISTRAR_CLIENTE = new ClienteBE(); bool resulta = false; try { Conexion myconexion = new Conexion(); SqlConnection conexion = myconexion.CreateConnection(); SqlCommand comando = myconexion.CreateCommand(conexion); //pasos FileStream stream = new FileStream(txtexaminar.Text, FileMode.Open, FileAccess.Read); //Se inicailiza un flujo de archivo con la imagen seleccionada desde el disco. BinaryReader br = new BinaryReader(stream); FileInfo fi = new FileInfo(txtexaminar.Text); //Se inicializa un arreglo de Bytes del tamaño de la imagen byte[] binData = new byte[stream.Length]; //Se almacena en el arreglo de bytes la informacion que se obtiene del flujo de archivos(foto) //Lee el bloque de bytes del flujo y escribe los datos en un búfer dado. stream.Read(binData, 0, Convert.ToInt32(stream.Length)); ////Se muetra la imagen obtenida desde el flujo de datos ClienteBE cliente = new ClienteBE(); picfoto.Image = Image.FromStream(stream); conexion.Open(); comando.CommandText = "REGISTRAR_CLIENTE"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@NOMBRES",txtnombre.Text.ToString()); //; comando.Parameters.AddWithValue("@APELLIDOS", txtapellido.Text.ToString()); comando.Parameters.AddWithValue("@DNI", txtcedula.Text.ToString()); comando.Parameters.AddWithValue("@EDAD", numedad.Text.ToString()); comando.Parameters.AddWithValue("@DIRECCION", txtdireccion.Text); comando.Parameters.AddWithValue("@PROVINCIA", cmbprovincia.Text); comando.Parameters.AddWithValue("@GENERO", cmbgenero.Text); comando.Parameters.AddWithValue("@FOTO", binData); int result = comando.ExecuteNonQuery(); if (result > 0) MessageBox.Show("!!!!!DATOS ALMACENADOS CORRECTAMENTE¡¡¡¡¡"); else MessageBox.Show("INSERCIÓN FALLO"); conexion.Close(); txtnombre.Clear(); txtapellido.Clear(); txtdireccion.Clear(); picfoto.Image = null; txtcedula.Clear(); txtnombre.Focus(); } catch (SqlException e) { //insert error in a log resulta = false; } return resulta; }