示例#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 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 btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         if ((txtNombre.Text == "") || (txtMarca.Text == "") || (txtDescripcion.Text == "") || (txtStock.Text == "") || (txtPrecio.Text == "") || (txtPrecio.Text == "."))
         {
             MessageBox.Show("Favor de llenar todos los campos");
         }
         else
         {
             objetoCN.InsertarPRod(txtNombre.Text, txtDescripcion.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text);
             MessageBox.Show("Se inserto Correctamente");
             txtNombre.Text      = "";
             txtDescripcion.Text = "";
             txtMarca.Text       = "";
             txtPrecio.Text      = "";
             txtStock.Text       = "";
             txtNombre.Focus();
             MostrarProductos();
         }
     }
     catch (Exception ex) {
         MessageBox.Show("" + ex);
     }
 }
        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);
                }
            }
        }
示例#5
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);
         }
     }
 }
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     try
     {
         objetoCN.InsertarPRod(txtNombre.Text, txtDescripcion.Text, txtMarca.Text, txtPrecio.Text, txtStock.Text);
         MessageBox.Show("Se inserto Correctamente");
         MostrarProductos();
     }
     catch (Exception ex) {
         MessageBox.Show("" + ex);
     }
 }