コード例 #1
0
ファイル: StaffDeletePage.aspx.cs プロジェクト: Tech-E/Tech-E
        protected void btn1_Click(object sender, EventArgs e)
        {
            clsStaffCollection clsstaffcollection = new clsStaffCollection();

            clsstaffcollection.Delete(staffid);
            Response.Redirect("Staffs.aspx");
        }
コード例 #2
0
ファイル: StaffsAdd.aspx.cs プロジェクト: Tech-E/Tech-E
        //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>");
            }
        }
コード例 #3
0
ファイル: tstStaffCollection.cs プロジェクト: Tech-E/Tech-E
 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);
 }
コード例 #4
0
ファイル: tstStaffCollection.cs プロジェクト: Tech-E/Tech-E
 public void StaffInstanceOk()
 {
     //create an instance
     clsStaffCollection clsstaffcollection = new clsStaffCollection();
     //test to see that exists
     Assert.IsNotNull(clsstaffcollection);
 }
コード例 #5
0
ファイル: Staffs.aspx.cs プロジェクト: Tech-E/Tech-E
 private void Disaplay()
 {
     //create an instane of the collection
     clsStaffCollection clsstaffcollection = new clsStaffCollection();
     //set data souce
     ListBox1.DataSource = clsstaffcollection.clsStaffListCollection();
     //set tje name of the primary key
     ListBox1.DataValueField = "staffid";
     ListBox1.DataTextField = "Staffname";
     //bind the data to the list
     ListBox1.DataBind();
 }
コード例 #6
0
ファイル: tstStaffCollection.cs プロジェクト: Tech-E/Tech-E
 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);
 }