Exemple #1
0
        public bool compareToDatabase()
        {
            sql = @"SELECT Ventas.Fecha, Ventas.idProducto, Productos.Nombre_Producto from Ventas
                   JOIN Productos ON Ventas.idProducto=Productos.idProducto";
            conn2.Connection();
            command    = new SqlCommand(sql, conn2.conn);
            dataReader = command.ExecuteReader();
            while (dataReader.Read())
            {
                if (getDateFromText() == dataReader.GetValue(0).ToString() && comboProd.SelectedItem.ToString() == dataReader.GetValue(2).ToString())
                {
                    MessageBox.Show("La venta ya existe en la base de datos.");
                    return(false);
                }
            }

            dataReader.Close();
            return(true);
        }
Exemple #2
0
 private void cargarComboFecha()
 {
     sql = "SELECT Distinct(Fecha) from Ventas";
     conn2.Connection();
     command    = new SqlCommand(sql, conn2.conn);
     dataReader = command.ExecuteReader();
     while (dataReader.Read())
     {
         comboFecha.Items.Add(dataReader.GetValue(0).ToString());
     }
     comboFecha.SelectedIndex = 0;
     dataReader.Close();
 }
Exemple #3
0
 public bool compareToDatabase()
 {
     sql = "SELECT Nombre_Producto from Productos";
     conn2.Connection();
     command    = new SqlCommand(sql, conn2.conn);
     dataReader = command.ExecuteReader();
     while (dataReader.Read())
     {
         if (txtBoxNombreProd.Text == dataReader.GetValue(0).ToString())
         {
             return(true);
         }
     }
     dataReader.Close();
     return(false);
 }
Exemple #4
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();
        }
Exemple #5
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;
        }