Beispiel #1
0
        private void BtnReportAllStock_Click(object sender, EventArgs e)
        {
            Provisions_Report reportPage = new Provisions_Report();

            reportPage.addItem("Report on Provisions Stock on Hand");
            reportPage.addItem("   On " + DateTime.Now.ToString("yyyy/MM/dd"));

            string inSQL = "SELECT Item_Name, Item_Description, Retail_Price, Stock_Level" +
                           " From Provisions_Current_Stock ORDER BY Item_Name ASC";


            reportPage.addItem("__________________________________________________________");

            using (OleDbDataAdapter itemAdapter = new OleDbDataAdapter(inSQL, connect))
            {
                DataSet dsItems = new DataSet();
                itemAdapter.Fill(dsItems);

                foreach (DataRow item in dsItems.Tables[0].Rows)
                {
                    double quantity       = double.Parse(item["Stock_Level"].ToString());
                    double worthPerItem   = double.Parse(item["Retail_Price"].ToString());
                    double itemTotalWorth = quantity * worthPerItem;

                    reportPage.addItem(item["Item_Name"].ToString() + " (" + item["Item_Description"] + ") | Total Value : R" + itemTotalWorth);
                    reportPage.addItem("\tStock Level: " + quantity);
                    reportPage.addItem("\tRetail Price: R" + worthPerItem);
                    reportPage.addItem("");
                }
            }
            reportPage.Show();
        }
Beispiel #2
0
        private void BtnMonthlyReport_Click(object sender, EventArgs e)
        {
            Provisions_Report reportPage = new Provisions_Report();

            reportPage.addItem("Monthly report of " + comboboxMonthlyReport.Text);

            sql = "SELECT io.ID, io.Date_Received, io.Stakeholder_Type, io.Stakeholder_Name, Input_Type" +
                  " FROM Provisions_In_Out io" +
                  " WHERE(";

            string inputDate = comboboxMonthlyReport.Text;
            string monthname = inputDate.Substring(0, inputDate.IndexOf(" "));


            int yearNr   = int.Parse(inputDate.Substring(inputDate.LastIndexOf(" ") + 1));
            int iMonthNo = Convert.ToDateTime("01-" + monthname + "-2011").Month;
            int dayCount = DateTime.DaysInMonth(yearNr, iMonthNo);

            DateTime strt = new DateTime(yearNr, iMonthNo, 1);
            DateTime endd = new DateTime(yearNr, iMonthNo, dayCount);

            string strtDate   = strt.ToString("yyyy/MM/dd 00:00:00");
            string endDateOut = endd.ToString("yyyy/MM/dd 23:59:59");

            sql += " io.Date_Received >= #" + strtDate + "# AND io.Date_Received <= #" + endDateOut + "#";
            sql += ") ORDER BY Date_Received ASC";

            using (OleDbDataAdapter adapter = new OleDbDataAdapter(sql, connect))
            {
                DataSet dstemp = new DataSet();
                adapter.Fill(dstemp);

                foreach (DataRow c in dstemp.Tables[0].Rows)
                {
                    reportPage.addItem("__________________________________________________________");
                    string add = "";
                    if (c["Input_Type"].ToString() == "Distributed")
                    {
                        add += "Distributed To ";
                    }
                    else
                    {
                        add += "Donation From ";
                    }

                    add += c["Stakeholder_Name"].ToString() + " (Distribution Type: " + c["Stakeholder_Type"].ToString() + ")";
                    reportPage.addItem(add);
                    string line = c["Date_Received"].ToString();
                    add = "Date: " + line.Substring(0, line.IndexOf(" "));
                    reportPage.addItem(add);
                    reportPage.addItem("Items:");
                    int itemID = int.Parse(c["ID"].ToString());

                    string inSQL = "SELECT cs.Item_Name, cs.Item_Description, cs.Retail_Price, st.Quantity" +
                                   " FROM Provisions_Support_Table st, Provisions_Current_Stock cs" +
                                   " WHERE ((cs.ID = st.Stock_ID) AND (In_Out_ID = " + itemID + "))";

                    using (OleDbDataAdapter itemAdapter = new OleDbDataAdapter(inSQL, connect))
                    {
                        DataSet dsItems = new DataSet();
                        itemAdapter.Fill(dsItems);
                        double donationWorth = 0.0;

                        foreach (DataRow item in dsItems.Tables[0].Rows)
                        {
                            double quantity       = double.Parse(item["Quantity"].ToString());
                            double worthPerItem   = double.Parse(item["Retail_Price"].ToString());
                            double itemTotalWorth = quantity * worthPerItem;
                            donationWorth += itemTotalWorth;
                            string inAdd = "\t" + item["Item_Name"].ToString() + " (" + item["Item_Description"] + ")\t* " + item["Quantity"].ToString() + "\t(Worth R" + itemTotalWorth + ")";

                            reportPage.addItem(inAdd);
                        }
                        reportPage.addItem("Total Worth of Distribution: R" + donationWorth);
                    }

                    reportPage.addItem("");
                }
            }

            reportPage.ShowDialog();
        }
Beispiel #3
0
        private void BtnGenerateDistributedReport_Click(object sender, EventArgs e)
        {
            Provisions_Report reportPage = new Provisions_Report();

            sql = "SELECT io.ID, io.Date_Received, io.Stakeholder_Type, io.Stakeholder_Name" +
                  " FROM Provisions_In_Out io" +
                  " WHERE(io.Input_Type = 'Distributed'";

            if (rbApecifyTimeOut.Checked == true)
            {
                DateTime strt = new DateTime();
                strt = dateTimePickerStartOut.Value;
                string strtDate = strt.ToString("yyyy/MM/dd 00:00:00");

                strt = datetimePickerEndOut.Value;
                string endDateOut = strt.ToString("yyyy/MM/dd 23:59:59");

                sql += " AND io.Date_Received >= #" + strtDate + "# AND io.Date_Received <= #" + endDateOut + "#";
            }

            if (rbSpecifyCategoryOut.Checked == true)
            {
                sql += " AND Stakeholder_Type = '" + comboboxDistributionCategory.Text + "'";
            }

            if (rbSpecifyDonorOut.Checked == true)
            {
                sql += " AND Stakeholder_Name = '" + comboboxDistributionName.Text + "'";
            }

            sql += ") ORDER BY Date_Received ASC";

            using (OleDbDataAdapter adapter = new OleDbDataAdapter(sql, connect))
            {
                DataSet dstemp = new DataSet();
                adapter.Fill(dstemp);

                string reportHeading = "Report on Distributions";

                if (rbSpecifyCategoryOut.Checked == true)
                {
                    if (rbSpecifyDonorOut.Checked == true)
                    {
                        reportHeading += " to " + comboboxDistributionName.Text + " (Distribution Type: " + comboboxDistributionCategory.Text + ")";
                    }
                    else
                    {
                        reportHeading += " to Distribution Type " + comboboxDistributionCategory.Text;
                    }
                }
                else if (rbSpecifyDonorOut.Checked == true)
                {
                    DataRow temp;
                    temp           = dstemp.Tables[0].Rows[0];
                    reportHeading += " to " + comboboxDistributionName.Text + " (Distribution Type: " + temp["Stakeholder_Type"].ToString() + ")";
                }
                reportPage.addItem(reportHeading);

                if (rbApecifyTimeOut.Checked == true)
                {
                    reportPage.addItem("   Between " + dateTimePickerStartOut.Text + " and " + datetimePickerEndOut.Text);
                }
                reportPage.addItem("");



                foreach (DataRow c in dstemp.Tables[0].Rows)
                {
                    reportPage.addItem("__________________________________________________________");
                    string add = "Distributed To " + c["Stakeholder_Name"].ToString() + " (Distribution Type: " + c["Stakeholder_Type"] + ")";
                    reportPage.addItem(add);
                    string line = c["Date_Received"].ToString();
                    add = "Date: " + line.Substring(0, line.IndexOf(" "));
                    reportPage.addItem(add);
                    reportPage.addItem("Items:");
                    int itemID = int.Parse(c["ID"].ToString());

                    string inSQL = "SELECT cs.Item_Name, cs.Item_Description, cs.Retail_Price, st.Quantity" +
                                   " FROM Provisions_Support_Table st, Provisions_Current_Stock cs" +
                                   " WHERE ((cs.ID = st.Stock_ID) AND (In_Out_ID = " + itemID + "))";

                    using (OleDbDataAdapter itemAdapter = new OleDbDataAdapter(inSQL, connect))
                    {
                        DataSet dsItems = new DataSet();
                        itemAdapter.Fill(dsItems);
                        double donationWorth = 0.0;

                        foreach (DataRow item in dsItems.Tables[0].Rows)
                        {
                            double quantity       = double.Parse(item["Quantity"].ToString());
                            double worthPerItem   = double.Parse(item["Retail_Price"].ToString());
                            double itemTotalWorth = quantity * worthPerItem;
                            donationWorth += itemTotalWorth;
                            string inAdd = "\t" + item["Item_Name"].ToString() + " (" + item["Item_Description"] + ")\t* " + item["Quantity"].ToString() + "\t(Worth R" + itemTotalWorth + ")";
                            reportPage.addItem(inAdd);
                        }
                        reportPage.addItem("Total Worth of Distribution: R" + donationWorth);
                    }
                    reportPage.addItem("");
                }
            }

            reportPage.ShowDialog();
        }