示例#1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     //INSERTAR
     if (Editar == false)
     {
         try
         {
             objetoCN.InsertarPRod(txtNombre.Text, txtDesc.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text);
             MessageBox.Show("se inserto correctamente");
             MostrarProdctos();
             limpiarForm();
         }
         catch (Exception ex)
         {
             MessageBox.Show("no se pudo insertar los datos por: " + ex);
         }
     }
     //EDITAR
     if (Editar == true)
     {
         try
         {
             objetoCN.EditarProd(txtNombre.Text, txtDesc.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text, idProducto);
             MessageBox.Show("se edito correctamente");
             MostrarProdctos();
             limpiarForm();
             Editar = false;
         }
         catch (Exception ex) {
             MessageBox.Show("no se pudo editar los datos por: " + ex);
         }
     }
 }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            // I  N   S  E  R  T  A  R
            if (Editar == false)
            {
                try
                {
                    objetoCN.InsertarProd(txtNombre.Text, txtDescripcion.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text);
                    MessageBox.Show("Se agrego correctamente!");
                    MostrarProductos();
                    limpiarForm();
                }
                catch (Exception EX)
                {
                    MessageBox.Show("No se pudo agregar los datos" + EX);
                }
            }

            // E  D  I  T  A  R
            if (Editar == true)
            {
                try
                {
                    objetoCN.EditarProd(txtNombre.Text, txtDescripcion.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text, idProducto);
                    MessageBox.Show("Se edito correctamente");
                    MostrarProductos();
                    limpiarForm();
                    Editar = false; // Esto para que vuelva a insertar
                }
                catch (Exception)
                {
                    MessageBox.Show("No se pudo editar");
                }
            }
        }
示例#3
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (!Editar)
     {
         try
         {
             objetoCN.InsertarProd(txtNombre.Text, txtDesc.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text);
             MessageBox.Show("Se inserto correctamente!");
             MostrarProductos();
             LimpiarControles();
         }
         catch (Exception ex)
         {
             MessageBox.Show("No se pudo insertar el registro por: " + ex);
         }
     }
     else
     {
         try
         {
             objetoCN.EditarProd(txtNombre.Text, txtDesc.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text, idProducto);
             MessageBox.Show("Se edito correctamente!");
             MostrarProductos();
             LimpiarControles();
             Editar = false;
         }
         catch (Exception ex)
         {
             MessageBox.Show("No se pudo editar el registro por: " + ex);
         }
     }
 }
示例#4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text == "" || txtCantidad.Text == "" || txtHora.Text == "" || txtTelefono.Text == "")
            {
                MessageBox.Show("FALTA LLENAR UN CAMPO!!", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (EDITAR == false)
                {
                    try
                    {
                        ////MessageBox.Show("Nombre: " + txtNombre.Text + "Fecha" + FechaPicker1.Text + "Hora:" + txtHora.Text + "Cantidad" + txtCantidad.Text + "Telefono" + txtTelefono.Text);
                        objetoCN.InsertarPRod(txtNombre.Text, Convert.ToDateTime(FechaPicker1.Text), Convert.ToDateTime(txtHora.Text), Convert.ToInt64(txtCantidad.Text), Convert.ToInt64(txtTelefono.Text));
                        MessageBox.Show("SE A INSERTADO CORRECTAMENTE!");
                        MostrarProdctos();
                        LimpiarFrom();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("NO SE LOGRO INSERTAR LOS DATOS CORRECTAMENTE DEBIDO A: NO SE INSERTARON DATOS ");
                    }
                }
            }

            //INsertar
            //if (EDITAR==false)
            //{


            //    try
            //    {
            //        ////MessageBox.Show("Nombre: " + txtNombre.Text + "Fecha" + FechaPicker1.Text + "Hora:" + txtHora.Text + "Cantidad" + txtCantidad.Text + "Telefono" + txtTelefono.Text);
            //        objetoCN.InsertarPRod(txtNombre.Text, Convert.ToDateTime(FechaPicker1.Text), Convert.ToDateTime(txtHora.Text), Convert.ToInt64(txtCantidad.Text), Convert.ToInt64(txtTelefono.Text));
            //        MessageBox.Show("SE A INSERTADO CORRECTAMENTE!");
            //        MostrarProdctos();
            //        LimpiarFrom();
            //    }
            //    catch (Exception ex)
            //    {
            //        MessageBox.Show("NO SE LOGRO INSERTAR LOS DATOS CORRECTAMENTE DEBIDO A: NO SE INSERTARON DATOS ");
            //    }
            //}
            //Editar
            if (EDITAR == true)
            {
                try
                {
                    objetoCN.EditarProd(txtNombre.Text, Convert.ToDateTime(FechaPicker1.Text), Convert.ToDateTime(txtHora.Text), Convert.ToInt64(txtCantidad.Text), Convert.ToInt64(txtTelefono.Text), folioPro);
                    MessageBox.Show("SE A EDITADO CORRECTAMENTE!");
                    MostrarProdctos();
                    LimpiarFrom();
                    EDITAR = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("NO SE LOGRO EDITAR LOS DATOS CORRECTAMENTE DEBIDO A: NO SE INSERTARON DATOS");
                }
            }
        }
        private void btnAgregar_Click_1(object sender, EventArgs e)
        {
            //INSERTAR
            if (Editar == false)
            {
                try
                {
                    objetoCN.InsertarPRod(txtCategoria.Text, txtNombre.Text, txtPrecio.Text, txtStock.Text, txtCodigo.Text);
                    MessageBox.Show("Se ha insertado correctamente el nuevo producto");
                    MostrarProductos();
                    limpiarForm();
                }

                catch (Exception ex)
                {
                    MessageBox.Show("No se ha podido insertar el nuevo producto: " + ex);
                }
            }

            if (Editar == true)
            {
                try
                {
                    objetoCN.EditarProd(txtCategoria.Text, txtNombre.Text, txtPrecio.Text, txtStock.Text, txtCodigo.Text, articulo);
                    MessageBox.Show("Se ha editado correctamente el producto");
                    MostrarProductos();
                    limpiarForm();
                    Editar = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("No se ha podido editado el producto por : " + ex);
                }
            }
        }
示例#6
0
        private void bttnAgregar_Click(object sender, EventArgs e)
        {
            // se creo una condicion si editar es false entonces agregara , pero si editar es true.
            if (editar == false)
            {
                try
                {
                    obj_CN.InsertarProd(txtNombre.Text, txtPrecio.Text, txtStock.Text, cmbCategoria.SelectedValue.ToString());

                    MessageBox.Show("Ingresado");
                    MostrarProductos();
                    limpiarForm();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error al Ingresar " + ex);
                }
            }
            // si la condicion resulta true  se podra editar.
            if (editar == true)
            {
                try
                {
                    obj_CN.EditarProd(txtNombre.Text, txtPrecio.Text, txtStock.Text, cmbCategoria.SelectedValue.ToString(), idprod);
                    MessageBox.Show("Fila fue Editada exitosamente.");
                    MostrarProductos();
                    limpiarForm();
                    editar = false; // se desactiva para que el bttnGuardar pueda agregar registros y no continue editando.
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error al Editar " + ex);
                }
            }
        }
示例#7
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if (editar == false)
     {
         try
         {
             cn.InsertarPRod(txtNombre.Text, txtDesc.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text);
             MessageBox.Show("se inserto correctamente");
             MostrarProductos();
             limpiarForm();
         }
         catch (Exception ex)
         {
             MessageBox.Show("No se inserto debido a:" + ex);
         }
     }
     else if (editar == true)
     {
         try
         {
             cn.EditarProd(txtNombre.Text, txtDesc.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text, id);
             MessageBox.Show("se edito correctamente");
             MostrarProductos();
             limpiarForm();
             editar = false;
         }
         catch (Exception ex)
         {
             MessageBox.Show("No se edito debido a:" + ex);
         }
     }
 }
示例#8
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     if ((txtNombre.Text == "") || (txtMarca.Text == "") || (txtDescripcion.Text == "") || (txtStock.Text == "") || (txtPrecio.Text == "") || (txtPrecio.Text == "."))
     {
         MessageBox.Show("Favor de llenar todos los campos");
     }
     else
     {
         objetoCN.EditarProd(txtNombre.Text, txtDescripcion.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text, idProducto);
         MessageBox.Show("Se inserto Correctamente");
         MostrarProductos();
         txtNombre.Text         = "";
         txtMarca.Text          = "";
         txtPrecio.Text         = "";
         txtStock.Text          = "";
         txtDescripcion.Text    = "";
         idProducto             = null;
         btnGuardar.Enabled     = false;
         txtNombre.Enabled      = false;
         txtMarca.Enabled       = false;
         txtDescripcion.Enabled = false;
         txtPrecio.Enabled      = false;
         txtStock.Enabled       = false;
         btnGuardar.Enabled     = false;
         txtNombre.Focus();
     }
 }
示例#9
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (Editar == false && Convert.ToInt32(cbCate.SelectedValue) != 0)
            {
                try
                {
                    //INSERTA DATOS A TABLA, CONEXION SQL. (TABLA 1)
                    _Crud.InsertarProd(txtNombre.Text, txtDescrip.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text, Convert.ToInt32(cbCate.SelectedValue), estado);
                    MostrarProdcs();


                    //INSERTA DATO A TABLA TEMPORAL (TABLA 2)
                    tabla.Rows.Add(txtNombre.Text);

                    dgvTemporal.DataSource = tabla;

                    MessageBox.Show("El registro se agregó correctamente.");
                    limpiarForm();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("no se pudo insertar los datos por: " + ex);
                }
            }
            if (Editar == true)
            {
                try
                {
                    _Crud.EditarProd(txtNombre.Text, txtDescrip.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text, Convert.ToInt32(cbCate.SelectedValue), idProd);
                    MessageBox.Show("se edito correctamente");
                    MostrarProdcs();
                    limpiarForm();
                    Editar = false;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("no se pudo editar los datos por: " + ex);
                }
            }
        }
示例#10
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     //En este caso vamos a buscar Insertar el producto ya que es necesario que la variable editar = false
     if (Editar == false)
     {
         try
         {
             // Hacemos un try de insertar productos usando el objeto que creamos al principio de la form
             // Hacemos un mensaje, Volovemos a mostrar los productos y limpiamos la hoja donde escribimos los datos
             objetoCN.InsertarProd(txtNombre.Text, txtDesc.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text);
             MessageBox.Show("Se inserto correctamente");
             MostrarProductos();
             limpiarForm();
         }
         catch (Exception ex)
         {
             // Hacemos un catch por si hay un error
             MessageBox.Show("no se pudo insertar los datos por: " + ex);
         }
     }
     // En este caso vamos a editar un producto ya que la variable editar = True
     if (Editar == true)
     {
         try{
             // Hacemos un try de editar productos usando el objeto que creamos al principio de la form
             // hacemos un mensaje, volvemos a mostrar los productos y limpiamos la hoja donde escribimos los datos
             // Tambien ponemos la variable Editar devuelta en False para dejar de editar
             objetoCN.EditarProd(txtNombre.Text, txtDesc.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text, idProducto);
             MessageBox.Show("Se edito correctamente");
             MostrarProductos();
             limpiarForm();
             Editar = false;
         }
         catch (Exception ex)
         {
             // hacemos un catch por si hay un error
             MessageBox.Show("no se pudo Editar los datos por: " + ex);
         }
     }
 }
示例#11
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            if (Editar == false)
            {
                try
                {
                    //se envian los tectos tal cual se capturan de tipo string en el formulario no se hace
                    //ninguna converción
                    objetoCN.InsertarProd(txtNombre.Text, textDescrip.Text, textPrecio.Text, txtStock.Text);
                    MessageBox.Show("Se insertó correctamente");

                    MostrarProdutos();
                    limpiar();
                }
                catch (Exception er)
                {
                    MessageBox.Show("Ha ocurrrido un error al insetar los datos " + er);
                }
            }
            if (Editar)
            {
                try
                {
                    //se envian los textos tal cual se capturan de tipo string en el formulario no se hace
                    //ninguna converción
                    objetoCN.EditarProd(txtNombre.Text, textDescrip.Text, textPrecio.Text, txtStock.Text, idProducto);
                    MessageBox.Show("Se Editó correctamente");
                    Editar = false;
                    MostrarProdutos();
                    limpiar();
                }
                catch (Exception er)
                {
                    MessageBox.Show("Ha ocurrrido un error al editar los datos " + er);
                }
            }
        }
示例#12
0
 private void b_guardar_Click(object sender, EventArgs e)
 {
     if (Editar == false)
     {
         try
         {
             objetoCN.InsertarProd(t_id.Text, t_descripcion.Text, t_existencia.Text, t_preciocosto.Text, t_precioventa.Text, t_cantidadminima.Text, cb_foliofactura.SelectedItem.ToString());
             objma = new Form_Mensaje_A("Producto agregadó correctamente");
             objma.Show();
             MostrarProductos();
             Limpiar_Datos();
         }
         catch (Exception ex)
         {
             objme = new Form_Mensaje_E("Ha ocurridó un error");
             objme.Show();
         }
     }
     if (Editar == true)
     {
         try
         {
             objetoCN.EditarProd(t_id.Text, t_descripcion.Text, t_existencia.Text, t_preciocosto.Text, t_precioventa.Text, t_cantidadminima.Text);
             objma = new Form_Mensaje_A("Producto editadó correctamente");
             objma.Show();
             MostrarProductos();
             Limpiar_Datos();
             Editar = false;
         }
         catch (Exception ex)
         {
             objme = new Form_Mensaje_E("Ha Ocurridó un error");
             objme.Show();
         }
     }
 }