Example #1
0
 private void SetButtonInfo(string tipo, object sender, EventArgs e)
 {
     if (sender is Button)
     {
         Button  btn     = sender as Button;
         DataSet dsBoton = DataUtil.FillDataSet(DataBaseQuerys.ProductoBoton(DataUtil.GetString(btn.Tag), DataUtil.GetString(subCategoriaIdSelected)), "producto_boton");
         if (dsBoton.Tables[0].Rows.Count.Equals(0))
         {
             DialogResult result = MessageBox.Show("Desea asignar un producto al boton?", "Asignar Producto", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (result == DialogResult.Yes)
             {
                 frmQuickButtons frmQuickButtonsForm = new frmQuickButtons();
                 frmQuickButtonsForm.categoriaId    = categoriaIdSelected.ToString();
                 frmQuickButtonsForm.subCategoriaId = subCategoriaIdSelected.ToString();
                 frmQuickButtonsForm.botonId        = DataUtil.GetString(btn.Tag);
                 frmQuickButtonsForm.tipo           = tipo;
                 frmQuickButtonsForm.ShowDialog();
                 GetButtonInfo(btn, subCategoriaIdSelected);
             }
         }
         else
         {
             DataSet dsProducto = DataUtil.FillDataSet(DataBaseQuerys.Producto(DataUtil.GetString(dsBoton.Tables[0].Rows[0], "Producto_id"), string.Empty, string.Empty, string.Empty), "producto");
             txtCodigoProducto.Text = DataUtil.GetString(dsBoton.Tables[0].Rows[0], "Producto_id");
             txtProducto.Text       = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Producto_descripcion");
             txtPrecioUnitario.Text = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Precio_final");
             this.btnAdd_Click(tipo, null);
         }
     }
 }
Example #2
0
        private bool PasarProducto(int cuentaNumber)
        {
            bool result = false;
            DataGridViewSelectedRowCollection Seleccionados = dgwCuenta.SelectedRows;

            foreach (DataGridViewRow item in Seleccionados)
            {
                DataSet dsProducto = DataUtil.FillDataSet(DataBaseQuerys.Producto(item.Cells["CODIGO"].Value.ToString(), string.Empty, string.Empty, string.Empty), "producto");
                txtCodigoProducto.Text  = item.Cells["CODIGO"].Value.ToString();
                txtProducto.Text        = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Producto_descripcion");
                txtPrecioUnitario.Text  = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Precio_final");
                txtPrecioProveedor.Text = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Precio_proveedor");
                txtCantidad.Text        = item.Cells["CANTIDAD"].Value.ToString();
                txtDescuento.Text       = item.Cells["DESCUENTO"].Value.ToString();
                AddDetail(cuentaNumber);

                subTotal0        = CalculoMontos(DataUtil.GetDouble(dgwCuenta.Rows[item.Index].Cells["PRECIO_FINAL"].Value), false, subTotal0);
                txtSubTotal.Text = subTotal0.ToString(DataUtil.Format.Decimals);
                this.dgwCuenta.Rows.RemoveAt(item.Index);
                result = true;
            }

            if (result == false)
            {
                MessageBox.Show("Se debe seleccionar al menos 1 producto a divir.", "Informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            return(result);
        }
Example #3
0
        private void btnViewOrder_Click(object sender, EventArgs e)
        {
            dgwCuenta.Rows.Clear();
            subTotal       = 0;
            totalDescuento = 0;

            btnViewOrder.Visible   = false;
            btnNewOrder.Visible    = true;
            btnCreateOrder.Visible = false;

            var dsPedidoDetalleInfo = DataUtil.FillDataSet(DataBaseQuerys.FillMainDataSet("pedido_detalle", "pedido_id", DataUtil.GetString(pedidoID), string.Empty), "pedido_detalle");

            foreach (DataRow pedidoDetalleRow in dsPedidoDetalleInfo.Tables["pedido_detalle"].Rows)
            {
                var dsProducto = DataUtil.FillDataSet(DataBaseQuerys.Producto(DataUtil.GetString(pedidoDetalleRow["Codigo_Producto"]), string.Empty,
                                                                              string.Empty, string.Empty), "producto");
                var precioUnitario  = DataUtil.GetDouble(dsProducto.Tables[0].Rows[0], "Precio_final");
                var precioProveedor = DataUtil.GetDouble(dsProducto.Tables[0].Rows[0], "Precio_proveedor");
                var descuento       = DataUtil.GetDouble(pedidoDetalleRow["Descuento"]);
                var cantidad        = DataUtil.GetInt(pedidoDetalleRow["Cantidad"]);

                double calculoMonto;
                double descuentoMonto = 0;
                if (Math.Abs(descuento) > 0)
                {
                    calculoMonto = Math.Round((precioUnitario * (1 - descuento / 100)) * cantidad, 2);
                    var totalSinDescuento = Math.Round(precioUnitario * cantidad, 2);
                    descuentoMonto = Math.Round(totalSinDescuento - calculoMonto, 2);
                }
                else
                {
                    calculoMonto = precioUnitario * cantidad;
                }

                var montoIgv = Math.Round((calculoMonto * 1.18), 1);

                string[] row =
                {
                    DataUtil.GetString(pedidoDetalleRow["Linea"]),
                    DataUtil.GetString(pedidoDetalleRow["Codigo_Producto"]),
                    DataUtil.GetString(pedidoDetalleRow["Descripcion_Producto"]),
                    DataUtil.GetString(pedidoDetalleRow["Cantidad"]),
                    DataUtil.GetString(pedidoDetalleRow["Descuento"]),
                    DataUtil.GetString(calculoMonto),
                    DataUtil.GetString(precioUnitario),
                    DataUtil.GetString(precioProveedor),
                    DataUtil.GetString(montoIgv),
                    DataUtil.GetString(descuentoMonto)
                };
                dgwCuenta.Rows.Add(row);
                CalculoMontos(calculoMonto, true, descuentoMonto);
            }
        }
Example #4
0
        private void SetButtonInfo(string tipo, object sender, EventArgs e)
        {
            if (sender is Button)
            {
                Button btn = sender as Button;

                DataSet dsBoton = DataUtil.FillDataSet(DataBaseQuerys.ProductoBoton(DataUtil.GetString(btn.Tag), DataUtil.GetString(subCategoriaIdSelected)), "producto_boton");
                if (dsBoton.Tables[0].Rows.Count.Equals(1))
                {
                    if (!productoPedido)
                    {
                        frmQuickButtons frmQuickButtonsForm = new frmQuickButtons();
                        frmQuickButtonsForm.categoriaId    = categoriaIdSelected.ToString();
                        frmQuickButtonsForm.subCategoriaId = subCategoriaIdSelected.ToString();
                        frmQuickButtonsForm.botonId        = DataUtil.GetString(btn.Tag);
                        frmQuickButtonsForm.tipo           = tipo;
                        frmQuickButtonsForm.adding         = false;
                        frmQuickButtonsForm.ShowDialog();
                        GetButtonInfo(btn, subCategoriaIdSelected);
                    }
                    else
                    {
                        DataSet dsProducto = DataUtil.FillDataSet(DataBaseQuerys.Producto(DataUtil.GetString(dsBoton.Tables[0].Rows[0], "Producto_id"),
                                                                                          string.Empty,
                                                                                          string.Empty,
                                                                                          string.Empty), "producto");
                        AppConstant.ProductButtonSelected.ProductoId          = DataUtil.GetString(dsBoton.Tables[0].Rows[0], "Producto_id");
                        AppConstant.ProductButtonSelected.ProductoDescripcion = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Producto_descripcion");
                        AppConstant.ProductButtonSelected.PrecioFinal         = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Precio_final");
                        AppConstant.ProductButtonSelected.PrecioProveedor     = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Precio_proveedor");
                        this.Close();
                    }
                }
                else if (dsBoton.Tables[0].Rows.Count.Equals(0))
                {
                    DialogResult result = MessageBox.Show("Desea asignar un producto al boton?", "Asignar Producto", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        frmQuickButtons frmQuickButtonsForm = new frmQuickButtons();
                        frmQuickButtonsForm.categoriaId    = categoriaIdSelected.ToString();
                        frmQuickButtonsForm.subCategoriaId = subCategoriaIdSelected.ToString();
                        frmQuickButtonsForm.botonId        = DataUtil.GetString(btn.Tag);
                        frmQuickButtonsForm.tipo           = tipo;
                        frmQuickButtonsForm.ShowDialog();
                        GetButtonInfo(btn, subCategoriaIdSelected);
                    }
                }
            }
        }
Example #5
0
        private void ViewOrder()
        {
            dgwCuenta.Rows.Clear();

            DataSet dsPedidoDetalleInfo = DataUtil.FillDataSet(DataBaseQuerys.FillMainDataSet("pedido_detalle", "pedido_id", DataUtil.GetString(pedidoIDView), string.Empty), "pedido_detalle");

            foreach (DataRow pedidoDetalleRow in dsPedidoDetalleInfo.Tables["pedido_detalle"].Rows)
            {
                DataSet dsProducto = DataUtil.FillDataSet(DataBaseQuerys.Producto(DataUtil.GetString(pedidoDetalleRow["Codigo_Producto"]), string.Empty, string.Empty, string.Empty), "producto");
                txtCodigoProducto.Text  = DataUtil.GetString(pedidoDetalleRow["Codigo_Producto"]);
                txtProducto.Text        = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Producto_descripcion");
                txtPrecioUnitario.Text  = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Precio_final");
                txtPrecioProveedor.Text = DataUtil.GetString(dsProducto.Tables[0].Rows[0], "Precio_proveedor");
                txtCantidad.Text        = DataUtil.GetString(pedidoDetalleRow["Cantidad"]);
                txtDescuento.Text       = DataUtil.GetString(pedidoDetalleRow["Descuento"]);
                AddDetail(0);
            }
        }
Example #6
0
 private bool VerificarDuplicados()
 {
     if (IsReadyToSaveFirst())
     {
         string  categoriaWhere = "Producto_categoria_descripcion = '" + DataUtil.GetString(cbCategoria.SelectedItem) + "'";
         DataSet dsSearch       = DataUtil.FillDataSet(DataBaseQuerys.Producto(string.Empty,
                                                                               cbTipoProducto.SelectedItem.ToString(),
                                                                               DataUtil.FindSingleRow("producto_categoria", "Producto_categoria_id", categoriaWhere),
                                                                               txtDescripcion.Text.Trim().Replace("'", "''")), "producto");
         if (dsSearch.Tables[0].Rows.Count > 0)
         {
             MessageBox.Show("El producto '" + txtDescripcion.Text.Trim() + "' ya existe.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
             return(false);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }