//Hàm nay se duoc thuc thi khi click nut them private void btnAdd_Click(object sender, EventArgs e) { if (ValidateForm())//Nếu đã nhập đầy đủ thong tin { string propertyName; //tạo ngày sinh khi click chọn ngày sinh trên form Date birthDay = new DoAnThucTapCoSo.Date(dtpBirthDay.Value.Day, dtpBirthDay.Value.Month, dtpBirthDay.Value.Year); //Tao node chứa thong tin nhan vien de them vao danh sach (thong tin lay tu du lieu nhap vao) Node <Employee> employee = new Node <Employee>() { Data = new Employee(txtName.Text.Trim(), cmbPosition.Text, birthDay, double.Parse(nudCoeffienceSalary.Value.ToString())) }; if ((propertyName = GetPropertyToSort()) != "")//kiem tra xem co chon thuoc tinh sap xep hay khong, neu co phai them vao danh sach sao cho dam bao danh sach van dc sap xep, neu khong them vao cuoi danh sach(truong hop else) { listEmployee.AddLast(employee); listEmployee.Sort(propertyName, cmbTypeSort.SelectedIndex); } else { listEmployee.AddLast(employee); } //hien thi lai danh sach ShowListEmployeeToDatagridView(this.listEmployee); isChanged = false; } }
private void btnAdd_Click(object sender, EventArgs e) { if (ValidateForm()) { string propertyName; Date birthDay = new DoAnThucTapCoSo.Date(dtpBirthDay.Value.Day, dtpBirthDay.Value.Month, dtpBirthDay.Value.Year); Node <Employee> employee = new Node <Employee>() { Data = new Employee(txtName.Text.Trim(), cmbPosition.Text, birthDay, double.Parse(nudCoeffienceSalary.Value.ToString())) }; if ((propertyName = GetPropertyToSort()) != "") { listEmployee.AddLast(employee); listEmployee.Sort(propertyName, cmbTypeSort.SelectedIndex); } else { listEmployee.AddLast(employee); } ShowListEmployeeToDatagridView(this.listEmployee); isSaved = false; } }