public void verconductor()
        {
            Conexion myconexion = new Conexion();
            SqlConnection conexion = myconexion.CreateConnection();
            string sql = "Select *from Conductor where DNI='" + txtcedulacond.Text + "'";
            SqlCommand comando = new SqlCommand(sql, conexion);
            conexion.Open();

            SqlDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)
            {

                txtnombrecond.Text = leer["NOMBRES"].ToString();
                txtcolor.Text = leer["COLOR"].ToString();
                txtplaca.Text = leer["PLACA"].ToString();
                tapellidocond.Text = leer["APELLIDOS"].ToString();

            }
            else
            {
                MessageBox.Show("No se encontro al conductor");

                txtnombrecond.Text = "";
                txtcolor.Text = "";
                txtplaca.Text = "";
                tapellidocond.Text = "";
            }
            conexion.Close();
        }
        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;
        }
        //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 void calcular()
        {
            Conexion myconexion = new Conexion();
            SqlConnection conexion = myconexion.CreateConnection();
            string sql = "Select *from RUTAS where RUTA='" + cmbruta.Text + "'";
            SqlCommand comando = new SqlCommand(sql, conexion);
            conexion.Open();

            SqlDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)

            {
                txtmonto.Text = leer["MONTO"].ToString();
                double monto;
                double monto2;

                monto = double.Parse(txtmonto.Text);
                monto2 = (monto / 540);
                txtdolares.Text = monto2.ToString();

            }
            else
            {
                MessageBox.Show("No se encontro al conductor");

            }
            conexion.Close();
        }
Esempio n. 7
0
        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 void calcular()
        {
            //este codigo me muestra el monto a cobrar por la ruta en el textbox ademas muestra la cantida en col y $
            Conexion myconexion = new Conexion();
            SqlConnection conexion = myconexion.CreateConnection();
            string sql = "Select *from RUTAS where RUTA='" + cmbruta.Text + "'";
            SqlCommand comando = new SqlCommand(sql, conexion);
            conexion.Open();

            SqlDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)

            {
                txtmonto.Text = leer["MONTO"].ToString();
                double monto;
                double monto2;

                monto = double.Parse(txtmonto.Text);
                monto2 = (monto / 540);
                txtdolares.Text = monto2.ToString();

            }
            //else
            //{
            //    MessageBox.Show("No se encontro al conductor");

            //}
            conexion.Close();
        }
        //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;
        }
Esempio n. 10
0
        //metodos para editar un conductor-------------------------------------------------
        public static List<ConductorBE> Buscar(string pNombre, string pApellido)
        {
            List<ConductorBE> resultadolista = new List<ConductorBE>();

            ConductorBE vvv = 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 NOMBRES ='{0}' or APELLIDOS='{1}'", pNombre,pApellido), conexion);
            SqlDataReader cconductor;

            conexion.Open();

            cconductor = comando.ExecuteReader();
            while (cconductor.Read())
            {
                ConductorBE pConductor = new ConductorBE();
                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);

                resultadolista.Add(pConductor);
            }
            conexion.Close();
            return resultadolista;
        }
        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<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;
        }
Esempio n. 13
0
 //METODOS PARA BUSCAR  POR CEDULA
 public void buscarcedula(DataGridView data)
 {
     Conexion myconexion = new Conexion();
     SqlConnection conexion = myconexion.CreateConnection();
     conexion.Open();
     SqlCommand comando = new SqlCommand("SELECT * FROM CLIENTE where DNI like ('" + buscar + "%')", conexion);
     comando.Connection = conexion;
     comando.ExecuteNonQuery();
     DataTable dt = new DataTable();
     SqlDataAdapter da = new SqlDataAdapter(comando);
     da.Fill(dt);
     data.DataSource = dt;
     conexion.Close();
 }
Esempio n. 14
0
        public static int Actualizar(ConductorBE mConductor)
        {
            int retorno = 0;

            Conexion myConnection = new Conexion();
            SqlConnection conexion = myConnection.CreateConnection();
            SqlCommand comando = new SqlCommand(string.Format("UPDATE CONDUCTOR set AÑO='{0}', COLOR='{1}', NOMBRES='{2}', APELLIDOS='{3}', DNI='{4}', EDAD='{5}', DIRECCION='{6}',PROVINCIA='{7}' where PLACA={8}",
                mConductor.Año, mConductor.Color, mConductor.Nombres, mConductor.Apellidos, mConductor.DNI,mConductor.Edad,mConductor.Direccion,mConductor.Provincia,mConductor.Placa), conexion);

            conexion.Open();
            retorno = comando.ExecuteNonQuery();
            conexion.Close();

            return retorno;
        }
Esempio n. 15
0
        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 void eliminar(DataGridView dataelimina)
        {
            Conexion myconexion = new Conexion();
            SqlConnection conexion = myconexion.CreateConnection();
            DialogResult resultado = MessageBox.Show("¿Estas Seguro de Eliminar al cliente?");
            if (resultado == DialogResult.No)
            {
                return;
            }

            {
                SqlCommand comando = new SqlCommand("BORRAR_CLIENTE", conexion);
                comando.CommandType = CommandType.StoredProcedure;
                comando.Parameters.AddWithValue("ID", dataelimina.CurrentRow.Cells["ID"].Value);
                conexion.Open();
                comando.ExecuteNonQuery();
                conexion.Close();

                MessageBox.Show("El cliente ha sido eliminado");
            }
        }
        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;
        }
Esempio n. 18
0
        ////////////
        public void ActualizarGrid(DataGridView dg, String Query)
        {
            Conexion myconexion = new Conexion();
            SqlConnection conexion = myconexion.CreateConnection();
            //SqlCommand comando = myconexion.CreateCommand(conexion);
            //SqlConnection miconexion = new SqlConnection(Conexion.conexion);
            conexion.Open();

            //crear DataSet
            System.Data.DataSet MiDataSet = new System.Data.DataSet();

            //Crear Adaptador de datos
            SqlDataAdapter MiDataAdapter = new SqlDataAdapter(Query, conexion);

            //LLenar el DataSet
            MiDataAdapter.Fill(MiDataSet, "CLIENTE");

            //Asignarle el valor adecuado a las propiedades del DataGrid
            dg.DataSource = MiDataSet;
            dg.DataMember = "CLIENTE";

            //nos desconectamos de la base de datos...
            conexion.Close();
        }
Esempio n. 19
0
        private void EditarClient()
        {
            Conexion myconexion = new Conexion();
            SqlConnection conexion = myconexion.CreateConnection();
            conexion.Open();
            string sql = @"UPDATE CLIENTE SET
                                         [NOMBRES] = @NOMBRES, [APELLIDOS] = @APELLIDOS ,[DIRECCION] = @DIRECCION ,[PROVINCIA] = @PROVINCIA WHERE [ID] = @ID";

            SqlCommand command = new SqlCommand(sql, conexion);

            command.Parameters.AddWithValue("ID", label7.Text);

            command.Parameters.AddWithValue("NOMBRES", txtnombre.Text);
            command.Parameters.AddWithValue("APELLIDOS", txtapellido.Text);
            command.Parameters.AddWithValue("DIRECCION", txtdireccion.Text);
            command.Parameters.AddWithValue("PROVINCIA", cmbprovincia.Text);
            command.ExecuteNonQuery();
            MessageBox.Show("Datos Actualizados Satisfactoriamente");
            conexion.Close();
        }
        private void vercliente()
        {
            //busca los datos del conductor de acuerdo a la cedula ingresada
            Conexion myconexion = new Conexion();
            SqlConnection conexion = myconexion.CreateConnection();
            string sql = "Select *from CLIENTE where DNI='" + txtcedulacliente.Text + "'";
            SqlCommand comando = new SqlCommand(sql, conexion);
            conexion.Open();

            SqlDataReader leer = comando.ExecuteReader();

            if (leer.Read() == true)
            {

                txtname.Text = leer["NOMBRES"].ToString();
                txtapellidocliente.Text = leer["APELLIDOS"].ToString();

            }
            else
            {
                MessageBox.Show("No se encontro al cliente");

                txtnombrecond.Text = "";
                txtcolor.Text = "";
                txtplaca.Text = "";
            }
            conexion.Close();
        }
Esempio n. 21
0
        //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;
        }
Esempio n. 22
0
        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;
        }
Esempio n. 23
0
        public void listarclientes(DataGridView data)
        {
            Conexion myconexion = new Conexion();
            SqlConnection conexion = myconexion.CreateConnection();

            conexion.Open();
            SqlCommand comando = new SqlCommand("VER_CLIENTE", conexion);
            comando.Connection = conexion;
            comando.ExecuteNonQuery();
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(comando);
            da.Fill(dt);
            data.DataSource = dt;
            data.Columns[0].Width = 60;
            data.Columns[1].Width = 165;
            data.Columns[2].Width = 165;
            data.Columns[3].Width = 90;
            data.Columns[4].Width = 50;
            data.Columns[5].Width = 165;
            data.Columns[6].Width = 100;
            data.Columns[7].Width = 125;

            conexion.Close();
        }
Esempio n. 24
0
        ///////////////////
        public void EjecutarSql(String Query)
        {
            Conexion conexion = new Conexion();
            SqlConnection MiConexion = conexion.CreateConnection();
            SqlCommand MiComando = new SqlCommand(Query, MiConexion);

            //ejecutamos la consulta (query) sql...
            int FilasAfectadas = MiComando.ExecuteNonQuery();

            if (FilasAfectadas > 0)
                MessageBox.Show("Operación realizada exitosamente", "la base de datos ha sido modificada", MessageBoxButtons.OK, MessageBoxIcon.Information);
            else

                MessageBox.Show("No se pudo realizar la modificación de la base de datos :-(", "Error del sistema", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
Esempio n. 25
0
        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 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;
        }
Esempio n. 27
0
        public void ver()
        {
            //BUSQUEDA POR CEDULA
            if (cmbcedula.Text == "Cedula")
            {
                Conexion myconexion = new Conexion();
                SqlConnection conexion = myconexion.CreateConnection();

                conexion.Open();
                SqlCommand cmd = new SqlCommand("select * from CLIENTE where DNI= @Clav", conexion);
                cmd.Parameters.AddWithValue("@Clav", txtbuscarcliente.Text);
                SqlDataAdapter da = new SqlDataAdapter(cmd);

                //Representa un set de comandos que es utilizado para llenar un DataSet
                SqlDataAdapter dp = new SqlDataAdapter(cmd);
                //Representa un caché (un espacio) en memoria de los datos.
                DataSet ds = new DataSet("CLIENTE");

                //Arreglo de byte en donde se almacenara la foto en bytes
                byte[] MyData = new byte[0];

                //Llenamosel DataSet con la tabla. ESTUDIANTE es nombre de la tabla
                dp.Fill(ds, "CLIENTE");

                //Si dni existe ejecutara la consulta
                if (ds.Tables["CLIENTE"].Rows.Count > 0)
                {
                    //Inicializamos una fila de datos en la cual se almacenaran todos los datos de la fila seleccionada
                    DataRow myRow = ds.Tables["CLIENTE"].Rows[0];

                    //Se almacena el campo foto de la tabla en el arreglo de bytes
                    MyData = (byte[])myRow["FOTO"];
                    //Se inicializa un flujo en memoria del arreglo de bytes
                    MemoryStream stream = new MemoryStream(MyData);
                    //En el picture box se muestra la imagen que esta almacenada en el flujo en memoria
                    //el cual contiene el arreglo de bytes
                    picfoto3.Image = Image.FromStream(stream);

                    txtnombre.Text = myRow["NOMBRES"].ToString();
                    txtapellido.Text = myRow["APELLIDOS"].ToString();
                    txtdireccion.Text = myRow["DIRECCION"].ToString();
                    cmbprovincia.Text = myRow["PROVINCIA"].ToString();
                    label7.Text = myRow["ID"].ToString();

                    txtbuscarcliente.Enabled = false;
                    cmbcedula.Enabled = false;
                    txtnombre.Enabled = true;
                    txtnombre.Focus();
                    txtapellido.Enabled = true;
                    txtdireccion.Enabled = true;
                    cmbprovincia.Enabled = true;

                }

                else
                {
                    MessageBox.Show("La Cedula ingresada NO EXISTE - Digite nuevamente");

                    txtbuscarcliente.Enabled = true;
                    cmbcedula.Enabled = true;
                    txtnombre.Enabled = false;
                    txtbuscarcliente.Focus();
                    txtbuscarcliente.Clear();
                    txtapellido.Enabled = false;
                    txtdireccion.Enabled = false;
                    cmbprovincia.Enabled = false;

                }

            }

            //BUSQUEDA POR APELLIDO
            if (cmbcedula.Text == "Apellido")
            {
                Conexion myconexion = new Conexion();
                SqlConnection conexion = myconexion.CreateConnection();

                conexion.Open();
                SqlCommand cmd = new SqlCommand("select * from CLIENTE where APELLIDOS= @Clav", conexion);
                cmd.Parameters.AddWithValue("@Clav", txtbuscarcliente.Text);
                SqlDataAdapter da = new SqlDataAdapter(cmd);

                //Representa un set de comandos que es utilizado para llenar un DataSet
                SqlDataAdapter dp = new SqlDataAdapter(cmd);
                //Representa un caché (un espacio) en memoria de los datos.
                DataSet ds = new DataSet("CLIENTE");

                //Arreglo de byte en donde se almacenara la foto en bytes
                byte[] MyData = new byte[0];

                //Llenamosel DataSet con la tabla. ESTUDIANTE es nombre de la tabla
                dp.Fill(ds, "CLIENTE");

                //Si dni existe ejecutara la consulta
                if (ds.Tables["CLIENTE"].Rows.Count > 0)
                {
                    //Inicializamos una fila de datos en la cual se almacenaran todos los datos de la fila seleccionada
                    DataRow myRow = ds.Tables["CLIENTE"].Rows[0];

                    //Se almacena el campo foto de la tabla en el arreglo de bytes
                    MyData = (byte[])myRow["FOTO"];
                    //Se inicializa un flujo en memoria del arreglo de bytes
                    MemoryStream stream = new MemoryStream(MyData);
                    //En el picture box se muestra la imagen que esta almacenada en el flujo en memoria
                    //el cual contiene el arreglo de bytes
                    picfoto3.Image = Image.FromStream(stream);

                    txtnombre.Text = myRow["NOMBRES"].ToString();
                    txtapellido.Text = myRow["APELLIDOS"].ToString();
                    txtdireccion.Text = myRow["DIRECCION"].ToString();
                    cmbprovincia.Text = myRow["PROVINCIA"].ToString();
                    label7.Text = myRow["ID"].ToString();

                    txtbuscarcliente.Enabled = false;
                    cmbcedula.Enabled = false;
                    txtnombre.Enabled = true;
                    txtnombre.Focus();
                    txtapellido.Enabled = true;
                    txtdireccion.Enabled = true;
                    cmbprovincia.Enabled = true;

                }

                else
                {
                    MessageBox.Show("El Apellido  NO EXISTE - Digite nuevamente");

                    txtbuscarcliente.Enabled = true;
                    cmbcedula.Enabled = true;
                    txtnombre.Enabled = false;
                    txtbuscarcliente.Focus();
                    txtbuscarcliente.Clear();
                    txtapellido.Enabled = false;
                    txtdireccion.Enabled = false;
                    cmbprovincia.Enabled = false;
                    txtbuscarcliente.Enabled = true;

                }

            }
        }
Esempio n. 28
0
        //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;
        }