示例#1
0
        private bool Valida_Registro()
        {
            bool band;

            if (Id_Socio.Text != "" && Convert.ToInt32(Id_Socio.Text) > 0 && buscaSocio(Convert.ToInt32(Id_Socio.Text)) == 1)
            {
                idSocio = Convert.ToInt32(Id_Socio.Text);
                band    = true;
            }
            else
            {
                MessageBox.Show("Ingrese un valor Valido Para 'Id de Socio' Para Continuar");
                Id_Socio.Focus();
                band = false;
                return(band);
            }

            if (Id_Producto.Text != "" && Convert.ToInt32(Id_Producto.Text) > 0 && buscaProducto(Convert.ToInt32(Id_Producto.Text)) == 1)
            {
                idProducto = Convert.ToInt32(Id_Producto.Text);
                band       = true;
            }
            else
            {
                MessageBox.Show("Ingrese un valor Valido Para 'Id de Producto' Para Continuar");
                Id_Producto.Focus();
                band = false;
                return(band);
            }

            return(band);
        }
示例#2
0
        private void Id_Producto_TextChanged(object sender, EventArgs e)
        {
            int datoT = 0, claveAux = 0;

            this.productosTableAdapter.Update(this.gym_Manager1DataSet.Productos);

            if (Id_Producto.Text != "")
            {
                claveAux = int.Parse(Id_Producto.Text);
                if (buscaProducto(claveAux) != 1)
                {
                    MessageBox.Show("El Id de Producto " + claveAux + " No Existe en la base de Datos, Ingrese un Id de Producto Valido");
                    Limpia_Registro_Producto();
                    Id_Producto.Focus();
                }
                else
                {
                    foreach (DataGridViewRow row in dataGridView2.Rows)
                    {
                        datoT = Convert.ToInt32(row.Cells["idProductoDataGridViewTextBoxColumn1"].Value);
                        if (datoT == claveAux)
                        {
                            Id_Producto.Text     = Convert.ToString(row.Cells["idProductoDataGridViewTextBoxColumn1"].Value);
                            Nombre_Producto.Text = Convert.ToString(row.Cells["nombreProductoDataGridViewTextBoxColumn"].Value);
                            Precio.Text          = Convert.ToString(row.Cells["precioProductoDataGridViewTextBoxColumn"].Value);
                        }
                    }
                }
            }
            else
            {
                Limpia_Registro_Producto();
                Id_Producto.Focus();
            }
        }
示例#3
0
        private void Agregar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Valida_Registro() == true)
                {
                    existencias = obtener_Existencias(idProducto);

                    if (existencias > 0 && cantidad < existencias)
                    {
                        if (buscaProductoVenta(idProducto) != 1)
                        {
                            Id_Socio.Enabled = false;
                            cantidad         = Convert.ToInt32(Cantidad.Value);
                            precio           = Convert.ToDecimal(Precio.Text);
                            subtotal         = (precio * cantidad);
                            this.detalle_VentaTableAdapter.Alta_Detalle_Venta(idDetalleVenta, idVenta, idProducto, cantidad, subtotal);
                            idDetalleVenta++;
                            this.detalle_VentaTableAdapter.Update(this.gym_Manager1DataSet.Detalle_Venta);
                            this.detalle_VentaTableAdapter.Fill(this.gym_Manager1DataSet.Detalle_Venta);
                            this.productosTableAdapter.Actualiza_Existencias((existencias - cantidad), idProducto);
                            this.productosTableAdapter.Update(this.gym_Manager1DataSet.Productos);
                            this.productosTableAdapter.Fill(this.gym_Manager1DataSet.Productos);
                            subtotal   = Convert.ToDecimal(this.detalle_VentaTableAdapter.Calcula_Total());
                            Total.Text = "$" + subtotal.ToString();
                            total      = subtotal;
                            Limpia_Registro_Producto();
                            Id_Producto.Clear();
                            Id_Producto.Focus();
                        }
                        else
                        {
                            cantidadAux      = obtener_cantidadProducto(idProducto);
                            Id_Socio.Enabled = false;
                            cantidad         = Convert.ToInt32(Cantidad.Value);
                            precio           = Convert.ToDecimal(Precio.Text);
                            subtotal         = (precio * (cantidad + cantidadAux));
                            this.detalle_VentaTableAdapter.Actualiza_Cantidad(idDetalleAux, idVenta, idProducto, cantidad + cantidadAux, subtotal, idProducto);
                            this.detalle_VentaTableAdapter.Update(this.gym_Manager1DataSet.Detalle_Venta);
                            this.detalle_VentaTableAdapter.Fill(this.gym_Manager1DataSet.Detalle_Venta);
                            this.productosTableAdapter.Actualiza_Existencias((existencias - cantidad), idProducto);
                            this.productosTableAdapter.Update(this.gym_Manager1DataSet.Productos);
                            this.productosTableAdapter.Fill(this.gym_Manager1DataSet.Productos);
                            subtotal   = Convert.ToDecimal(this.detalle_VentaTableAdapter.Calcula_Total());
                            Total.Text = "$" + subtotal.ToString();
                            total      = subtotal;
                            Limpia_Registro_Producto();
                            Id_Producto.Clear();
                            Id_Producto.Focus();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Existencias Insuficientes para realizar la Venta");
                        Limpia_Registro_Producto();
                        Id_Producto.Focus();
                    }
                }
                else
                {
                    Id_Producto.Focus();
                }
            }
            catch (DBConcurrencyException ex)
            {
                MessageBox.Show("Error de concurrencia:\n" + ex.Message);
            }
        }