示例#1
0
 public void limpiarventa()
 {
     try
     {
         cmd = new SqlCommand("SELECT IDENT_CURRENT ('Venta');", new Conexion().con);
         Folio_venta.Text = Convert.ToString((Convert.ToInt32(cmd.ExecuteScalar()) + 1));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
     venta.Rows.Clear();
     TotalPagar.Text = "0,00";
     cantidad.Text   = "1";
     textBox5.Text   = "0";
     ID_Producto.Focus();
 }
示例#2
0
 private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
 {
     //Funcion con la tecla enter
     if ((int)e.KeyChar == (int)Keys.Enter)
     {
         if (ID_Producto.Text == "")
         {
             FormRealizarConsultas metodopago = new FormRealizarConsultas();
             metodopago.ban = 2;
             metodopago.Show();
         }
         else
         {
             ban_v = 0;
             try
             {
                 cmd = new SqlCommand("ConsultarProducto " + ID_Producto.Text, new Conexion().con);
                 SqlDataReader consu = cmd.ExecuteReader();
                 String        descripcion, precio, codigo;
                 double        total;
                 if (consu.Read() == true)
                 {
                     for (int fila = 0; fila <= venta.Rows.Count - 1; fila++)
                     {
                         string codigo_co = venta.Rows[fila].Cells[0].Value.ToString();
                         string pedido_co = venta.Rows[fila].Cells[2].Value.ToString();
                         string precio_co = venta.Rows[fila].Cells[3].Value.ToString();
                         int    valor_total;
                         if (ID_Producto.Text == codigo_co)
                         {
                             valor_total = (Convert.ToInt32(pedido_co) + Convert.ToInt32(cantidad.Text));
                             total       = (valor_total * Convert.ToDouble(precio_co));
                             venta.Rows[fila].Cells[2].Value = Convert.ToString(valor_total);
                             venta.Rows[fila].Cells[4].Value = Convert.ToString(total);
                             calcular();
                             ID_Producto.Text = "";
                             cantidad.Text    = "1";
                             ban_v            = 1;
                         }
                     }
                     if (ban_v == 0)
                     {
                         codigo      = consu["id_producto"].ToString();
                         descripcion = consu["Nombre_P"].ToString();
                         precio      = consu["precio_Tienda"].ToString();
                         total       = (Convert.ToDouble(precio) * Convert.ToInt32(cantidad.Text));
                         venta.Rows.Add(codigo, descripcion, cantidad.Text, precio, total);
                         ID_Producto.Text = "";
                         cantidad.Text    = "1";
                         calcular();
                     }
                 }
                 else
                 {
                     MessageBox.Show("No se encuentra Producto.", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Error);
                     ID_Producto.Text = "";
                     ID_Producto.Focus();
                 }
                 consu.Close();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
     //Validacion para puros numeros
     if (Char.IsDigit(e.KeyChar))
     {
         e.Handled = false;
     }
     //Validacion para multiplicar la cantidad de productos
     else if (e.KeyChar == '*')
     {
         if (ID_Producto.Text == "")
         {
             e.Handled = true;
         }
         else
         {
             cantidad.Text    = ID_Producto.Text;
             e.Handled        = true;
             ID_Producto.Text = ("");
         }
     }
     //parte de la validacion de numeros
     else if (Char.IsControl(e.KeyChar))
     {
         e.Handled = false;
     }
     else
     {
         e.Handled = true;
     }
 }