Example #1
0
        private void ventaDiaria()
        {
            sql = @"SELECT SUM(Ventas.vendido*Productos.Precio) AS Venta
                  FROM Productos
                  LEFT JOIN Ventas ON Productos.idProducto=Ventas.idProducto
                  WHERE Ventas.Fecha='" + comboFecha.SelectedItem.ToString() + "'";
            SQLConn conn2 = new SQLConn();

            conn2.Connection();
            command    = new SqlCommand(sql, conn2.conn);
            dataReader = command.ExecuteReader();
            while (dataReader.Read())
            {
                txtVentaDiaria.Text = "$" + dataReader.GetValue(0).ToString();
            }
            dataReader.Close();
        }
Example #2
0
        private void searchProduct(String query, String optOrder = "")
        {
            table.Visible = false;
            table.Controls.Clear();
            table.RowStyles.Clear();
            table.RowCount = 1;
            table.Controls.Add(labelID, 0, table.RowCount - 1);
            table.Controls.Add(labelProducto, 1, table.RowCount - 1);
            table.Controls.Add(labelPrecio, 2, table.RowCount - 1);
            table.Controls.Add(labelVenta, 3, table.RowCount - 1);
            table.Controls.Add(labelProveedor, 4, table.RowCount - 1);
            sql           = "";
            panel1.Height = table.RowCount * 30;
            sql           = @"SELECT Productos.idProducto, Productos.Nombre_Producto, Productos.Precio,
                      Ventas.vendido*Productos.Precio AS Venta,
                      Proveedor.Nombre_Proveedor
                      FROM Productos
                      INNER JOIN Proveedor ON Productos.idProveedor=Proveedor.idProveedor
                      LEFT JOIN Ventas ON Productos.idProducto=Ventas.idProducto ";
            if (!string.IsNullOrEmpty(query))
            {
                sql += "WHERE Productos.Nombre_Producto  LIKE '" + query + "%' ";
            }
            sql += "AND Ventas.Fecha='" + comboFecha.SelectedItem.ToString() + "'";
            sql += optOrder;
            SQLConn conn2 = new SQLConn();

            conn2.Connection();
            command    = new SqlCommand(sql, conn2.conn);
            dataReader = command.ExecuteReader();
            while (dataReader.Read())
            {
                table.RowCount++;
                panel1.Height = table.RowCount * 30;
                Label myLab = new Label();
                myLab.Width    = 200;
                myLab.AutoSize = true;
                myLab.Anchor   = AnchorStyles.None;
                myLab.Dock     = DockStyle.Fill;
                Label labID = new Label();
                labID.TextAlign = ContentAlignment.MiddleCenter;
                table.RowStyles.Add(new RowStyle(SizeType.Absolute, 30F));
                labID.Text = dataReader.GetValue(0).ToString();
                table.Controls.Add(labID, 0, table.RowCount - 1);
                myLab.Text = dataReader.GetValue(1).ToString();
                table.Controls.Add(myLab, 1, table.RowCount - 1);
                table.Controls.Add(new Label()
                {
                    Text = "$" + dataReader.GetValue(2).ToString()
                }, 2, table.RowCount - 1);
                table.Controls.Add(new Label()
                {
                    Text = "$" + dataReader.GetValue(3).ToString()
                }, 3, table.RowCount - 1);
                table.Controls.Add(new Label()
                {
                    Text = dataReader.GetValue(4).ToString()
                }, 4, table.RowCount - 1);
            }
            dataReader.Close();
            table.Visible = true;
        }