public void KhachHang_Load(int _KhachHangID) { QuocTichClient = new QuocTichSVCClient(); QuocTichClient.QuocTich_GetItemsCompleted += new EventHandler<QuocTich_GetItemsCompletedEventArgs>(QuocTichClient_QuocTich_GetItemsCompleted); QuocTichClient.QuocTich_GetItemsAsync(); cbxQuocTich.SelectedValue = 1; if (_KhachHangID != 0) { KhachHangID = _KhachHangID; KhachHangClient = new KhachHangSVCClient(); KhachHangClient.KhachHang_GetItemCompleted += new EventHandler<KhachHang_GetItemCompletedEventArgs>(KhachHangClient_KhachHang_GetItemCompleted); KhachHangClient.KhachHang_GetItemAsync(KhachHangID); } }
private void OKButton_Click(object sender, RoutedEventArgs e) { if (!String.IsNullOrEmpty(txtHoTen.Text.Trim()) && !String.IsNullOrEmpty(txtCMND.Text.Trim())) { string ngaysinh = string.Empty; string thoihanvisa = string.Empty; string ngaynhapcanh = string.Empty; string tungay = string.Empty; string denngay = string.Empty; int gioitinh = -1; if (!String.IsNullOrEmpty(rdpNgaySinh.SelectedDate.ToString())) ngaysinh = rdpNgaySinh.SelectedDate.Value.ToString("MM/dd/yyyy"); if (!String.IsNullOrEmpty(rdpThoiHanVisa.SelectedDate.ToString())) thoihanvisa = rdpThoiHanVisa.SelectedDate.Value.ToString("MM/dd/yyyy"); if (!String.IsNullOrEmpty(rdpNgayNhapCanh.SelectedDate.ToString())) ngaynhapcanh = rdpNgayNhapCanh.SelectedDate.Value.ToString("MM/dd/yyyy"); if (!String.IsNullOrEmpty(rdpTuNgay.SelectedDate.ToString())) tungay = rdpTuNgay.SelectedDate.Value.ToString("MM/dd/yyyy"); if (!String.IsNullOrEmpty(rdpDenNgay.SelectedDate.ToString())) denngay = rdpDenNgay.SelectedDate.Value.ToString("MM/dd/yyyy"); //if (cbxGioiTinh.SelectedIndex == -1) // gioitinh = int.Parse(cbxGioiTinh.SelectedIndex.ToString()); RadComboBoxItem SelectedItem = cbxGioiTinh.SelectedValue as RadComboBoxItem; gioitinh = int.Parse(SelectedItem.Tag.ToString()); KhachHangClient = new KhachHangSVCClient(); if (KhachHangID == -1) { KhachHangClient.KhachHang_AddCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(KhachHangClient_KhachHang_AddCompleted); KhachHangClient.KhachHang_AddAsync(txtHoTen.Text, txtDiaChi.Text, txtDienThoai.Text, txtCMND.Text, ngaysinh, txtNoiSinh.Text, txtSoVisa.Text, thoihanvisa, txtNguoiTiepNhan.Text, ngaynhapcanh, tungay, denngay, int.Parse(cbxQuocTich.SelectedValue.ToString()), gioitinh, User.UserID, DateTime.Now.ToString("MM/dd/yyyy")); } else { KhachHangClient.KhachHang_EditCompleted += new EventHandler<System.ComponentModel.AsyncCompletedEventArgs>(KhachHangClient_KhachHang_EditCompleted); KhachHangClient.KhachHang_EditAsync(KhachHangID, txtHoTen.Text, txtDiaChi.Text, txtDienThoai.Text, txtCMND.Text, ngaysinh, txtNoiSinh.Text, txtSoVisa.Text, thoihanvisa, txtNguoiTiepNhan.Text, ngaynhapcanh, tungay, denngay, int.Parse(cbxQuocTich.SelectedValue.ToString()), gioitinh, User.UserID, DateTime.Now.ToString("MM/dd/yyyy")); } } else { MessageBox.Show("Kiểm tra lại cái trường bắt buộc nhập", "Thông báo", MessageBoxButton.OK); } }