Esempio n. 1
0
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsEmployeeCollection AllEmployees = new clsEmployeeCollection();
            //create the item of test data
            ClsEmployee TestEmployee = new ClsEmployee();
            //var to store the primary key
            Int32 PrimaryKey = 117;

            //set its properties
            TestEmployee.Emp_Name   = "Jake Wills";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //set ThisAddress to the test data
            AllEmployees.ThisEmployee = TestEmployee;
            //add the record
            PrimaryKey = AllEmployees.Add();
            //set the primary key of the test data
            TestEmployee.Emp_ID = PrimaryKey;
            //find the record
            AllEmployees.ThisEmployee.Find(PrimaryKey);
            //delete the record
            AllEmployees.Delete();
            //now find the record
            Boolean Found = AllEmployees.ThisEmployee.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
Esempio n. 2
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsEmployeeCollection AllEmployee = new clsEmployeeCollection();
            //create the item of test data
            ClsEmployee TestEmployee = new ClsEmployee();
            //var to store the primary key
            Int32 PrimaryKey = 119;

            //set its properties
            TestEmployee.Emp_Name   = "Jake Wills";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //set ThisEmployee to the test data
            AllEmployee.ThisEmployee = TestEmployee;
            //add the record
            AllEmployee.Add();
            //set the primary key of the test data
            //find the record
            AllEmployee.ThisEmployee.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllEmployee.ThisEmployee, TestEmployee);
        }
    void Add()
    {
        //create instance of employee book
        clsEmployeeCollection EmployeeBook = new clsEmployeeCollection();
        //vlidate data in form
        //Valid(string employeeAddress, string employeeContactNumber, string employeeDOB, string employeeEmail, string employeeJoinDate, string employeeName, string employeeRole, string employeeSalary)
        String Error = EmployeeBook.ThisEmployee.Valid(txtEmployeeAddress.Text, txtEmployeeContactNo.Text, txtEmployeeDOB.Text, txtEmployeeEmail.Text, txtEmployeeJoinDate.Text, txtEmployeeName.Text, txtEmployeeRole.Text, txtEmployeeSalary.Text);

        //if data is OK then add to objext
        if (Error == " ")
        {
            //get data entered by user
            EmployeeBook.ThisEmployee.Address = txtEmployeeAddress.Text;
            EmployeeBook.ThisEmployee.EmployeeContactNumber = txtEmployeeContactNo.Text;
            EmployeeBook.ThisEmployee.EmployeeDOB           = Convert.ToDateTime(txtEmployeeDOB.Text);
            EmployeeBook.ThisEmployee.EmployeeEmail         = txtEmployeeEmail.Text;
            EmployeeBook.ThisEmployee.EmployeeJoinDate      = Convert.ToDateTime(txtEmployeeContactNo.Text);
            //EmployeeBook.ThisEmployee.EmployeeContactNo = txtEmployeeContactNo.Text;
            EmployeeBook.ThisEmployee.EmployeeName   = txtEmployeeName.Text;
            EmployeeBook.ThisEmployee.EmployeeRole   = txtEmployeeRole.Text;
            EmployeeBook.ThisEmployee.EmployeeSalary = txtEmployeeSalary.Text;
            //add record
            EmployeeBook.Add();
        }
        else
        {
            lblError.Text = "There was an error with the data entered" + Error;
        }
    }
Esempio n. 4
0
    void Add()
    {
        //create an instance of the address book
        clsEmployeeCollection EmployeeBook = new clsEmployeeCollection();
        //validate the data on the web form
        String Error = EmployeeBook.ThisEmployee.Valid(txtfirstname.Text, txtlastname.Text, txtaddress.Text, txtpostcode.Text, txtdatejoined.Text, txtemail.Text, txtphone.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //get the data entered by the user

            EmployeeBook.ThisEmployee.FirstName    = txtfirstname.Text;
            EmployeeBook.ThisEmployee.LastName     = txtlastname.Text;
            EmployeeBook.ThisEmployee.PostCode     = txtpostcode.Text;
            EmployeeBook.ThisEmployee.Address      = txtaddress.Text;
            EmployeeBook.ThisEmployee.Active       = Active.Checked;
            EmployeeBook.ThisEmployee.EmailAddress = txtemail.Text;
            EmployeeBook.ThisEmployee.DateJoined   = Convert.ToDateTime(txtdatejoined.Text);
            EmployeeBook.ThisEmployee.PhoneNumber  = txtphone.Text;
            //add the record
            EmployeeBook.Add();
            //all done so redirect back to the main page
            Response.Redirect("HomePage.aspx");
        }
        else
        {
            //report an error
            lblerror.Text = "There were problems with the data entered " + Error;
        }
    }
        public void AddMethodOK()
        {
            //create instance of class we want to create
            clsEmployeeCollection AllEmployees = new clsEmployeeCollection();
            //create item of test data
            clsEmployee TestItem = new clsEmployee();
            //var to store primary key
            Int32 PrimaryKey = 0;

            //set properties
            TestItem.Address = "london road";
            TestItem.EmployeeContactNumber = "07777777880";
            TestItem.EmployeeDOB           = Convert.ToDateTime("12/01/1997");
            TestItem.EmployeeEmail         = "*****@*****.**";
            TestItem.EmployeeJoinDate      = Convert.ToDateTime("11/04/2018");
            TestItem.EmployeeName          = "Sandeep";
            TestItem.EmployeeNo            = 1;
            TestItem.EmployeeRole          = "Accountant";
            TestItem.EmployeeSalary        = "1000";
            //set ThisAddress to test data
            AllEmployees.ThisEmployee = TestItem;
            //add record
            PrimaryKey = AllEmployees.Add();
            //set primary key of test data
            TestItem.EmployeeNo = PrimaryKey;
            //find record
            AllEmployees.ThisEmployee.Find(PrimaryKey);
            //test to see two values are same
            Assert.AreEqual(AllEmployees.ThisEmployee, TestItem);
        }
Esempio n. 6
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        ClsEmployee AnEmployee = new ClsEmployee();


        string emp_Name   = txtemp_Name.Text;
        string job_Name   = txtjob_Name.Text;
        string dep_ID     = txtdep_ID.Text;
        string hire_Date  = txthire_Date.Text;
        string manager_ID = txtmanager_ID.Text;
        string salary     = txtsalary.Text;
        string check      = chkActive.Text;
        string Error      = "";

        Error = AnEmployee.Valid(emp_Name, job_Name, manager_ID, Convert.ToDateTime(hire_Date), salary, dep_ID, chkActive.Checked);
        if (Error == "")
        {
            AnEmployee.Emp_ID     = emp_ID;
            AnEmployee.Emp_Name   = emp_Name;
            AnEmployee.Job_Name   = job_Name;
            AnEmployee.Manager_ID = Convert.ToInt32(manager_ID);
            AnEmployee.Hire_Date  = Convert.ToDateTime(hire_Date);
            AnEmployee.Salary     = Convert.ToInt32(salary);
            AnEmployee.Dep_ID     = Convert.ToInt32(dep_ID);
            AnEmployee.Active     = chkActive.Checked;

            clsEmployeeCollection EmployeeList = new clsEmployeeCollection();

            if (Convert.ToInt32(emp_ID) == -1)
            {
                EmployeeList.ThisEmployee = AnEmployee;
                EmployeeList.Add();
            }
            else
            {
                EmployeeList.ThisEmployee.Find(Convert.ToInt32(emp_ID));
                EmployeeList.ThisEmployee = AnEmployee;
                EmployeeList.Update();
            }
            Response.Redirect("DefaultEmployee.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
Esempio n. 7
0
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsEmployeeCollection AllEmployees = new clsEmployeeCollection();
            //create the item of test data
            ClsEmployee TestEmployee = new ClsEmployee();
            //var to store the primary key
            Int32 PrimaryKey = 117;

            //set its properties
            TestEmployee.Emp_Name   = "Jake Wills";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //set ThisAddress to the test data
            AllEmployees.ThisEmployee = TestEmployee;
            //add the record
            PrimaryKey = AllEmployees.Add();
            //set the primary key of the test data
            TestEmployee.Emp_ID = PrimaryKey;
            //modify the test data
            TestEmployee.Emp_Name   = "Jake Williams";
            TestEmployee.Job_Name   = "Supporter";
            TestEmployee.Manager_ID = 2;
            TestEmployee.Hire_Date  = DateTime.Now.Date;
            TestEmployee.Salary     = 22000;
            TestEmployee.Dep_ID     = 3;
            TestEmployee.Active     = true;
            //set the record based on the new test data
            AllEmployees.ThisEmployee = TestEmployee;
            //update the record
            AllEmployees.Update();
            //find the record
            AllEmployees.ThisEmployee.Find(PrimaryKey);
            //test to see ThisAddress matches the test data
            Assert.AreEqual(AllEmployees.ThisEmployee, TestEmployee);
        }