Esempio n. 1
0
        private void ButtonReports_Click(object sender, EventArgs e)
        {
            Reports reports = new Reports();

            ToggleColor(ButtonReports);
            ContentPanel.Controls.Clear();
            CreateUserControl(reports);

            DatabaseWorking database      = new DatabaseWorking();
            string          command       = "select distinct soldDate from saleOrder";
            SqlConnection   sqlConnection = database.CreateConnectionToSqlDatabase();

            database.AddItemsToCombobox(reports.comboBoxFromdate, command, sqlConnection);
            database.AddItemsToCombobox(reports.comboBoxTillDate, command, sqlConnection);

            command = "select soldDate, SUM([totalPrice]) from saleOrder   group by soldDate ";
            SqlCommand     cmd     = new SqlCommand(command, sqlConnection);
            SqlDataAdapter adapter = new SqlDataAdapter(cmd);
            DataTable      dt      = new DataTable();

            adapter.Fill(dt);

            foreach (DataRow dataRow in dt.Rows)
            {
                reports.chartSalesPerday.Series["Series1"].Points.AddXY(dataRow[0].ToString(), dataRow[1].ToString());
            }
        }
Esempio n. 2
0
        private void ButtonPurchase_Click(object sender, EventArgs e)
        {
            DatabaseWorking working     = new DatabaseWorking();
            Purcahse        purcahseTab = new Purcahse();

            ToggleColor(ButtonPurchase);
            ContentPanel.Controls.Clear();
            CreateUserControl(purcahseTab);

            if (purcahseTab.DatagridStock.Rows.Count != 0)
            {
                string[] sql = new string[2];
                sql[0] = "select barcode as Barcode, medicineName as Prouct, quantity as Quantity, expirayDate as [Expiry Date] from stock join medicine on stock.medicneID = medicine.medicineID";
                sql[1] = "select SupplierName from supplier";

                SqlConnection conn = working.CreateConnectionToSqlDatabase();
                working.AddItemsToDataGrid(purcahseTab.DatagridStock, sql[0], conn);
                working.AddItemsToCombobox(purcahseTab.comboBox1, sql[1], conn);
                purcahseTab.comboBox1.SelectedIndex = 0;
            }
        }