/// <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);
         DataSet ds = process.getTreeView(ClientInformation.MaDonViQuanLy, ClientInformation.TenDangNhap);
         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)
     {
         LMessage.ShowMessage("M.DungChung.LoiLoadDuLieu", LMessage.MessageBoxType.Error);
         LLogging.WriteLog(ex.TargetSite.Name, LLogging.LogType.ERR, ex);
     }
 }
        /// <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_NGUOI_DDIEN");

            if (ds != null && ds.Tables.Count > 0)
            {
                _dtSource = ds.Tables[0];
            }
        }
        /// <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);
                //DataSet ds = process.getTreeView(1);

                // 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
                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(ClientInformation.MaDonViQuanLy, ClientInformation.TenDangNhap);
                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);
            }
        }
        /// <summary>
        /// Tìm kiếm phân trang
        /// </summary>
        private void TimKiemPhanTrang()
        {
            if (!tiThongTinChung.IsSelected)
            {
                return;
            }
            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";
            string userName   = ClientInformation.TenDangNhap;

            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;
        }
Exemplo n.º 5
0
        private void TimKiem()
        {
            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";
            string userName   = AppConfig.LoginedUser.UserName;

            if (tvwDonVi.SelectedNode != null)
            {
                TreeNode item  = tvwDonVi.SelectedNode as TreeNode;
                string   level = item.Value.ToString().Split('#')[0];
                string[] path  = item.Value.ToString().Split('#')[1].Split('/');
                string   type  = item.Value.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

            LDatatable.AddParameter(ref dt, "@NgayGiaNhapTu", "STRING", "");

            LDatatable.AddParameter(ref dt, "@NgayGiaNhapDen", "STRING", "");


            // Lay du lieu tu cac combobox

            LDatatable.AddParameter(ref dt, "@NganhKT", "STRING", "");

            LDatatable.AddParameter(ref dt, "@LoaiHinhToChuc", "STRING", "");

            LDatatable.AddParameter(ref dt, "@LoaiKhachHang", "STRING", "");


            // Them du lieu vao tim kiem

            LDatatable.AddParameter(ref dt, "@TrangThaiNghiepVu", "STRING", "");


            LDatatable.AddParameter(ref dt, "@MaKhachHang", "STRING", txtMaKHang.Text);
            LDatatable.AddParameter(ref dt, "@TenKhachHang", "STRING", txtTenKHang.Text);
            LDatatable.AddParameter(ref dt, "@DkienMPA", "STRING", "");

            LDatatable.AddParameter(ref dt, "@DanToc", "STRING", "");

            LDatatable.AddParameter(ref dt, "@GioiTinh", "STRING", "");

            LDatatable.AddParameter(ref dt, "@NgheNghiep", "STRING", "");
            LDatatable.AddParameter(ref dt, "@TuoiTu", "STRING", Convert.ToInt32(0).ToString());
            LDatatable.AddParameter(ref dt, "@TuoiDen", "STRING", Convert.ToInt32(0).ToString());
            LDatatable.AddParameter(ref dt, "@NgayHienTai", "STRING", AppConfig.LoginedUser.NgayLamViecHienTai);
            LDatatable.AddParameter(ref dt, "@SoCMND", "STRING", "");
            LDatatable.AddParameter(ref dt, "@SoDkyKDoanh", "STRING", "");
            LDatatable.AddParameter(ref dt, "@TenDangNhap", "STRING", AppConfig.LoginedUser.UserName);
            LDatatable.AddParameter(ref dt, "@DonViQLy", "STRING", AppConfig.LoginedUser.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, "@HetHieuLuc", "STRING", "%");
            LDatatable.AddParameter(ref dt, "@StartRow", "INT", "1");
            LDatatable.AddParameter(ref dt, "@EndRow", "INT", "100");

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

            grdDangKyKHangDS.DataSource = ds;
            grdDangKyKHangDS.DataBind();
        }
        /// <summary>
        /// Tìm kiếm nâng cao
        /// </summary>
        private void TimKiem()
        {
            AutoComboBox      au           = new AutoComboBox();
            AutoCompleteEntry auLyDo       = au.getEntryByDisplayName(lstSourceLyDoRa, ref cmbLyDoRaKhoiNhom);
            AutoCompleteEntry auLoaiGiayTo = au.getEntryByDisplayName(lstSourceLoaiGiayTo, ref cmbLoaiGiayTo);

            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];
                        }
                    }
                }
            }

            if (ucTrangThaiNVu.GetItemsSelected() == "NULL")
            {
                LDatatable.AddParameter(ref dt, "@TrangThaiNghiepVu", "STRING", "");
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@TrangThaiNghiepVu", "STRING", ucTrangThaiNVu.GetItemsSelected());
            }

            LDatatable.AddParameter(ref dt, "@IdDonVi", "INT", ma_don_vi);
            LDatatable.AddParameter(ref dt, "@IdKhuVuc", "INT", ma_khu_vuc);
            LDatatable.AddParameter(ref dt, "@IdCum", "INT", ma_cum);
            LDatatable.AddParameter(ref dt, "@IdNhom", "INT", ma_nhom);
            LDatatable.AddParameter(ref dt, "@SoGD", "STRING", txtSoGD.Text);

            if (raddtTuNgayGD.Value != null)
            {
                LDatatable.AddParameter(ref dt, "@NgayGDTu", "STRING", txtMaKH.Text);
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@NgayGDTu", "STRING", "");
            }

            if (raddtDenNgayGD.Value != null)
            {
                LDatatable.AddParameter(ref dt, "@NgayGDDen", "STRING", txtMaKH.Text);
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@NgayGDDen", "STRING", "");
            }

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

            LDatatable.AddParameter(ref dt, "@MaKhang", "STRING", txtMaKH.Text);
            LDatatable.AddParameter(ref dt, "@TenKhang", "STRING", txtTenKH.Text);

            if (auLoaiGiayTo != null)
            {
                LDatatable.AddParameter(ref dt, "@LoaiGTO", "STRING", txtMaKH.Text);
            }
            else
            {
                LDatatable.AddParameter(ref dt, "@LoaiGTO", "STRING", "");
            }

            LDatatable.AddParameter(ref dt, "@SoGTO", "STRING", txtSoGiayTo.Text);
            LDatatable.AddParameter(ref dt, "@Email", "STRING", txtEmail.Text);
            LDatatable.AddParameter(ref dt, "@SoDThoai", "STRING", txtDienThoai.Text);
            LDatatable.AddParameter(ref dt, "@TenDangNhap", "STRING", ClientInformation.TenDangNhap);
            LDatatable.AddParameter(ref dt, "@DonViQLy", "STRING", ClientInformation.MaDonViQuanLy);

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

            if (ds != null && ds.Tables.Count > 0)
            {
                grKhachHangDS.ItemsSource = ds.Tables[0].DefaultView;
                if (!LObject.IsNullOrEmpty(grKhachHangDS.SelectedItems))
                {
                    grKhachHangDS.SelectedItems.Clear();
                }
                lblSumDonVi.Content = ds.Tables[0].Rows.Count.ToString();
            }
            Mouse.OverrideCursor = Cursors.Arrow;
        }