public void AddMethodOK()
        {
            clsReportsCollection AllReports = new clsReportsCollection();

            //create the item of test data
            clsReports TestItem = new clsReports();

            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.ProfitOrLoss = true;
            TestItem.EmployeeId   = 2;
            TestItem.DateAdded    = DateTime.Now.Date;
            TestItem.EmployeeName = "Akshay";
            TestItem.Expenses     = 200;
            TestItem.Total        = 1000;

            //set ThisReports to the test data
            AllReports.ThisReport = TestItem;

            //add the record
            PrimaryKey = AllReports.Add();

            //set the primary key of the test data
            TestItem.EmployeeId = PrimaryKey;

            //find the record
            AllReports.ThisReport.Find(PrimaryKey);

            //test to see that the two values are the same
            Assert.AreEqual(AllReports.ThisReport, TestItem);
        }
        public void ReportListOK()
        {
            clsReportsCollection AllReports = new clsReportsCollection();

            //create some test data to assign to the property
            //in this case data neeeds list of objects
            List <clsReports> TestList = new List <clsReports>();
            clsReports        TestItem = new clsReports();

            //set its properties
            TestItem.ProfitOrLoss = true;
            TestItem.EmployeeId   = 2;
            TestItem.EmployeeName = "Akshay";
            TestItem.Expenses     = 200;
            TestItem.Total        = 1000;

            //add item to test list
            TestList.Add(TestItem);

            //assign the data to the property
            AllReports.ReportList = TestList;

            //test to see the two values are the same
            Assert.AreEqual(AllReports.ReportList, TestList);
        }
        public void ListAndCountOK()
        {
            clsReportsCollection AllReports = new clsReportsCollection();

            //create some data to assign to the property , in this case the data needs to be a list of objects
            List <clsReports> TestList = new List <clsReports>();

            //add an item to the list and create the item of test data
            clsReports TestItem = new clsReports();

            //set the properties of the test object
            TestItem.ProfitOrLoss = true;
            TestItem.EmployeeId   = 2;
            TestItem.DateAdded    = DateTime.Now.Date;
            TestItem.EmployeeName = "Akshay";
            TestItem.Expenses     = 200;
            TestItem.Total        = 1000;

            //add the item to the test list
            TestList.Add(TestItem);

            //assign the data to the property
            AllReports.ReportList = TestList;

            //test to see that two values are the same
            Assert.AreEqual(AllReports.Count, TestList.Count);
        }
        public void ReportByEmployeeNameTestDataFound()
        {
            clsReportsCollection FilteredEmployeeNames = new clsReportsCollection();

            //var to store the outcome
            Boolean OK = true;

            //apply a employee name that does not exist
            FilteredEmployeeNames.ReportByEmployeeName("John");

            //check that the correct number of record is found
            if (FilteredEmployeeNames.Count == 2)
            {
                //check that the first record ID is 2
                if (FilteredEmployeeNames.ReportList[0].EmployeeId != 2)
                {
                    OK = false;
                }
                //check that the first record Id is 37
                if (FilteredEmployeeNames.ReportList[1].EmployeeId != 37)
                {
                    OK = false;
                }
            }

            else
            {
                OK = false;
            }
            //test to see that there are no records
            Assert.IsTrue(OK);
        }
        public void InstanceOK()
        {
            clsReportsCollection AllReports = new clsReportsCollection();

            //test to see that it exists
            Assert.IsNotNull(AllReports);
        }
        public void ReportByEmployeeNameNoneFound()
        {
            clsReportsCollection FilteredEmployeeNames = new clsReportsCollection();

            //apply a employee name that does not exist
            FilteredEmployeeNames.ReportByEmployeeName("xxxxxx");

            //test to see  that there are no records
            Assert.AreEqual(0, FilteredEmployeeNames.Count);
        }
        public void ReportByEmployeeNameMethodOK()
        {
            clsReportsCollection AllReports = new clsReportsCollection();

            //create an instance of the filtered data
            clsReportsCollection FilteredEmployeeNames = new clsReportsCollection();

            //apply a blank string (should return all records)
            FilteredEmployeeNames.ReportByEmployeeName("");

            //test to see that the two values are the same
            Assert.AreEqual(AllReports.Count, FilteredEmployeeNames.Count);
        }
    protected void btnYes_Click(object sender, EventArgs e)
    {
        //create a new instance of the address book
        clsReportsCollection ReportsBook = new clsReportsCollection();

        //find the record to delete
        ReportsBook.ThisReport.Find(EmployeeId);

        //delete the record
        ReportsBook.Delete();

        //redirect back to the main page
        Response.Redirect("5ReportsList.aspx");
    }
Exemple #9
0
    private void DisplayReport()
    {
        clsReportsCollection ReportsEmployeeId = new clsReportsCollection();

        //find the record to update
        ReportsEmployeeId.ThisReport.Find(EmployeeId);

        //display the data for this record
        txtEmployeeId.Text   = ReportsEmployeeId.ThisReport.EmployeeId.ToString();
        txtEmployeeName.Text = ReportsEmployeeId.ThisReport.EmployeeName;
        txtTotal.Text        = ReportsEmployeeId.ThisReport.Total.ToString();
        txtDateAdded.Text    = ReportsEmployeeId.ThisReport.DateAdded.ToString();
        txtExpenses.Text     = ReportsEmployeeId.ThisReport.Expenses.ToString();
        chkProfit.Checked    = ReportsEmployeeId.ThisReport.ProfitOrLoss;
        chkLoss.Checked      = ReportsEmployeeId.ThisReport.ProfitOrLoss;
    }
Exemple #10
0
    void DisplayReports()
    {
        clsReportsCollection Reports = new clsReportsCollection();

        //set the data source to the list of Employees in the collection
        lstReportsList.DataSource = Reports.ReportList;

        //set the name of the primary key
        lstReportsList.DataValueField = "EmployeeId";

        //set the data field to display
        lstReportsList.DataTextField = "EmployeeName";

        //bind the data to the list
        lstReportsList.DataBind();
    }
        public void UpdateMethodOK()
        {
            clsReportsCollection AllReports = new clsReportsCollection();

            //create the item of test data
            clsReports TestItem = new clsReports();

            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.ProfitOrLoss = true;
            TestItem.EmployeeId   = 2;
            TestItem.DateAdded    = DateTime.Now.Date;
            TestItem.EmployeeName = "Akshay";
            TestItem.Expenses     = 200;
            TestItem.Total        = 1000;

            //set ThisReport to the test data
            AllReports.ThisReport = TestItem;

            //add the record
            PrimaryKey = AllReports.Add();

            //set the primary key of the test data
            TestItem.EmployeeId = PrimaryKey;

            //modify the test data
            TestItem.ProfitOrLoss = false;
            TestItem.EmployeeId   = 3;
            TestItem.DateAdded    = DateTime.Now.Date;
            TestItem.EmployeeName = "Lax";
            TestItem.Expenses     = 500;
            TestItem.Total        = 5000;

            //set the record based on the new test data
            AllReports.ThisReport = TestItem;

            //update the record
            AllReports.Update();

            //find the record
            AllReports.ThisReport.Find(PrimaryKey);

            //test to see ThisReport matched the test data
            Assert.AreEqual(AllReports.ThisReport, TestItem);
        }
Exemple #12
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        //create an instance of the class collection
        clsReportsCollection Reports = new clsReportsCollection();

        Reports.ReportByEmployeeName(txtEmployeeName.Text);
        lstReportsList.DataSource = Reports.ReportList;

        //set the name of the primary key
        lstReportsList.DataValueField = "EmployeeId";

        //set the name of the field to display
        lstReportsList.DataTextField = "EmployeeName";

        //bind the data to the list
        lstReportsList.DataBind();
    }
Exemple #13
0
    protected void btnClear_Click(object sender, EventArgs e)
    {
        clsReportsCollection Reports = new clsReportsCollection();

        Reports.ReportByEmployeeName("");

        //clear any existing filter to tidy up the interface
        txtEmployeeName.Text      = "";
        lstReportsList.DataSource = Reports.ReportList;

        //set the name of the primary key
        lstReportsList.DataValueField = "EmployeeId";

        //set the name of the field to display
        lstReportsList.DataTextField = "EmployeeName";

        //bind the data to the list
        lstReportsList.DataBind();
    }
        public void ThisReportPropertyOK()
        {
            clsReportsCollection AllReports = new clsReportsCollection();

            //create some test data to assign to the property
            clsReports TestReports = new clsReports();

            //set the properties of the test object
            TestReports.ProfitOrLoss = true;
            TestReports.EmployeeId   = 2;
            TestReports.DateAdded    = DateTime.Now.Date;
            TestReports.EmployeeName = "Akshay";
            TestReports.Expenses     = 200;
            TestReports.Total        = 1000;

            //assign the data to the property
            AllReports.ThisReport = TestReports;

            //test to see the two values are the same
            Assert.AreEqual(AllReports.ThisReport, TestReports);
        }
        public void DeleteMethodOK()
        {
            clsReportsCollection AllReports = new clsReportsCollection();

            //create the item of test data
            clsReports TestItem = new clsReports();

            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.ProfitOrLoss = true;
            TestItem.EmployeeId   = 2;
            TestItem.DateAdded    = DateTime.Now.Date;
            TestItem.EmployeeName = "Akshay";
            TestItem.Expenses     = 200;
            TestItem.Total        = 1000;

            //set ThisReport to the test data
            AllReports.ThisReport = TestItem;

            //add the record
            PrimaryKey = AllReports.Add();

            //set the primary key of the test data
            TestItem.EmployeeId = PrimaryKey;

            //find the record
            AllReports.ThisReport.Find(PrimaryKey);

            //delete the record
            AllReports.Delete();

            //now find the record
            Boolean Found = AllReports.ThisReport.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
Exemple #16
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        clsReports AReport = new clsReports();



        //capture employeeName
        string EmployeeName = txtEmployeeName.Text;
        //capture DateAdded
        string DateAdded = txtDateAdded.Text;
        //capture Total
        string Total = txtTotal.Text;
        //capture Expenses
        string Expenses = txtExpenses.Text;
        //variable to store any error messages
        string Error = "";

        //validate the data
        Error = AReport.Valid(EmployeeName, Total, Expenses, DateAdded);
        if (Error == "")
        {
            //Capture the employee id
            AReport.EmployeeId = EmployeeId;

            //Capture EmployeeName
            AReport.EmployeeName = EmployeeName;
            //capture DateAdded
            AReport.DateAdded = Convert.ToDateTime(DateAdded);
            //capture Total
            AReport.Total = Convert.ToInt32(Total);
            //capture Expenses
            AReport.Expenses = Convert.ToInt32(Expenses);
            //capture Profit
            AReport.ProfitOrLoss = chkProfit.Checked;
            //capture Loss
            AReport.ProfitOrLoss = chkLoss.Checked;

            //create a new instance of the reports collection
            clsReportsCollection ReportList = new clsReportsCollection();

            //if this is a new record i.e. EmployeeId = -1 then add the data
            if (EmployeeId == -1)
            {
                //set the ThisReport property
                ReportList.ThisReport = AReport;

                //add the new record
                ReportList.Add();
            }
            else
            {
                //find the record to update
                ReportList.ThisReport.Find(EmployeeId);

                //set the ThisReport property
                ReportList.ThisReport = AReport;

                //update the record
                ReportList.Update();
            }


            //redirect back to the listpage
            Response.Redirect("5ReportsList.aspx");
        }

        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }