private void modificarPedido()
        {
            string descuento = (double.Parse(txtCuenta.Text) - double.Parse(txtTotal.Text)).ToString();
            string sqlQuery  = "Update Pedido set Pagado='True',Descuento='" + descuento + "',TotalVenta='" + total + "' where PedidoId=" + pedidoId;

            CommonUtils.ConexionBD.Actualizar(sqlQuery);
            sqlQuery = "Delete from Pedido_Producto where PedidoId=" + pedidoId;
            CommonUtils.ConexionBD.Actualizar(sqlQuery);
            List <DataRow> listaPedidos = dataTable.AsEnumerable().ToList();

            foreach (DataRow item in listaPedidos)
            {
                string costoReceta = CalculadoraVentas.obtenerCostoReceta(item);//this.obtenerCostoReceta(item);
                sqlQuery = "insert into Pedido_Producto(PedidoId,ProductoId,Cantidad,Total,CostoReceta,PrecioProducto,Descripcion) values('" + pedidoId + "','" + item["Id"] + "','" + item["Cantidad"] + "','" + item["Subtotal"] + "','" + costoReceta + "','" + item["Precio"] + "','" + item["Descripcion"] + "')";
                CommonUtils.ConexionBD.Actualizar(sqlQuery);
            }
        }
Beispiel #2
0
        private void registrarReserva(CommonUtils.Cliente cliente1)
        {
            string entregado    = "False";
            string tipoPedido   = "Reserva";
            string pagado       = "False";
            string fechaEntrega = dateEditFechaEntrega.DateTime.ToString();
            double total        = double.Parse(columnTotal.SummaryItem.SummaryValue.ToString());

            this.manageClient(cliente1);
            string         sqlQuery     = "Insert into Pedido(FechaPedidoText,FechaEntregaText,Descuento,TipoPedido,Pagado,FechaEntrega,Entregado,ClienteId,TotalVenta,FechaPedido,NombreCliente,Direccion,Telefono,NIT,NumeroPedido) values('" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss.fff") + "','" + dateEditFechaEntrega.DateTime.ToString("yyyy-MM-dd H:mm:ss.fff") + "','" + 0 + "','" + tipoPedido + "','" + pagado + "','" + fechaEntrega + "','" + entregado + "','" + cliente1.IdCliente + "','" + total + "','" + DateTime.Now + "','" + cliente1.Nombre + "','" + cliente1.Direccion + "','" + cliente1.Telefono + "','" + cliente1.NIT + "','" + cliente1.NumeroPedido + "')";
            decimal        idPedido     = CommonUtils.ConexionBD.ActualizarRetornandoId(sqlQuery);
            List <DataRow> listaPedidos = dataTable.AsEnumerable().ToList();

            foreach (DataRow item in listaPedidos)
            {
                string costoReceta = CalculadoraVentas.obtenerCostoReceta(item);    //this.obtenerCostoReceta(item);
                sqlQuery = "insert into Pedido_Producto(PedidoId,ProductoId,Cantidad,Total,CostoReceta,PrecioProducto,Descripcion) values('" + idPedido + "','" + item["Id"] + "','" + item["Cantidad"] + "','" + item["Subtotal"] + "','" + costoReceta + "','" + item["Precio"] + "','" + item["Descripcion"] + "')";
                CommonUtils.ConexionBD.Actualizar(sqlQuery);
            }
        }
        private void registrarPedidoInmediato()
        {
            string descuento = (double.Parse(txtCuenta.Text) - double.Parse(txtTotal.Text)).ToString();
            string entregado = "True";

            string tipoPedido = "Inmediato";

            this.manageClient();
            int    idCliente = cliente.IdCliente;
            string nit       = cliente.NIT;

            string         sqlQuery     = "Insert into Pedido(FechaPedidoText,FechaEntregaText,Descuento,TipoPedido,Pagado,FechaEntrega,Entregado,ClienteId,TotalVenta,FechaPedido,NombreCliente,Direccion,Telefono,NIT,NumeroPedido) values('" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss.fff") + "','" + DateTime.Now.ToString("yyyy-MM-dd H:mm:ss.fff") + "','" + descuento + "','" + tipoPedido + "','" + pagado + "','" + DateTime.Now + "','" + entregado + "','" + idCliente + "','" + total + "','" + DateTime.Now + "','" + cliente.Nombre + "','" + cliente.Direccion + "','" + cliente.Telefono + "','" + nit + "','" + cliente.NumeroPedido + "')";
            decimal        idPedido     = CommonUtils.ConexionBD.ActualizarRetornandoId(sqlQuery);
            List <DataRow> listaPedidos = dataTable.AsEnumerable().ToList();

            foreach (DataRow item in listaPedidos)
            {
                string costoReceta = CalculadoraVentas.obtenerCostoReceta(item);//this.obtenerCostoReceta(item);
                sqlQuery = "insert into Pedido_Producto(PedidoId,ProductoId,Cantidad,Total,CostoReceta,PrecioProducto,Descripcion) values('" + idPedido + "','" + item["Id"] + "','" + item["Cantidad"] + "','" + item["Subtotal"] + "','" + costoReceta + "','" + item["Precio"] + "','" + item["Descripcion"] + "')";
                CommonUtils.ConexionBD.Actualizar(sqlQuery);
            }
        }
Beispiel #4
0
        /* private void View_CellValueChanging( object sender , DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e )
         * {
         *  DataRow row=gridViewItems.GetFocusedDataRow();
         *   if (e.Column.Caption != "Descripcion")
         *   {
         *       if (Convert.ToDecimal(e.Value) < 1)
         *       {
         *           this.gridViewItems.SetRowCellValue(e.RowHandle, this.gridViewItems.Columns[1].FieldName, CANTIDAD_MINIMA);
         *           return;
         *       }
         *
         *       double subTotal = Convert.ToDouble(e.Value) * Convert.ToDouble(row[3].ToString());// gridProducto.ventas.Precio;
         *       this.gridViewItems.SetRowCellValue(e.RowHandle, this.gridViewItems.Columns[3].FieldName, subTotal);
         *
         *       gridViewItems.UpdateTotalSummary();
         *   }
         * }
         */
        private void btnVenta_Click(object sender, EventArgs e)
        {
            this.calcularNumeroPedido();
            //    string sql = "INSERT INTO Cliente (Nombre,NIT,Telefono,Direccion)  VALUES ('" +
            //                 mruCliente.Text + "','" + mruNIT.Text + "','" +CommonUtils.StringUtils.EscapeSQL( txtTelefono.Text) + "','" +CommonUtils.StringUtils.EscapeSQL( txtDireccion.Text) + "')";
            //     CommonUtils.ConexionBD.Actualizar( sql );

            if (dataTable.Rows.Count == 0)
            {
                //no hay nada para vender
                return;
            }
            else if (llamadoDePnlReservas)
            {
                CalculadoraVentas calculadora = new CalculadoraVentas(reservasPanel, dataTable, this.ParentForm, float.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), true, false, cliente);
                calculadora.PedidoId = pedidoId;
                calculadora.Ventas   = reservasPanel.FormReservasPagar;
                calculadora.checkBtn = this.chbtn;
                calculadora.ShowDialog();
                calculadora.Refresh();
            }
            else if (txtTipoPedido.SelectedItem.ToString() == "Inmediato")
            {
                CommonUtils.Cliente cliente = new CommonUtils.Cliente(0, /*mruCliente.Text*/ txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text, int.Parse(txtNumPedido.Text));

                CalculadoraVentas calculadora = new CalculadoraVentas(this, dataTable, this.ParentForm, double.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), false, true, cliente);
                calculadora.ShowDialog();
                calculadora.Refresh();
            }
            else if (txtEstadoPedido.SelectedItem.ToString() == "Pagado" && txtTipoPedido.SelectedItem.ToString() == "Reserva")//mostramos calculadora
            {
                if (!dxErrorProvider.HasErrors)
                {
                    CommonUtils.Cliente cliente     = new CommonUtils.Cliente(0, txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text, int.Parse(txtNumPedido.Text));
                    CalculadoraVentas   calculadora = new CalculadoraVentas(this, dataTable, this.ParentForm, float.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), true, true, cliente);
                    calculadora.FechaEntrega         = dateEditFechaEntrega.DateTime.ToString("yyyy-MM-dd H:mm:ss.fff");
                    calculadora.FechaEntregaNoFormat = dateEditFechaEntrega.DateTime.ToString( );
                    calculadora.ShowDialog();
                    calculadora.Refresh();
                }
                else
                {
                    this.GetErrorProviderMessages();
                }
            }
            else //hacemos reserva directamente.
            {
                if (!dxErrorProvider.HasErrors)
                {
                    try
                    {
                        CommonUtils.Cliente client = new CommonUtils.Cliente(0, txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text, int.Parse(txtNumPedido.Text));
                        this.registrarReserva(client);
                        this.ResetFields();
                        MessageBarValue = "La reserva fue creada satisfactoriamente.";

                        // MessageBox.Show(this, "Reserva Realizada correctamente", "Reserva ", MessageBoxButtons.OK);
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.Message, ex);
                        MessageBarValue = "No se pudo registrar reserva sin pagar. Hubo un error: " + ex.Message;
                    }
                    finally
                    {
                        alertControlPnlVentas.Show(this.FindForm(), "Reserva.", MessageBarValue, Image);
                    }
                }
                else
                {
                    this.GetErrorProviderMessages();
                }
            }
        }
Beispiel #5
0
       /* private void View_CellValueChanging( object sender , DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e )
        {
           DataRow row=gridViewItems.GetFocusedDataRow();
            if (e.Column.Caption != "Descripcion")
            {
                if (Convert.ToDecimal(e.Value) < 1)
                {
                    this.gridViewItems.SetRowCellValue(e.RowHandle, this.gridViewItems.Columns[1].FieldName, CANTIDAD_MINIMA);
                    return;
                }

                double subTotal = Convert.ToDouble(e.Value) * Convert.ToDouble(row[3].ToString());// gridProducto.ventas.Precio;
                this.gridViewItems.SetRowCellValue(e.RowHandle, this.gridViewItems.Columns[3].FieldName, subTotal);

                gridViewItems.UpdateTotalSummary();
            }
        }
        */
        private void btnVenta_Click( object sender , EventArgs e )
        {
            this.calcularNumeroPedido();
        //    string sql = "INSERT INTO Cliente (Nombre,NIT,Telefono,Direccion)  VALUES ('" +
      //                 mruCliente.Text + "','" + mruNIT.Text + "','" +CommonUtils.StringUtils.EscapeSQL( txtTelefono.Text) + "','" +CommonUtils.StringUtils.EscapeSQL( txtDireccion.Text) + "')";
       //     CommonUtils.ConexionBD.Actualizar( sql );
           
            if (dataTable.Rows.Count == 0)
            {
                //no hay nada para vender
                return;
            }
            else if (llamadoDePnlReservas)
            {
                CalculadoraVentas calculadora = new CalculadoraVentas(reservasPanel, dataTable, this.ParentForm, float.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), true, false, cliente);
                calculadora.PedidoId = pedidoId;
                calculadora.Ventas = reservasPanel.FormReservasPagar;
                calculadora.checkBtn = this.chbtn;
                calculadora.ShowDialog();
                calculadora.Refresh();
            }
            else if (txtTipoPedido.SelectedItem.ToString() == "Inmediato")
            {
                CommonUtils.Cliente cliente = new CommonUtils.Cliente(0, /*mruCliente.Text*/txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text,int.Parse(txtNumPedido.Text));
                
                CalculadoraVentas calculadora = new CalculadoraVentas(this, dataTable, this.ParentForm, double.Parse(columnTotal.SummaryItem.SummaryValue.ToString()) , false, true, cliente);
                calculadora.ShowDialog();
                calculadora.Refresh();

            }
            else if (txtEstadoPedido.SelectedItem.ToString() == "Pagado" && txtTipoPedido.SelectedItem.ToString() == "Reserva")//mostramos calculadora
            {
                if (!dxErrorProvider.HasErrors)
                {
                    CommonUtils.Cliente cliente = new CommonUtils.Cliente(0, txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text,int.Parse(txtNumPedido.Text));
                    CalculadoraVentas calculadora = new CalculadoraVentas(this, dataTable, this.ParentForm, float.Parse(columnTotal.SummaryItem.SummaryValue.ToString()), true, true, cliente);
                    calculadora.FechaEntrega = dateEditFechaEntrega.DateTime.ToString("yyyy-MM-dd H:mm:ss.fff");
                    calculadora.FechaEntregaNoFormat = dateEditFechaEntrega.DateTime.ToString( );
                    calculadora.ShowDialog();
                    calculadora.Refresh();
                }
                else
                {
                    this.GetErrorProviderMessages();
                }
            }
            else //hacemos reserva directamente.
            {
                if (!dxErrorProvider.HasErrors)
                {
                    try
                    {
                        CommonUtils.Cliente client = new CommonUtils.Cliente(0, txtCliente.Text, txtTelefono.Text, txtNIT.Text, txtDireccion.Text, int.Parse(txtNumPedido.Text));
                        this.registrarReserva(client);
                        this.ResetFields();
                        MessageBarValue="La reserva fue creada satisfactoriamente.";
                        
                       // MessageBox.Show(this, "Reserva Realizada correctamente", "Reserva ", MessageBoxButtons.OK);
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex.Message, ex);
                         MessageBarValue = "No se pudo registrar reserva sin pagar. Hubo un error: " + ex.Message;
                    }
                    finally
                    {
                        alertControlPnlVentas.Show(this.FindForm(), "Reserva.", MessageBarValue, Image);
                    }                    
                }
                else
                {
                    this.GetErrorProviderMessages();
                }
            }
            
        }