Пример #1
0
        private void SetProducto(PROt09_producto producto)
        {
            try
            {
                prod = new PROt09_producto();
                prod = producto;

                txtCodProd.Text         = producto.cod_producto;
                txtDescripcionProd.Text = producto.txt_desc;
                txtPeso.Text            = producto.peso_prod;
                if (producto.mto_pvpu_con_igv != null)
                {
                    txtPrecio.Text = producto.mto_pvpu_con_igv.RoundOut(numDec);
                }
                else
                {
                    if (producto.mto_pvpu_sin_igv != null)
                    {
                        txtPrecio.Text = producto.mto_pvpu_sin_igv.RoundOut(numDec);
                    }
                    else
                    {
                        txtPrecio.Text = "";
                    }
                }
                cboUm.SelectedValue = producto.id_um ?? -1;
                txtCantidad.Focus();
            }
            catch (Exception e)
            {
                MessageBox.Show("No se pudo setear el producto. Excepción: " + e.Message, "Mensaje Eagle", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void SeleccionarProducto()
        {
            if (dgvProd.CurrentRow != null)
            {
                try
                {
                    producto = new PROt09_producto();

                    var pvpu_con_igv = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["PVPU_CON_IGV"].Value;
                    var pvpu_sin_igv = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["PVPU_SIN_IGV"].Value;
                    var por_impto    = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["POR_IMPTO"].Value;
                    var id_um        = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["UM"].Value;

                    producto.id_producto   = long.Parse(dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["ID"].Value.ToString());
                    producto.cod_producto  = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["CODIGO"].Value.ToString();
                    producto.cod_producto2 = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["CODIGO02"].Value.ToString();
                    producto.txt_desc      = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["DESCRIPCION"].Value.ToString();
                    producto.txt_estado    = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["ESTADO"].Value.ToString();
                    if (pvpu_con_igv == null)
                    {
                        producto.mto_pvpu_con_igv = null;
                    }
                    else
                    {
                        producto.mto_pvpu_con_igv = decimal.Parse(pvpu_con_igv.ToString());
                    }
                    if (pvpu_sin_igv == null)
                    {
                        producto.mto_pvpu_sin_igv = null;
                    }
                    else
                    {
                        producto.mto_pvpu_sin_igv = decimal.Parse(pvpu_sin_igv.ToString());
                    }
                    if (por_impto == null)
                    {
                        producto.por_impto = null;
                    }
                    else
                    {
                        producto.por_impto = decimal.Parse(por_impto.ToString());
                    }
                    producto.peso_prod = dgvProd.Rows[dgvProd.CurrentRow.Index].Cells["PESO"].Value.ToString();
                    if (id_um == null)
                    {
                        producto.id_um = null;
                    }
                    else
                    {
                        producto.id_um = int.Parse(id_um.ToString());
                    }

                    Hide();
                    Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show($"No se pudo seleccionar el producto. Excepción: {e.Message}", "Excepción encontrada", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #3
0
        private void AddItem()
        {
            if (details == null || details.Count < maxNumItems)
            {
                if (ValidarProducto())
                {
                    var item = GetProducto();
                    if (item != null)
                    {
                        if (details == null)
                        {
                            details = new List <TNSt05_comp_emitido_dtl>();
                        }
                        if (details != null)
                        {
                            try
                            {
                                var index = details.FindIndex(x => x.id_producto == item.id_producto);
                                //Si el producto ya existe en el detalle -> edita item
                                if (index != -1)
                                {
                                    var oldItem = details[index];

                                    item.qt_venta += oldItem.qt_venta;

                                    item.punit_dscto_con_igv += oldItem.punit_dscto_con_igv;
                                    item.punit_dscto_sin_igv += oldItem.punit_dscto_sin_igv;

                                    item.mto_vta_con_igv += oldItem.mto_vta_con_igv;
                                    item.mto_vta_sin_igv += oldItem.mto_vta_sin_igv;

                                    item.txt_observ = oldItem.txt_observ == "" ? item.txt_observ : string.Format("{0} | {1}", item.txt_observ, oldItem.txt_observ);

                                    details[index] = item;
                                }
                                //Si el producto no existe en el detalle -> agrega item
                                else
                                {
                                    details.Add(item);
                                }

                                CargarGridProd(details);
                                if (dgvDetail.Rows.Count > 0)
                                {
                                    ReadOnlyDescuentoRecargo(false);
                                }
                                CalcularMontos();
                                CalcularDescuentoRecargo(InputCalculo.PorcDescuento);
                                CalcularDescuentoRecargo(InputCalculo.PorcRecargo);
                            }
                            catch (Exception e)
                            {
                                MessageBox.Show($"No se pudo agregar el item correctamente. Excepción: {e}", "Excepción encontrada", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                            finally
                            {
                                prod = null;
                                CleanProducto();
                                txtCodProd.Focus();
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Ingrese valores válidos para el producto.", "Mensaje Eagle", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show($"No puede agregar más items. Ha alcanzado el número máximo de items({maxNumItems}).", "Mensaje Eagle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }