Ejemplo n.º 1
0
 private void btnAgregarD_Click(object sender, EventArgs e)
 {
     errorProvider1.Clear();
     if (Utilidades.ValidarForm(this, errorProvider1) == false)
     {
         return;
     }
     try
     {
         if (Convert.ToDouble(txtInicial1.Text) < Convert.ToDouble(txtFinal1.Text))
         {
             if (Program.Evento == 0)
             {
                 string mensaje = "";
                 P.Idproducto = Program.Idproducto;
                 P.Rangof     = Convert.ToDouble(txtFinal1.Text);
                 P.Rangoi     = Convert.ToDouble(txtInicial1.Text);
                 P.Utilidad   = Convert.ToDouble(txtUtilidad.Text);
                 mensaje      = P.RegistrarPrecios();
                 if (mensaje == "1")
                 {
                     MessageBoxEx.Show("Registrado con éxito", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else if (mensaje == "0")
                 {
                     MessageBoxEx.Show("Rango ya registrado", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
                 LlenarGrid();
                 Limpiar();
             }
             else if (Program.Evento == 1)
             {
                 string mensaje = "";
                 P.Idprecio   = Program.Idprecio;
                 P.Idproducto = Program.Idproducto;
                 P.Rangof     = Convert.ToDouble(txtFinal1.Text);
                 P.Rangoi     = Convert.ToDouble(txtInicial1.Text);
                 P.Utilidad   = Convert.ToDouble(txtUtilidad.Text);
                 mensaje      = P.ActualizarPrecios();
                 if (mensaje == "1")
                 {
                     MessageBoxEx.Show("Registrado con éxito", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 }
                 else if (mensaje == "0")
                 {
                     MessageBoxEx.Show("Rango ya registrado", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                 }
                 LlenarGrid();
                 Limpiar();
             }
         }
         else
         {
             MessageBoxEx.Show("Rango inicial no puede ser mayor que el final", "FactSYS", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     catch (Exception ex)
     {
         MessageBoxEx.Show(ex.Message);
     }
 }