Example #1
0
        private void btnRegistrar_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            if (Utilidades.ValidarForm2(this, errorProvider1) == false)
            {
                return;
            }
            string mensaje = "";

            try
            {
                if (Program.Evento == 0)
                {
                    P.Idproducto   = Program.Idproducto;
                    P.Unidadb      = txtUnidadb.Text;
                    P.Idunidad     = Convert.ToInt32(cbUnidad.SelectedValue);
                    P.Equivalencia = Convert.ToDouble(txtEquivalencia.Text);
                    // U.Abreviacion = txtAbreviacion.Text;
                    mensaje = P.RegistrarEp();
                    if (mensaje == "1")
                    {
                        MessageBoxEx.Show("Registrado con éxito", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Limpiar();
                    }
                    else
                    {
                        MessageBoxEx.Show("Registro ya existe", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                else if (Program.Evento == 1)
                {
                    P.Idproducto     = Program.Idproducto;
                    P.Idequivalencia = Convert.ToInt32(txtCodigo.Text);
                    P.Unidadb        = txtUnidadb.Text;
                    P.Idunidad       = Convert.ToInt32(cbUnidad.SelectedValue);
                    P.Equivalencia   = Convert.ToDouble(txtEquivalencia.Text);
                    mensaje          = P.ActualizarEp();
                    if (mensaje == "1")
                    {
                        MessageBoxEx.Show("Actualizado con éxito", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        Limpiar();
                    }
                    else
                    {
                        MessageBoxEx.Show("Ha ocurrido un error", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        //Limpiar();
                    }
                }
                LlenarGrid();
                Program.Evento = 0;
                //Limpiar();
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }