Esempio n. 1
0
        private void lblBuscar_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Suplidores s = new Suplidores();

            try
            {
                s = Suplidores.getSuplidor(txtCodigo.Text);
                if (s != null)
                {
                    txtDescripcion.Text = s.descripcion;
                    txtDireccion.Text   = s.direccion;
                    txtNombre.Text      = s.nombre;
                    txtTelefono.Text    = s.telefono;
                    btnEliminar.Enabled = true;
                    pbImagen.Image      = Image.FromFile(s.imagen);
                    txtCodigo.Enabled   = false;
                    lblBuscar.Enabled   = false;
                }
                else
                {
                    MessageBox.Show("No Existe el Suplidor, Digite un ID valido", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtCodigo.Clear();
                    txtCodigo.Focus();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
0
        public static Suplidores getSuplidor(string codigo)
        {
            Suplidores s = new Suplidores();

            using (SqlConnection con = ConnectionDB.conectar())
            {
                SqlCommand    comand = new SqlCommand(string.Format("select * from suplidores where codigo = {0}", codigo), con);
                SqlDataReader re     = comand.ExecuteReader();
                if (re.HasRows)
                {
                    while (re.Read())
                    {
                        s.codigo      = re["codigo"].ToString();
                        s.descripcion = re["descripcion"].ToString();
                        s.direccion   = re["direccion"].ToString();
                        s.imagen      = re["imagen"].ToString();
                        s.nombre      = re["nombresuplidor"].ToString();
                        s.telefono    = re["telefono"].ToString();
                    }
                }
                else
                {
                    s = null;
                }
                con.Close();
            }
            return(s);
        }
Esempio n. 3
0
 private void frmEliminarSuplidores_Load(object sender, EventArgs e)
 {
     txtCodigo.Text = IDs;
     try
     {
         if (txtCodigo.Text != string.Empty)
         {
             Suplidores s = Suplidores.getSuplidor(txtCodigo.Text);
             txtDescripcion.Text = s.descripcion;
             txtDireccion.Text   = s.direccion;
             txtNombre.Text      = s.nombre;
             txtTelefono.Text    = s.telefono;
             txtCodigo.Enabled   = false;
             lblBuscar.Enabled   = false;
             pbImagen.Image      = Image.FromFile(s.imagen);
         }
         else
         {
             pbImagen.Image         = Image.FromFile(@"C:\FactoriadeProyectos\Dealer\img\n.png");
             txtDescripcion.Enabled = false;
             txtDireccion.Enabled   = false;
             txtNombre.Enabled      = false;
             txtTelefono.Enabled    = false;
             btnEliminar.Enabled    = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 4
0
        public static List <Suplidores> Buscar(string nombre, string direccion, string telefono, string codigo)
        {
            List <Suplidores> list = new List <Suplidores>();

            using (SqlConnection con = ConnectionDB.conectar())
            {
                SqlCommand comand = new SqlCommand(string.Format("select * from suplidores where codigo like '{0}%' and nombresuplidor like '{1}%' and telefono like '{2}%' and direccion like '{3}%'",
                                                                 codigo, nombre, telefono, direccion), con);
                SqlDataReader re = comand.ExecuteReader();
                while (re.Read())
                {
                    Suplidores s = new Suplidores();
                    s.codigo      = re["codigo"].ToString();
                    s.descripcion = re["descripcion"].ToString();
                    s.direccion   = re["direccion"].ToString();
                    s.imagen      = re["imagen"].ToString();
                    s.nombre      = re["nombresuplidor"].ToString();
                    s.telefono    = re["telefono"].ToString();

                    list.Add(s);
                }
                con.Close();
            }
            return(list);
        }
Esempio n. 5
0
        public static int Modificar(Suplidores s)
        {
            int r = -1;

            using (SqlConnection con = ConnectionDB.conectar())
            {
                SqlCommand comand = new SqlCommand(string.Format("update suplidores set nombresuplidor = '{0}', direccion = '{1}', descripcion = '{2}', imagen = '{3}', telefono = '{4}' where codigo = '{5}'", s.nombre, s.direccion, s.descripcion, s.imagen, s.telefono, s.codigo), con);
                r = comand.ExecuteNonQuery();
                con.Close();
            }
            return(r);
        }
Esempio n. 6
0
        public static int Registrar(Suplidores s)
        {
            int r = -1;

            using (SqlConnection con = ConnectionDB.conectar())
            {
                SqlCommand comand = new SqlCommand(string.Format("insert into suplidores (nombresuplidor, direccion, descripcion, imagen, telefono) values ('{0}', '{1}', '{2}', '{3}', '{4}')", s.nombre, s.direccion, s.descripcion, s.imagen, s.telefono), con);
                r = comand.ExecuteNonQuery();
                con.Close();
            }
            return(r);
        }
Esempio n. 7
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            Suplidores s = new Suplidores();

            if (txtDescripcion.Text == string.Empty)
            {
                MessageBox.Show("Descripcion esta vacia", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDescripcion.Focus();
            }

            else if (txtDireccion.Text == string.Empty)
            {
                MessageBox.Show("Direccion esta vacia", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtDireccion.Focus();
            }
            else if (txtNombre.Text == string.Empty)
            {
                MessageBox.Show("El Nombre del suplidor esta vacio", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtNombre.Focus();
            }
            else if (txtTelefono.Text == string.Empty)
            {
                MessageBox.Show("El telefono esta vacio", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTelefono.Focus();
            }
            else
            {
                s.descripcion = txtDescripcion.Text;
                s.direccion   = txtDireccion.Text;
                s.imagen      = dimagen;
                s.nombre      = txtNombre.Text;
                s.telefono    = txtTelefono.Text;

                try
                {
                    int r = Suplidores.Registrar(s);
                    if (r > 0)
                    {
                        MessageBox.Show("Registrado con exito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        LimpiarCampos();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo registrar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 8
0
 private void btnSelecionar_Click(object sender, EventArgs e)
 {
     if (dgvSuplidores.SelectedRows.Count == 1)
     {
         ID = dgvSuplidores.CurrentRow.Cells[0].Value.ToString();
         Suplidores s = Suplidores.getSuplidor(ID);
         txtDireecionS.Text  = s.direccion;
         txtNombreS.Text     = s.nombre;
         txtTelefonoS.Text   = s.telefono;
         txtDescripcion.Text = s.descripcion;
         pbImagen.Image      = Image.FromFile(s.imagen);
     }
     else
     {
         MessageBox.Show("No se ha seleccionado un Suplidor de la Lista", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Esempio n. 9
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            string codigo, nombre, telefono, direecion;

            if (txtCodigo.Text == string.Empty)
            {
                codigo = "";
            }
            else
            {
                codigo = txtCodigo.Text;
            }
            if (txtDireccion.Text == string.Empty)
            {
                direecion = "";
            }
            else
            {
                direecion = txtDireccion.Text;
            }
            if (txtNombre.Text == string.Empty)
            {
                nombre = "";
            }
            else
            {
                nombre = txtNombre.Text;
            }
            if (txtTelefono.Text == string.Empty)
            {
                telefono = "";
            }
            else
            {
                telefono = txtTelefono.Text;
            }
            try
            {
                dgvSuplidores.DataSource = Suplidores.Buscar(nombre, direecion, telefono, codigo);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 10
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     try
     {
         int r = Suplidores.Eliminar(txtCodigo.Text);
         if (r > 0)
         {
             MessageBox.Show("Eliminado Exitosamente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
             LimpiarCampos();
         }
         else
         {
             MessageBox.Show("No se pudo Eliminar", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }