private void controlHDV_Load() { HuongDanVien hdv = HuongDanVien.Single(MaSo); txtCode.Text = hdv.ID; txtLastName.Text = hdv.Ho; txtFirstName.Text = hdv.Ten; dtpBirthDate.Value = hdv.NgaySinh; rdMale.Checked = hdv.GioiTinh ? true : false; txtAddress.Text = hdv.DiaChi; txtPhone.Text = hdv.DienThoai; cbbCountry.Text = hdv.QuocGia; dtpBirthDate.Text = hdv.NgaySinh.ToShortDateString(); ckbStatus.Checked = hdv.TrangThai; lvTours_Load(lvSpecializedTours, HDV_Tour.FindByMHDV(MaSo)); lvTours_Load(lvTours, HDV_Tour.NotFindByMHDV(MaSo)); }
private void itemUpdate_ItemClick_1(object sender, TileItemEventArgs e) { if (MaSo != null) { if (txtLastName.Text.Length == 0) { txtLastName.Focus(); lblLastName.Text = "You must enter last name!"; return; } if (txtFirstName.Text.Length == 0) { txtFirstName.Focus(); lblfirstNameInfo.Text = "You must enter first name!"; return; } if (DateTime.Now.Year - dtpBirthDate.Value.Year < 18) { MessageBox.Show("Age must be less than 18!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); DateTime dt = new DateTime(DateTime.Now.Year - 18, DateTime.Now.Month, DateTime.Now.Day); dtpBirthDate.Value = dt; dtpBirthDate.Focus(); return; } if (MaSo != null) { List <HDV_Tour> list = new List <HDV_Tour>(); HuongDanVien hdv = HDV_Load(ref list); HuongDanVien exited = HuongDanVien.Single(txtCode.Text); if (hdv.Ten != exited.Ten || hdv.Ho != exited.Ho) { if (HuongDanVien.FindByNameSingle(txtLastName.Text, txtFirstName.Text) != null) { DialogResult dlg = MessageBox.Show("This guider had ben exited! Do you want to add this guider?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dlg == System.Windows.Forms.DialogResult.No) { return; } } } if (HuongDanVien.Update(hdv, list)) { MessageBox.Show("Updating is successfull", "Message", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); lvTours_Load(lvSpecializedTours, HDV_Tour.FindByMHDV(MaSo)); lvTours_Load(lvTours, HDV_Tour.NotFindByMHDV(MaSo)); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBox.Show("Updating had being faile", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Updating had been not allowed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }