Example #1
0
        private void FrmDetalleVenta_Load(object sender, EventArgs e)
        {
            try
            {
                DataSet ds = FDetalleVenta.GetAll();
                dt = ds.Tables[0];
                dgvVentas.DataSource = dt;

                if (dt.Rows.Count > 0)
                {
                    lblNoSeEncontraronDatos.Visible = false;
                    // dgvVentas_CellClick(null, null);
                }
                else
                {
                    lblNoSeEncontraronDatos.Visible = true;
                }

                //MostrarGuardarCancelar(false);
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Example #2
0
        private void btnQuitar_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Esta seguro de eliminar los productos seleccionados?", "Eliminacion de Producto", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    foreach (DataGridViewRow row in dgvVentas.Rows)
                    {
                        if (Convert.ToBoolean(row.Cells["Eliminar"].Value))
                        {
                            DetalleVenta Dventa = new DetalleVenta();
                            Dventa.Producto.Id = Convert.ToInt32(row.Cells["ProductoId"].Value);
                            Dventa.Cantidad    = Convert.ToInt32(row.Cells["Cantidad"].Value);

                            Dventa.Id = Convert.ToInt32(row.Cells["Id"].Value);
                            if (!(FDetalleVenta.Eliminar(Dventa) > 0))
                            {
                                MessageBox.Show("El producto no pudo ser quitado de la venta. Intente nuevamente", "Eliminacion de Producto",
                                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            }
                        }
                    }
                    FRM_DetalleVenta_Load(null, null);
                    Limpiar();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Algo está mal, Favor intentar denuevo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #3
0
        private void FRM_DetalleVenta_Load(object sender, EventArgs e)
        {
            try
            {
                if (txtFlag.Text != " ")
                {
                    DataSet ds = FDetalleVenta.GetAll(Convert.ToInt32((textVentaId.Text)));
                    dt = ds.Tables[0];
                    dgvVentas.DataSource = dt;
                    dgvVentas.Columns["VentaId"].Visible     = false;
                    dgvVentas.Columns["ProductoId"].Visible  = false;
                    dgvVentas.Columns["Id"].Visible          = false;
                    dgvVentas.Columns["PrecioVenta"].Visible = false;

                    try
                    {
                        tipoCliente = dgvVentas.Rows[0].Cells["TipoCliente"].Value.ToString();
                    }
                    catch (Exception)
                    {
                    }
                    dgvVentas.Columns["TipoCliente"].Visible = false;

                    if (dt.Rows.Count > 0)
                    {
                        noencontrado.Visible = false;
                        // dgvVentas_CellClick(null, null);
                    }
                    else
                    {
                        noencontrado.Visible = true;
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error inesperado, Favor cerrar y volver a abrir", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            CMB_Buscar.Text = "Nombre";
            cbx_ProdSer.Focus();
            cbx_ProdSer.Text = "Producto";
        }
Example #4
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string sResultado = ValidarDatos();


                if (sResultado == "")

                {
                    DetalleVenta detventa = new DetalleVenta();
                    detventa.Venta.Id    = Convert.ToInt32(txtVentaId.Text);
                    detventa.Producto.Id = Convert.ToInt32(txtProductoId.Text);
                    detventa.Cantidad    = Convert.ToDouble(txtPrecioUnitario.Text);



                    int iDetVentaId = FDetalleVenta.Insertar(detventa);

                    if (iDetVentaId > 0)
                    {
                        MessageBox.Show("El Producto se agrego correctamente");
                        Limpiar();
                    }
                    else
                    {
                        MessageBox.Show("El producto no se pudo agregar");
                    }
                }
                else
                {
                    MessageBox.Show(sResultado, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
Example #5
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            string sresultado;

            try
            {
                sresultado = ValidarDatos();

                if (sresultado == "")
                {
                    DetalleVenta Dventa = new DetalleVenta();

                    Dventa.Venta.Id         = Convert.ToInt32(textVentaId.Text);
                    Dventa.Producto.Id      = Convert.ToInt32(text_ProductoId.Text);
                    Dventa.Cantidad         = Convert.ToInt32(text_Cantidad.Text);
                    Dventa.PrecioUnitario   = Convert.ToDouble(text_PrecioUnitario.Text);
                    Dventa.DescripcionVenta = text_DescripcionVenta.Text;

                    int iDVentaId = FDetalleVenta.Insertar(Dventa);

                    if (iDVentaId > 0)
                    {
                        if (cbx_ProdSer.Text == "Producto")
                        {
                            //obteniento nuevo stock
                            int    currentStock = Convert.ToInt32(text_stock.Text);
                            string newStock     = Convert.ToString(currentStock - Dventa.Cantidad);
                            text_stock.Text = newStock;
                        }


                        //este es el metodo para guardar el log con la accion Detalle de ventas agregados
                        Form1.Log(Usuario.Nombreusuario, "Detalle de ventas agregados ");


                        FRM_DetalleVenta_Load(null, null);
                        Limpiar();
                    }
                    else
                    {
                        MessageBox.Show("El Producto no fue agregado, intente nuevamente", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }

                else
                {
                    MessageBox.Show(sresultado, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception)
            {
                if (text_PrecioUnitario.Text == "")
                {
                    MessageBox.Show("Favor seleccionar algún " + cbx_ProdSer.Text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    text_PrecioUnitario.Focus();
                }
                else
                {
                    MessageBox.Show("Algo salio mal, Favor llenar campos correctamente e intentar denuevo", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            FRM_DetalleVenta_Load(null, null);
        }