/// <summary>
        /// Khởi tạo cấu trúc datasource
        /// </summary>
        private void KhoiTaoDataSource()
        {
            Presentation.Process.KhachHangProcess process = new Presentation.Process.KhachHangProcess();
            DataSet ds = process.getThongTinKhac("VKH_KHANG_LQUAN");

            if (ds != null && ds.Tables.Count > 0)
            {
                _dtSource = ds.Tables[0];
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Đưa các control của form về trạng thái mặc định
 /// </summary>
 private void SetFormThanhVienGD(int idKhachHang)
 {
     Presentation.Process.KhachHangProcess process = new Presentation.Process.KhachHangProcess();
     try
     {
         DataSet dsSourceKHang = process.getThongTinKHTheoID(idKhachHang);
         if (dsSourceKHang != null && dsSourceKHang.Tables.Count > 0)
         {
             DataRow dr = dsSourceKHang.Tables["KH_KHANG_HSO"].Rows[0];
             isUpdate = false;
             txtMaThanhVienGD.Text = dr["MA_KHANG"].ToString();
             txtTenKhachHang.Text  = dr["TEN_KHANG"].ToString();
             raddtNgaySinh.Value   = LDateTime.StringToDate(dr["DD_NGAY_SINH"].ToString(), "yyyyMMdd");
             if (!LString.IsNullOrEmptyOrSpace(dr["DD_GIOI_TINH"].ToString()))
             {
                 cmbGioiTinh.SelectedIndex = lstSourceGioiTinh.IndexOf(lstSourceGioiTinh.FirstOrDefault(f => f.KeywordStrings.First().Equals(dr["DD_GIOI_TINH"].ToString())));
             }
             cmbMoiQuanHe.SelectedIndex       = 0;
             cmbTTSucKhoe.SelectedIndex       = 0;
             chkThongTinCoBanGDinh.IsChecked  = false;
             chkNguoiThuaKe.IsChecked         = false;
             chkNguoiDongTrachNhiem.IsChecked = false;
             txtSoGiayTo.Text            = "";
             raddtNgayCap.Value          = null;
             cmbLoaiGiayTo.SelectedIndex = lstSourceLoaiGiayTo.IndexOf(lstSourceLoaiGiayTo.FirstOrDefault(f => f.KeywordStrings.First().Equals(BusinessConstant.LOAI_GIAY_TO.CHUNG_MINH_ND.layGiaTri())));
             cmbNoiCap.SelectedIndex     = -1;
             txtTenKhachHang.Focus();
         }
     }
     catch (System.Exception ex)
     {
         if (ex.GetType() == typeof(CustomException))
         {
             new frmThongBaoLoi(ex.Message, ex.InnerException).ShowDialog();
         }
         else if (ex.InnerException.GetType() == typeof(CustomException))
         {
             new frmThongBaoLoi(ex.InnerException.Message, ex.InnerException).ShowDialog();
         }
         else
         {
             new frmThongBaoLoi("M.DungChung.LoiLoadDuLieu", ex).ShowDialog();
         }
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
     finally
     {
         process = null;
     }
 }
        /// <summary>
        /// Load dữ liệu lên form
        /// </summary>
        private void LoadDuLieu()
        {
            try
            {
                Presentation.Process.KhachHangProcess process = new Presentation.Process.KhachHangProcess();
                //DataSet ds = process.getTreeView(Presentation.Process.Common.ClientInformation.IdDonVi);

                // Nếu người dùng là NVDV, QTDV thì chỉ lấy thông tin đơn vị mình
                // Nếu người dùng là NVTW,... thì lấy thông tin toàn hệ thống
                // (Truongnx: popup chỉ lấy thông tin khách hàng thuộc đơn vị mình)
                int idDonVi = 0;
                idDonVi = ClientInformation.IdDonVi;
                //if (ClientInformation.LoaiNguoiSuDung.Equals(BusinessConstant.LoaiNguoiSuDung.CAP_NVDV.layGiaTri()) ||
                //    ClientInformation.LoaiNguoiSuDung.Equals(BusinessConstant.LoaiNguoiSuDung.CAP_QTDV.layGiaTri()))
                //{
                //    idDonVi = ClientInformation.IdDonVi;
                //}
                //else
                //{
                //    idDonVi = DatabaseConstant.ID_TOCHUC;
                //}
                DataSet ds = process.getTreeView(idDonVi);
                if (ds != null && ds.Tables.Count > 0)
                {
                    dtSourceTree = ds.Tables[0];
                    if (dtSourceTree != null && dtSourceTree.Rows.Count > 0)
                    {
                        DataRow   drFirst = dtSourceTree.Rows[0];
                        string    cond    = "convert(path,System.String) like '0#" + drFirst["idparent"].ToString() + @"/%'";
                        DataRow[] drRoot  = dtSourceTree.Select(cond, "id");
                        foreach (DataRow dr in drRoot)
                        {
                            RadTreeViewItem item = new RadTreeViewItem();
                            item.Header = dr["ten"];
                            item.Tag    = dr["path"];
                            tvwKhachHangDS.Items.Add(item);
                            tvwKhachHangDS.SelectedItem = item;
                            dtSourceTree.Rows.Remove(dr);
                            BuildTreeCungCap(item);
                            item.IsExpanded = true;
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
            }
        }
        //private void radpage_PageIndexChanged(object sender, PageIndexChangedEventArgs e)
        //{
        //    if (e.NewPageIndex < radpage.PageCount)
        //    {
        //        CurrentPagging = e.NewPageIndex + 1;
        //        StartRow = (CurrentPagging - 1) * PaggingSize + 1;
        //        EndRow = StartRow + PaggingSize;
        //        //radpage = new RadDataPager();
        //        TimKiemPhanTrang();
        //    }
        //}

        /// <summary>
        /// Tìm kiếm phân trang
        /// </summary>
        private void TimKiemPhanTrang()
        {
            Mouse.OverrideCursor = Cursors.Wait;
            DataTable dt = null;

            LDatatable.MakeParameterTable(ref dt);

            // Lay du lieu treeview cho tim kiem
            string ma_don_vi  = "-1";
            string ma_khu_vuc = "-1";
            string ma_cum     = "-1";
            string ma_nhom    = "-1";

            if (tvwKhachHangDS.SelectedItem != null)
            {
                RadTreeViewItem item  = tvwKhachHangDS.SelectedItem as RadTreeViewItem;
                string          level = item.Tag.ToString().Split('#')[0];
                string[]        path  = item.Tag.ToString().Split('#')[1].Split('/');
                string          type  = item.Tag.ToString().Split('#')[2];
                if (type == "DVI")
                {
                    ma_don_vi = path[path.Length - 1];
                }
                else
                {
                    ma_don_vi = path[0];
                    //ma_khu_vuc = path[1];
                    //ma_cum = path[1];
                    if (type == "KVUC")
                    {
                        ma_khu_vuc = path[1];
                    }
                    if (type == "CUM")
                    {
                        if (path.Length > 2)
                        {
                            ma_cum = path[2];
                        }
                        else
                        {
                            ma_cum = path[1];
                        }
                    }
                    if (type == "NHOM")
                    {
                        if (path.Length > 3)
                        {
                            ma_nhom = path[3];
                        }
                        else
                        {
                            ma_nhom = path[2];
                        }
                    }
                }
            }

            // Thong tin ngay gia nhap
            if (raddtTuNgayGiaNhap.Value != null)
            {
                LDatatable.AddParameter(ref dt, "@NgayGiaNhapTu", "STRING", Convert.ToDateTime(raddtTuNgayGiaNhap.Value).ToString("yyyyMMdd"));
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@NgayGiaNhapTu", "STRING", "");
            }

            if (raddtDenNgayGiaNhap.Value != null)
            {
                LDatatable.AddParameter(ref dt, "@NgayGiaNhapDen", "STRING", Convert.ToDateTime(raddtDenNgayGiaNhap.Value).ToString("yyyyMMdd"));
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@NgayGiaNhapDen", "STRING", "");
            }

            // Lay du lieu tu cac combobox
            AutoComboBox      au             = new AutoComboBox();
            AutoCompleteEntry nganhKT        = au.getEntryByDisplayName(lstSourceNganhKinhTe, ref cmbNganhKT);
            AutoCompleteEntry loaihinhToChuc = au.getEntryByDisplayName(lstSourceLoaiHinhToChuc, ref cmbLoaiHinhToChuc);
            AutoCompleteEntry loaiKhachHang  = au.getEntryByDisplayName(lstSourceLoaiKhachHang, ref cmbLoaiKhachHang);

            if (nganhKT != null)
            {
                LDatatable.AddParameter(ref dt, "@NganhKT", "STRING", nganhKT.KeywordStrings[0]);
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@NganhKT", "STRING", "");
            }

            if (loaihinhToChuc != null)
            {
                LDatatable.AddParameter(ref dt, "@LoaiHinhToChuc", "STRING", loaihinhToChuc.KeywordStrings[0]);
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@LoaiHinhToChuc", "STRING", "");
            }

            if (loaiKhachHang != null)
            {
                LDatatable.AddParameter(ref dt, "@LoaiKhachHang", "STRING", loaiKhachHang.KeywordStrings[0]);
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@LoaiKhachHang", "STRING", "");
            }

            // Them du lieu vao tim kiem
            if (ucTrangThaiNVu.GetItemsSelected() == "NULL")
            {
                LDatatable.AddParameter(ref dt, "@TrangThaiNghiepVu", "STRING", "");
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@TrangThaiNghiepVu", "STRING", ucTrangThaiNVu.GetItemsSelected());
            }
            LDatatable.AddParameter(ref dt, "@MaKhachHang", "STRING", txtMaKH.Text);
            LDatatable.AddParameter(ref dt, "@TenKhachHang", "STRING", txtTenKH.Text);
            LDatatable.AddParameter(ref dt, "@DkienMPA", "STRING", "");
            if (cmbDanToc.SelectedIndex >= 0)
            {
                LDatatable.AddParameter(ref dt, "@DanToc", "STRING", lstSourceDanToc.ElementAt(cmbDanToc.SelectedIndex).KeywordStrings.First());
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@DanToc", "STRING", "");
            }
            if (cmbGioiTinh.SelectedIndex >= 0)
            {
                LDatatable.AddParameter(ref dt, "@GioiTinh", "STRING", lstSourceGioiTinh.ElementAt(cmbGioiTinh.SelectedIndex).KeywordStrings.First());
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@GioiTinh", "STRING", "");
            }
            if (cmbLHCongTac.SelectedIndex >= 0)
            {
                LDatatable.AddParameter(ref dt, "@NgheNghiep", "STRING", lstSourceLHinhCongTac.ElementAt(cmbLHCongTac.SelectedIndex).KeywordStrings.First());
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@NgheNghiep", "STRING", "");
            }
            LDatatable.AddParameter(ref dt, "@TuoiTu", "STRING", Convert.ToInt32(numTuoiTu.Value).ToString());
            LDatatable.AddParameter(ref dt, "@TuoiDen", "STRING", Convert.ToInt32(numTuoiDen.Value).ToString());
            LDatatable.AddParameter(ref dt, "@NgayHienTai", "STRING", ClientInformation.NgayLamViecHienTai);
            LDatatable.AddParameter(ref dt, "@SoCMND", "STRING", txtCMND.Text);
            LDatatable.AddParameter(ref dt, "@SoDkyKDoanh", "STRING", txtSoDKKD.Text);
            LDatatable.AddParameter(ref dt, "@TenDangNhap", "STRING", ClientInformation.TenDangNhap);
            LDatatable.AddParameter(ref dt, "@DonViQLy", "STRING", ClientInformation.MaDonViQuanLy);
            LDatatable.AddParameter(ref dt, "@DonVi", "INT", ma_don_vi);
            LDatatable.AddParameter(ref dt, "@KhuVuc", "INT", ma_khu_vuc);
            LDatatable.AddParameter(ref dt, "@Cum", "INT", ma_cum);
            LDatatable.AddParameter(ref dt, "@Nhom", "INT", ma_nhom);
            LDatatable.AddParameter(ref dt, "@StartRow", "INT", StartRow.ToString());
            LDatatable.AddParameter(ref dt, "@EndRow", "INT", EndRow.ToString());

            // Tim kiem
            Presentation.Process.KhachHangProcess process = new Presentation.Process.KhachHangProcess();
            DataSet ds = process.getKetQuaTimKiemNangCao(dt);

            if (ds != null && ds.Tables.Count > 0)
            {
                DataTable serverDataTable = ds.Tables[0];
                int       totalRecord     = Int32.Parse(ds.Tables[1].Rows[0][0].ToString());
                DataTable clientDataTable = CommonFunction.BuildClientDataTable(serverDataTable, CurrentPagging, PaggingSize, totalRecord);

                //grKhachHangDS.ItemsSource = ds.Tables[0].DefaultView;
                //lblSumKhachHang.Content = ds.Tables[0].Rows.Count.ToString();
                lblSumKhachHang.Content = totalRecord;
                //radpage.Source = ds.Tables[0].DefaultView;
                //radpage = new RadDataPager();

                //radpage.Source = clientDataTable.DefaultView;
                //radpage.PageSize = PaggingSize;
                //radpage.PageIndex = CurrentPagging - 1;

                //grKhachHangDS.ItemsSource = radpage.PagedSource;
                grKhachHangDS.ItemsSource = null;
                grKhachHangDS.ItemsSource = clientDataTable.DefaultView;
                if (!LObject.IsNullOrEmpty(grKhachHangDS.SelectedItem))
                {
                    grKhachHangDS.SelectedItems.Clear();
                }
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }