Example #1
0
        //add method
        private void add()
        {
            clsStaff staffModel = new clsStaff();
            string ErrorMessage;

            //test  the data on the web form
            ErrorMessage = staffModel.StaffValid(TextBox2.Text, TextBox3.Text, TextBox4.Text, TextBox6.Text, TextBox8.Text);
            if (ErrorMessage == "")
            {

                staffModel.Staffname = TextBox2.Text;
                staffModel.Age = Convert.ToInt32(TextBox3.Text);
                staffModel.Brief = TextBox4.Text;
                staffModel.Gender = "man";
                staffModel.Mobilesphone = TextBox6.Text;
                staffModel.Workage = Convert.ToInt32(TextBox8.Text);
                staffModel.Position = DropDownList1.Text;
                clsStaffCollection staffcollection = new clsStaffCollection();
                int a = staffcollection.AddStaff(staffModel);
                Response.Redirect("Staffs.aspx");
            }

            else
            {
                Response.Write("<script type='text/javascript'>alert('" + ErrorMessage + "');</script>");
            }
        }
Example #2
0
 public void StaffDeleteMethodOk()
 {
     //create an instance of the class we want to create
     clsStaffCollection clsstaffcollection = new clsStaffCollection();
     //create some test data to assign to the property
     // add an item of test data
     clsStaff TestItem = new clsStaff();
     Boolean Found = false;
     //var to store the primary key
     Int32 PrimaryKey = 0;
     //set its properties
     TestItem.Staffid = 1;
     TestItem.Staffname = "jefferson";
     TestItem.Age = 20;
     TestItem.Brief = "i am jefferson";
     TestItem.Gender = "man";
     TestItem.Mobilesphone = "083128312321";
     TestItem.Workage = 2;
     TestItem.Position = "staff";
     //set ThisStaffto the test data
     clsstaffcollection.ThisStaff = TestItem;
     //delete the record
     //PrimaryKey = clsstaffcollection.Delete(TestItem);
     //set the primary key of the test data
     TestItem.Staffid = PrimaryKey;
     //find the record
     //Found=clsstaffcollection.ThisStaff.Find(PrimaryKey);
     //test to see that the two values are the same
     Assert.IsFalse(Found);
 }
Example #3
0
 public void StaffInstanceOk()
 {
     //create an instance
     clsStaff clsstaff = new clsStaff();
     //test to see that exists
     Assert.IsNotNull(clsstaff);
 }
Example #4
0
 //update method
 private void update()
 {
     clsStaff clstaffs = new clsStaff();
     clstaffs = clstaffs.Find(staffid);
     TextBox2.Text = clstaffs.Staffname.ToString();
     TextBox3.Text = clstaffs.Age.ToString();
     TextBox4.Text = clstaffs.Brief.ToString();
     TextBox6.Text = clstaffs.Mobilesphone.ToString();
     TextBox8.Text = clstaffs.Workage.ToString();
     DropDownList1.Text = clstaffs.Position.ToString();
 }
Example #5
0
        public void StaffNamePropertyOK()
        {
            //create an instance of the class we want to create
            clsStaff AStaff = new clsStaff();
            //Create test data 
            string AName = "ShiRan";
            //assign the data to the property
            AStaff.Staffname = AName;
            //two values are the same
            Assert.AreEqual(AStaff.Staffname, AName);

        }
Example #6
0
        public void StaffstaffidPropertyOK()
        {
            //create an instance of the class we want to create
            clsStaff AStaff = new clsStaff();
            //Create test data 
            int Number = 1;
            //assign the data to the property
            AStaff.Staffid = Number;
            //two values are the same
            Assert.AreEqual(AStaff.Staffid, Number);

        }
Example #7
0
        //Add Stafff Information
        public int AddStaff(clsStaff staffModel)
        {
            dBConnection = new clsDataConnection();
            //execute 
            dBConnection.AddParameter("@Name", staffModel.Staffname);
            dBConnection.AddParameter("@Age", staffModel.Age);
            dBConnection.AddParameter("@Brief", staffModel.Brief);
            dBConnection.AddParameter("@Gender", staffModel.Gender);
            dBConnection.AddParameter("@Mobilesphone", staffModel.Mobilesphone);
            dBConnection.AddParameter("@workage", staffModel.Workage);
            dBConnection.AddParameter("@positiob", staffModel.Position);

            return dBConnection.Execute("sproc_Staff_Insert");

        }
Example #8
0
        public void StaffNameLessOne()
        {
            //create an instance of the staffname
            clsStaff AStaff = new clsStaff();
            //boolean variable to store the results of the validation
            Boolean Ok = false;
            //some string test data to assign the property
            string StaffNameValid = "";
            string BriefValid = "i am jefferson";
            string GenderValid = "man";
            string MobilesphoneValid = "07833324651";
            string PositionValid = "manager";

            //invoke the method 
            Ok = AStaff.Valid(StaffNameValid, BriefValid, GenderValid, MobilesphoneValid, PositionValid);
            //test to see that results is correct
            Assert.IsFalse(Ok);

        }
Example #9
0
 public void StaffAddressListOk()
 {
     //create an instance of the class we want to create
     clsStaffCollection clsstaffcollection = new clsStaffCollection();
     //create some test data to assign to the property
     //in this case the data needs to be a list of objects
     List<clsStaff> TestStaffList = new List<clsStaff>();
     // add an item of test data
     clsStaff TestItem = new clsStaff();
     //set its properties
     TestItem.Staffid = 1;
     TestItem.Staffname = "jefferson";
     TestItem.Age = 20;
     TestItem.Brief = "i am jefferson";
     TestItem.Gender = "man";
     TestItem.Mobilesphone = "083128312321";
     TestItem.Workage = 2;
     TestItem.Position = "staff";
     //add the item to the test list
     TestStaffList.Add(TestItem);
     clsstaffcollection.staffList = TestStaffList;
     Assert.AreEqual(clsstaffcollection.staffList, TestStaffList);
 }
Example #10
0
        public List<clsStaff> clsStaffListCollection()
        {
            //var for the index
            Int32 Index = 0;
            //var to store the record count
            Int32 RecordCount = 0;
            //object for the data connection
            List<clsStaff> StaffList = new List<clsStaff>();
            clsDataConnection DB = new clsDataConnection();
            //execute the stored procedure
            DB.Execute("sproc_tblStaff_SelectAll");
            //get the count of records
            RecordCount = DB.Count;
            //while there are records to proccess
            while (Index < RecordCount)
            {
                clsStaff StaffOne = new clsStaff();
                StaffOne.Staffid = Convert.ToInt32(DB.DataTable.Rows[Index]["staffid"]);
                StaffOne.Staffname = Convert.ToString(DB.DataTable.Rows[Index]["Name"]);
                StaffOne.Age = Convert.ToInt32(DB.DataTable.Rows[Index]["age"]);
                StaffOne.Brief = Convert.ToString(DB.DataTable.Rows[Index]["brief"]);
                StaffOne.Gender = Convert.ToString(DB.DataTable.Rows[Index]["gender"]);
                StaffOne.Mobilesphone = Convert.ToString(DB.DataTable.Rows[Index]["mobilesphone"]); 
                StaffOne.Workage = Convert.ToInt32(DB.DataTable.Rows[Index]["workage"]); 
                StaffOne.Position = Convert.ToString(DB.DataTable.Rows[Index]["position"]);
                StaffList.Add(StaffOne);
            //    //point at the next record
                Index++;

            }
            return StaffList;
        }
Example #11
0
        public void StaffpositionPropertyOK()
        {
            //create an instance of the class we want to create
            clsStaff AStaff = new clsStaff();
            //Create test data 
            string Aposition = "manager";
            //assign the data to the property
            AStaff.Position = Aposition;
            //two values are the same
            Assert.AreEqual(AStaff.Position, Aposition);

        }
Example #12
0
        public void StaffworkagePropertyOK()
        {
            //create an instance of the class we want to create
            clsStaff AStaff = new clsStaff();
            //Create test data 
            int Aworkage = 2;
            //assign the data to the property
            AStaff.Workage = Aworkage;
            //two values are the same
            Assert.AreEqual(AStaff.Workage, Aworkage);

        }
Example #13
0
        public void StaffmobilesphonePropertyOK()
        {
            //create an instance of the class we want to create
            clsStaff AStaff = new clsStaff();
            //Create test data 
            string Amobilesphone = "07832223456";
            //assign the data to the property
            AStaff.Mobilesphone = Amobilesphone;
            //two values are the same
            Assert.AreEqual(AStaff.Mobilesphone, Amobilesphone);

        }
Example #14
0
        public void StaffgenderPropertyOK()
        {
            //create an instance of the class we want to create
            clsStaff AStaff = new clsStaff();
            //Create test data 
            string Agender = "gentleman";
            //assign the data to the property
            AStaff.Gender = Agender;
            //two values are the same
            Assert.AreEqual(AStaff.Gender, Agender);

        }
Example #15
0
 public void StaffbriefPropertyOK()
 {
     //create an instance of the class we want to create
     clsStaff AStaff = new clsStaff();
     //Create test data 
     string Abrief = "i am shiran lin...";
     //assign the data to the property
     AStaff.Brief = Abrief;
     //two values are the same
     Assert.AreEqual(AStaff.Brief, Abrief);
 }
Example #16
0
        public void StaffmobilesphoneExtremeMax()
        {
            //create an instance of the Staffmobilesphone
            clsStaff AStaff = new clsStaff();
            //boolean variable to store the results of the validation
            Boolean Ok = false;
            //some string test data to assign the property
            string StaffNameValid = "Jefferson";
            string BriefValid = "i am jefferson";
            string GenderValid = "man";
            string MobilesphoneValid = "";
            //pad the string with a characters
            MobilesphoneValid = MobilesphoneValid.PadRight(12, '0');
            string PositionValid = "manager";
            //invoke the method 
            Ok = AStaff.Valid(StaffNameValid, BriefValid, GenderValid, MobilesphoneValid, PositionValid);
            //test to see that results is correct
            Assert.IsFalse(Ok);

        }
Example #17
0
        public clsStaff Find(Int32 Staffid)
        {

            //initialise the DBConnection
            clsDataConnection dBConnection = new clsDataConnection();
            //add the Product No parameter
            dBConnection.AddParameter("@Staffid", Staffid);
            //execute the query
            dBConnection.Execute("sproc_tblStaff_FilterByStaffid");
            //if the record was found
            clsStaff clstaffs = new clsStaff();
            if (dBConnection.Count == 1)
            {
                //get the Product No
                clstaffs.Staffid = Convert.ToInt32(dBConnection.DataTable.Rows[0]["Staffid"]);
                clstaffs.Staffname = Convert.ToString(dBConnection.DataTable.Rows[0]["Staffname"]);
                clstaffs.Age = Convert.ToInt32(dBConnection.DataTable.Rows[0]["Age"]);
                clstaffs.Brief = Convert.ToString(dBConnection.DataTable.Rows[0]["Brief"]);
                clstaffs.Gender = Convert.ToString(dBConnection.DataTable.Rows[0]["Gender"]);
                clstaffs.Mobilesphone = Convert.ToString(dBConnection.DataTable.Rows[0]["Mobilesphone"]);
                clstaffs.Workage = Convert.ToInt32(dBConnection.DataTable.Rows[0]["Workage"]);
                clstaffs.Position = Convert.ToString(dBConnection.DataTable.Rows[0]["Position"]);
            }
            //return success
            return clstaffs;

        }