コード例 #1
0
        /// <summary>
        /// Khởi tạo các combobox
        /// </summary>
        private void LoadCombobox()
        {
            // Khai bao AutoComboBox
            AutoComboBox auto;
            // Khởi tạo điều kiện gọi danh mục
            List <string> lstDieuKien = new List <string>();

            //Tao combobox Chi nhanh,PGD, KVUC
            auto = new AutoComboBox();
            auto.GenAutoComboBox(ref lstSourceChiNhanh, ref cmbChiNhanh, DatabaseConstant.DanhSachTruyVan.COMBOBOX_CNHANH.getValue(), null, ClientInformation.MaDonVi);
            auto.GenAutoComboBox(ref lstSourcePhongGD, ref cmbPhongGD, DatabaseConstant.DanhSachTruyVan.COMBOBOX_PHONG_GD.getValue());
            LoadComboboxPhongGD();

            //Load du lieu khu vuc, cum
            var process = new TruyVanProcess();
            DanhSachResponse response = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.COMBOBOX_KHUVUC_ALL.getValue(), lstDieuKien);

            if (!LObject.IsNullOrEmpty(response.DataSetSource) && response.DataSetSource.Tables[0].Rows.Count > 0)
            {
                dtSourceKhuVuc = response.DataSetSource.Tables[0];
            }

            response = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.COMBOBOX_CUM_ALL.getValue(), lstDieuKien);
            if (!LObject.IsNullOrEmpty(response.DataSetSource) && response.DataSetSource.Tables[0].Rows.Count > 0)
            {
                dtSourceCum = response.DataSetSource.Tables[0];
            }

            lstDieuKien = new List <string>();
            lstDieuKien.Add(DatabaseConstant.DanhMuc.LY_DO_VAO_RA.getValue());
            // khởi tạo combobox
            auto = new AutoComboBox();

            lstDieuKien = new List <string>();
            lstDieuKien.Add(DatabaseConstant.DanhMuc.NGON_NGU.getValue());
            // khởi tạo combobox
            auto = new AutoComboBox();
            auto.GenAutoComboBox(ref lstSourceNgonNgu, ref cmbNgonNgu, DatabaseConstant.DanhSachTruyVan.COMBOBOX_DMUC.getValue(), lstDieuKien, ApplicationConstant.LoaiNgonNguBaoCao.vi_VN.layGiaTri());
            cmbNgonNgu.IsEnabled = false;

            lstDieuKien.Clear();
            lstDieuKien.Add(DatabaseConstant.DanhMuc.DINH_DANG_BAO_CAO.getValue());
            // khởi tạo combobox
            auto = new AutoComboBox();
            auto.GenAutoComboBox(ref lstSourceDinhDang, ref cmbDinhDang, DatabaseConstant.DanhSachTruyVan.COMBOBOX_DMUC.getValue(), lstDieuKien, ApplicationConstant.LoaiDinhDangBaoCao.EXCEL.layGiaTri());
            cmbDinhDang.IsEnabled = false;

            cmbChiNhanh.SelectionChanged += cmbChiNhanh_SelectionChanged;
            cmbPhongGD.SelectionChanged  += cmbPhongGD_SelectionChanged;
            grKhuVuc.SelectionChanged    += grKhuVuc_SelectionChanged;
            IsLoadForm = true;
        }
コード例 #2
0
        /// <summary>
        /// Load dữ liệu lên datagrid
        /// </summary>
        private void LoadDuLieu()
        {
            var           process  = new TruyVanProcess();
            List <string> lstDkLoc = new List <string>();

            lstDkLoc.Add(ucTrangThaiNVu.GetItemsSelected());
            lstDkLoc.Add(ucTrangThaiSDung.GetItemsSelected());
            DanhSachResponse DanhSachResponse = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.DM_QUOCGIA.getValue(), lstDkLoc);

            if (DanhSachResponse.DataSetSource != null)
            {
                lstHeader = DanhSachResponse.ListHeader.ToList();

                //dtMaster = DanhSachResponse.DataSetSource.Tables[0];
                //dtDetail = DanhSachResponse.DataSetSource.Tables[1];
                dtMaster = null;
                dtDetail = DanhSachResponse.DataSetSource.Tables[0];

                //RadTreeViewItem rootItem = new RadTreeViewItem();
                //rootItem.Header = LLanguage.SearchResourceByKey(DanhSachResponse.Title);
                //rootItem.Tag = string.Empty;
                //rootItem.IsExpanded = true;
                //tvwTree.Items.Add(rootItem);
                //BuildTree(rootItem);
                BuildGrid();
                loadWidthColumn();
            }
        }
コード例 #3
0
        private void KhoiTaoGiaTriComboBox(ref List <AutoCompleteEntry> lstAutoComplete, ref Telerik.Windows.Controls.RadComboBox cmbCommon, string maDanhMuc)
        {
            var           process       = new TruyVanProcess();
            DataSet       dataSetSource = new DataSet();
            List <string> lstDieuKien   = new List <string>();

            lstDieuKien.Clear();
            lstDieuKien.Add(maDanhMuc);
            lstDieuKien.Add(ClientInformation.MaDonVi);
            DanhSachResponse response = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.COMBOBOX_DMUC_NHAN_SU_THEO_BANG.getValue(), lstDieuKien);

            dataSetSource = response.DataSetSource;
            if (dataSetSource.Tables.Count > 0)
            {
                foreach (DataRow row in dataSetSource.Tables[0].Rows)
                {
                    AutoCompleteEntry entry = new AutoCompleteEntry(row["TEN"].ToString(), row["ID"].ToString(), row["MA"].ToString());
                    cmbCommon.Items.Add(entry);
                    lstAutoComplete.Add(entry);
                }
            }
            if (cmbCommon.Items.Count > 0)
            {
                cmbCommon.SelectedIndex = 0;
            }
            cmbCommon.IsEditable = isEditable;
        }
コード例 #4
0
        private void KhoiTaoGiaTriComboBox(ref List <AutoCompleteEntry> lstAutoComplete, ref Telerik.Windows.Controls.RadComboBox cmbCommon, string maPhongBan)
        {
            var           process       = new TruyVanProcess();
            DataSet       dataSetSource = new DataSet();
            List <string> lstDieuKien   = new List <string>();

            lstDieuKien.Clear();
            lstDieuKien.Add(maPhongBan);
            lstDieuKien.Add(BusinessConstant.LOAI_HO_SO.THOI_VIEC.layGiaTri());
            lstDieuKien.Add(ClientInformation.MaDonVi);
            DanhSachResponse response = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.COMBOBOX_NGUOI_BAN_GIAO.getValue(), lstDieuKien);

            dataSetSource = response.DataSetSource;
            if (dataSetSource.Tables.Count > 0)
            {
                foreach (DataRow row in dataSetSource.Tables[0].Rows)
                {
                    AutoCompleteEntry entry = new AutoCompleteEntry(row["TEN_HSO"].ToString(), row["MA_HSO"].ToString(), row["CHUC_VU"].ToString());
                    cmbCommon.Items.Add(entry);
                    lstAutoComplete.Add(entry);
                }
            }
            if (cmbCommon.Items.Count > 0)
            {
                cmbCommon.SelectedIndex = 0;
            }
            cmbCommon.IsEditable = isEditable;
        }
コード例 #5
0
        private void BuildGrid(string maDonVi)
        {
            Cursor = Cursors.Wait;
            try
            {
                var           process  = new TruyVanProcess();
                List <string> lstDkLoc = new List <string>();
                lstDkLoc.Add(ucTrangThaiNVu.GetItemsSelected());
                lstDkLoc.Add(ucTrangThaiSDung.GetItemsSelected());
                lstDkLoc.Add(maDonVi);
                DanhSachResponse DanhSachResponse = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.DM_KHUVUC.getValue(), lstDkLoc);
                if (DanhSachResponse.DataSetSource != null)
                {
                    lstHeader = DanhSachResponse.ListHeader.ToList();

                    //dtMaster = DanhSachResponse.DataSetSource.Tables[0];
                    dtDetail = DanhSachResponse.DataSetSource.Tables[0];
                }

                List <string> lst = new List <string>();
                lst.Add(maDonVi);
                DataTable grdData = new DataTable();

                foreach (DataColumn col in dtDetail.Columns)
                {
                    grdData.Columns.Add(col.ColumnName, typeof(string));
                }

                if (lst.Count > 0)
                {
                    foreach (DataRow row in dtDetail.Rows)
                    {
                        if (lst.Contains(row["KEY"].ToString()))
                        {
                            grdData.ImportRow(row);
                        }
                    }
                }

                if (grdData.Rows.Count > 0)
                {
                    grKhuVucDS.ItemsSource = grdData.DefaultView;
                }
                else
                {
                    grKhuVucDS.ItemsSource = null;
                }
                lblTongSo.Content = grdData.Rows.Count;
            }
            catch (System.Exception ex)
            {
            }
            finally
            {
                Cursor = Cursors.Arrow;
            }
        }
コード例 #6
0
        public void GenAutoSoure(ref List <AutoCompleteEntry> lstSource, string maTruyVan, List <string> lstDieuKien = null, string maChon = "Default", List <string> lstMaKhoangChon = null)
        {
            Func <AutoCompleteEntry, bool> predicate = null;
            Func <AutoCompleteEntry, bool> func2     = null;

            try
            {
                if (!string.IsNullOrEmpty(maTruyVan))
                {
                    TruyVanProcess process       = new TruyVanProcess();
                    DataSet        dataSetSource = new DataSet();
                    dataSetSource = process.getDanhSachInformation(maTruyVan, lstDieuKien).DataSetSource;
                    foreach (DataRow row in dataSetSource.Tables[0].Rows)
                    {
                        if (row.Table.Columns.Count > 3)
                        {
                            List <string> list = new List <string> {
                                row[1].ToString(),
                                row[0].ToString()
                            };
                            for (int i = 3; i < dataSetSource.Tables[0].Columns.Count; i++)
                            {
                                list.Add(row[i].ToString());
                            }
                            lstSource.Add(new AutoCompleteEntry(LanguageEngine.Instance().GetContent(0, row[2].ToString()), list.ToArray()));
                        }
                        else
                        {
                            string content = LanguageEngine.Instance().GetContent(0, row[2].ToString());
                            if (content == "")
                            {
                                content = LanguageEngine.Instance().GetContent(0, row[1].ToString());
                            }
                            lstSource.Add(new AutoCompleteEntry(content, new string[] { row[1].ToString(), row[0].ToString() }));
                        }
                    }
                }
                if (lstMaKhoangChon != null)
                {
                    if (predicate == null)
                    {
                        predicate = e => lstMaKhoangChon.Contains(e.KeywordStrings.First <string>());
                    }
                    lstSource = lstSource.Where <AutoCompleteEntry>(predicate).ToList <AutoCompleteEntry>();
                }
            }
            catch (Exception exception)
            {
                LLogging.WriteLog("", LLogging.LogType.ERR, exception);
            }
        }
コード例 #7
0
        /// <summary>
        /// Load dữ liệu lên datagrid
        /// </summary>
        public void LoadDuLieu()
        {
            var           process  = new TruyVanProcess();
            List <string> lstDkLoc = new List <string>();

            lstDkLoc.Add(ucTrangThaiNVu.GetItemsSelected());
            lstDkLoc.Add(ucTrangThaiSDung.GetItemsSelected());
            DanhSachResponse DanhSachResponse = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.DM_PHANHE_GD.getValue(), lstDkLoc);

            if (DanhSachResponse.DataSetSource != null)
            {
                lstHeader = DanhSachResponse.ListHeader.ToList();
                dtMaster  = new DataTable();
                grdData   = new DataTable();
                foreach (HeaderDto item in lstHeader)
                {
                    grdData.Columns.Add(LLanguage.SearchResourceByKey(item.LanguageKey), typeof(string));
                }

                lstHeader = DanhSachResponse.ListHeader.ToList();

                dtMaster = DanhSachResponse.DataSetSource.Tables[0];
                dtDetail = DanhSachResponse.DataSetSource.Tables[1];
                while (tvwTree.Items.Count > 0)
                {
                    tvwTree.Items.RemoveAt(0);
                }
                UpdateLayout();
                RadTreeViewItem rootItem = new RadTreeViewItem();
                rootItem.Header     = "Danh mục (" + DanhSachResponse.DataSetSource.Tables[1].Rows.Count.ToString() + ")";
                rootItem.Tag        = string.Empty;
                rootItem.IsExpanded = true;
                tvwTree.Items.Add(rootItem);
                BuildTree(rootItem);
                BuildGrid();
                loadWidthColumn();
                // khởi tạo sự kiện combobox
                cmbTrangThai.KeyDown        += cmb_KeyDown;
                cmbPhanHe.KeyDown           += cmb_KeyDown;
                tvwTree.SelectionChanged    += tvwTree_SelectionChanged;
                tvwTree.MouseDoubleClick    += tvwTree_MouseDoubleClick;
                grDanhSach.MouseDoubleClick += grDanhSach_MouseDoubleClick;
                nudPageSize.ValueChanged    += nudPageSize_ValueChanged;
            }
        }
コード例 #8
0
        /// <summary>
        /// Load dữ liệu lên datagrid
        /// </summary>
        private void LoadDuLieu()
        {
            var           process  = new TruyVanProcess();
            List <string> lstDkLoc = new List <string>();

            lstDkLoc.Add(ucTrangThaiNVu.GetItemsSelected().Equals("NULL") ? null : ucTrangThaiNVu.GetItemsSelected());
            lstDkLoc.Add(ucTrangThaiSDung.GetItemsSelected().Equals("NULL") ? null : ucTrangThaiSDung.GetItemsSelected());
            DanhSachResponse DanhSachResponse = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.DM_TAN_SUAT.getValue(), lstDkLoc);

            if (DanhSachResponse.DataSetSource != null)
            {
                lstHeader = DanhSachResponse.ListHeader.ToList();

                dtMaster = DanhSachResponse.DataSetSource.Tables[0];
                BuildGrid();
                loadWidthColumn();
            }
        }
コード例 #9
0
        /// <summary>
        /// Tạo AutocomboBox
        /// </summary>
        /// <param name="lstSource">Source cho Combobox</param>
        /// <param name="comboBox">Tên control Combobox được gen</param>
        /// <param name="maTruyVan">Mã truy vấn để lấy source cho combobox</param>
        /// <param name="lstDieuKien">Giá trị các điều kiện tương ứng với truy vấn</param>
        /// <param name="maChon">Mã Item sẽ được chọn nếu có</param>
        /// <param name="lstMaKhoangChon">Danh sách các Item sẽ được gen vào Combobox nếu có.</param>
        public static void GenAutoComboBox(ref List <AutoCompleteEntry> lstSource, string maTruyVan, List <string> lstDieuKien = null, string maChon = "Default", List <string> lstMaKhoangChon = null)
        {
            try
            {
                if (!string.IsNullOrEmpty(maTruyVan))
                {
                    var              process       = new TruyVanProcess();
                    DataSet          dataSetSource = new DataSet();
                    DanhSachResponse response      = process.getDanhSachInformation(maTruyVan, lstDieuKien);
                    dataSetSource = response.DataSetSource;

                    //}

                    foreach (DataRow row in dataSetSource.Tables[0].Rows)
                    {
                        if (row.Table.Columns.Count > 3)
                        {
                            List <string> lst = new List <string>();
                            lst.Add(row[1].ToString());
                            lst.Add(row[0].ToString());
                            for (int i = 3; i < dataSetSource.Tables[0].Columns.Count; i++)
                            {
                                lst.Add(row[i].ToString());
                            }
                            lstSource.Add(new AutoCompleteEntry(LanguageNode.GetValueUILanguage(row[2].ToString()), lst.ToArray()));
                        }
                        else
                        {
                            lstSource.Add(new AutoCompleteEntry(LanguageNode.GetValueUILanguage(row[2].ToString()), row[1].ToString(), row[0].ToString()));
                        }
                    }
                }
                if (lstMaKhoangChon != null)
                {
                    lstSource = lstSource.Where(e => lstMaKhoangChon.Contains(e.KeywordStrings.First())).ToList();
                }
            }
            catch (Exception e)
            {
                LLogging.WriteLog("", LLogging.LogType.ERR, e);
            }
        }
コード例 #10
0
        public void GenAutoComboBoxDirectly(ref List<AutoCompleteEntry> lstSource, ref RadComboBox comboBox, string maTruyVan, List<string> lstDieuKien = null, string maChon = "Default", List<string> lstMaKhoangChon = null)
        {
            try
            {
                if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
                    return;
                if (!string.IsNullOrEmpty(maTruyVan))
                {
                    var process = new TruyVanProcess();
                    DataSet dataSetSource = new DataSet();

                    // Lấy kết quả trả về
                    DanhSachResponse response = process.getDanhSachInformation(maTruyVan, lstDieuKien);
                    dataSetSource = response.DataSetSource;

                    foreach (DataRow row in dataSetSource.Tables[0].Rows)
                    {
                        lstSource.Add(new AutoCompleteEntry(LLanguage.SearchResourceByKey(row[2].ToString()), row[1].ToString(), row[0].ToString()));
                    }
                }
                if (lstMaKhoangChon != null)
                {
                    lstSource = lstSource.Where(e => lstMaKhoangChon.Contains(e.KeywordStrings.First())).ToList();
                }
                foreach (AutoCompleteEntry auto in lstSource)
                {
                    comboBox.Items.Add(auto);
                }
                if (!string.IsNullOrEmpty(maChon))
                {
                    if (maChon.Equals("Default"))
                        comboBox.SelectedIndex = 0;
                    else
                        comboBox.SelectedIndex = lstSource.IndexOf(lstSource.FirstOrDefault(e => e.KeywordStrings.First().Equals(maChon)));
                }
            }
            catch (Exception e)
            {
                LLogging.WriteLog("", LLogging.LogType.ERR, e);
            }
        }
コード例 #11
0
 /// <summary>
 /// Tạo AutocomboBox
 /// </summary>
 /// <param name="lstSource">Source cho Combobox</param>
 /// <param name="comboBox">Tên control Combobox được gen</param>
 /// <param name="maTruyVan">Mã truy vấn để lấy source cho combobox</param>
 /// <param name="lstDieuKien">Giá trị các điều kiện tương ứng với truy vấn</param>
 /// <param name="maChon">Mã Item sẽ được chọn nếu có</param>
 /// <param name="lstMaKhoangChon">Danh sách các Item sẽ được gen vào Combobox nếu có.</param>
 public void GenAutoComboBox(ref ListCheckBoxCombo lstSource, ref RadComboBox comboBox, string maTruyVan, List <string> lstDieuKien = null, string maChon = "Default", List <string> lstMaKhoangChon = null)
 {
     if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
     {
         return;
     }
     if (!string.IsNullOrEmpty(maTruyVan))
     {
         DataSet          dataSetSource = new DataSet();
         TruyVanProcess   process       = new TruyVanProcess();
         DanhSachResponse response      = process.getDanhSachInformation(maTruyVan, lstDieuKien);
         dataSetSource = response.DataSetSource;
         AutoCompleteCheckBox autocom = new AutoCompleteCheckBox();
         int icount = 0;
         lstSource.Add(new AutoCompleteCheckBox());
         foreach (DataRow row in dataSetSource.Tables[0].Rows)
         {
             icount++;
             string[] value = new string[row.Table.Columns.Count - 1];
             if (row.Table.Columns.Count > 3)
             {
                 value[0] = row[1].ToString();
                 value[1] = row[0].ToString();
                 for (int i = 3; i < row.Table.Columns.Count; i++)
                 {
                     value[i - 1] = row[i].ToString();
                 }
                 autocom.ValueMember = value;
             }
             else
             {
                 value[0]            = row[1].ToString();
                 value[1]            = row[0].ToString();
                 autocom.ValueMember = value;
             }
             lstSource.Add(new AutoCompleteCheckBox(LLanguage.SearchResourceByKey(row[2].ToString()), value, true, icount));
         }
     }
     comboBox.ItemsSource   = lstSource;
     comboBox.SelectedIndex = 0;
 }
コード例 #12
0
        private void getData()
        {
            lstHeader = new List <HeaderDto>();
            dsData    = new DataSet();
            dtMaster  = new DataTable();
            dtDetail  = new DataTable();

            var           process  = new TruyVanProcess();
            List <string> lstDkLoc = new List <string>();

            lstDkLoc.Add("NULL");
            lstDkLoc.Add("NULL");
            DanhSachResponse DanhSachResponse = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.DM_TINHTP.getValue(), lstDkLoc);

            if (DanhSachResponse.DataSetSource != null)
            {
                lstHeader = DanhSachResponse.ListHeader.ToList();
                dsData    = DanhSachResponse.DataSetSource;
                dtMaster  = DanhSachResponse.DataSetSource.Tables[0];
                dtDetail  = DanhSachResponse.DataSetSource.Tables[1];
            }
        }
コード例 #13
0
        /// <summary>
        /// Load dữ liệu lên tree
        /// </summary>
        private void LoadDuLieu()
        {
            var           process  = new TruyVanProcess();
            List <string> lstDkLoc = new List <string>();

            lstDkLoc.Add(ucTrangThaiNVu.GetItemsSelected());
            lstDkLoc.Add(ucTrangThaiSDung.GetItemsSelected());
            if (ClientInformation.LoaiNguoiSuDung.Equals(BusinessConstant.LoaiNguoiSuDung.CAP_QTDV.layGiaTri()) ||
                ClientInformation.LoaiNguoiSuDung.Equals(BusinessConstant.LoaiNguoiSuDung.CAP_NVDV.layGiaTri()))
            {
                lstDkLoc.Add(ClientInformation.IdDonVi.ToString());
            }
            else
            {
                lstDkLoc.Add(DatabaseConstant.ID_TOCHUC.ToString());
            }
            lstDkLoc.Add(ClientInformation.TenDangNhap);
            lstDkLoc.Add(ClientInformation.MaDonViQuanLy);

            DanhSachResponse DanhSachResponse = process.getDanhSachInformation(DatabaseConstant.DanhSachTruyVan.DM_CUM_TREE.getValue(), lstDkLoc);

            if (DanhSachResponse.DataSetSource != null)
            {
                //lstHeader = DanhSachResponse.ListHeader.ToList();

                dtMaster = DanhSachResponse.DataSetSource.Tables[0];
                DataRow drRoot = dtMaster.Rows[0];

                RadTreeViewItem rootItem = new RadTreeViewItem();
                rootItem.Header = drRoot["NODE_NAME"].ToString();
                rootItem.Tag    = drRoot["NODE"].ToString();
                rootItem.Uid    = drRoot["NODE_TYPE"].ToString();
                //rootItem.IsExpanded = true;
                tvwKhuVuc.Items.Add(rootItem);
                BuildTree(rootItem);
            }
        }
コード例 #14
0
        /// <summary>
        /// Tạo AutocomboBox
        /// </summary>
        /// <param name="lstSource">Source cho Combobox</param>
        /// <param name="comboBox">Tên control Combobox được gen</param>
        /// <param name="maTruyVan">Mã truy vấn để lấy source cho combobox</param>
        /// <param name="lstDieuKien">Giá trị các điều kiện tương ứng với truy vấn</param>
        /// <param name="maChon">Mã Item sẽ được chọn nếu có</param>
        /// <param name="lstMaKhoangChon">Danh sách các Item sẽ được gen vào Combobox nếu có.</param>
        public void GenAutoComboBox(ref List<AutoCompleteEntry> lstSource, ref RadComboBox comboBox, string maTruyVan, List<string> lstDieuKien = null, string maChon = "Default", List<string> lstMaKhoangChon = null)
        {
            try
            {
                if (DesignerProperties.GetIsInDesignMode(new DependencyObject()))
                    return;
                if (!string.IsNullOrEmpty(maTruyVan))
                {
                    var process = new TruyVanProcess();
                    DataSet dataSetSource = new DataSet();

                    // Lấy kết quả trả về
                    //if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_DMUC.getValue()))
                    //{
                    //    dataSetSource = getDataSetDmDmucGtri(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_HINHTHUCSD.getValue()))
                    //{
                    //    dataSetSource = getDataSetDmDmucGtriHinhThucSd(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_KHOANG_GTRI_TAISAN.getValue()))
                    //{
                    //    dataSetSource = getDataSetDmDmucGtriKhoangGiaTriTaiSan(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_LOAICHUNGTU_NGOAIBANG.getValue()))
                    //{
                    //    dataSetSource = getDataSetDmDmucGtriLoaiChungTuNgoaiBang(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_QUOCGIA.getValue()))
                    //{
                    //    dataSetSource = getDataSetDmQuocGia(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_TIENTE.getValue()) ||
                    //    maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_LOAITIEN.getValue()))
                    //{
                    //    dataSetSource = getDataSetDmTienTe(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_TINHTP.getValue()))
                    //{
                    //    dataSetSource = getDataSetDmTinhTp(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_COSOTINHLAI.getValue()))
                    //{
                    //    dataSetSource = getDataSetDcCsoTlai(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_LOAI_LSUAT.getValue()))
                    //{
                    //    dataSetSource = getDataSetDcLoaiLsuat(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_TINH_CHAT_TK.getValue()))
                    //{
                    //    dataSetSource = getDataSetKtNhomPloai(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_KY_HIEU.getValue()))
                    //{
                    //    dataSetSource = getDataSetKtKyHieu(maTruyVan, lstDieuKien);
                    //}
                    //else if (maTruyVan.Equals(DatabaseConstant.DanhSachTruyVan.COMBOBOX_NAM_TCHINH.getValue()))
                    //{
                    //    dataSetSource = getDataSetNamTaiChinh(maTruyVan, lstDieuKien);
                    //}
                    //else
                    //{
                        DanhSachResponse response = process.getDanhSachInformation(maTruyVan, lstDieuKien);
                        dataSetSource = response.DataSetSource;
                        
                    //}

                    foreach (DataRow row in dataSetSource.Tables[0].Rows)
                    {

                        if (row.Table.Columns.Count > 3)
                        {
                            List<string> lst = new List<string>();
                            lst.Add(row[1].ToString());
                            lst.Add(row[0].ToString());
                            for (int i = 3; i < dataSetSource.Tables[0].Columns.Count; i++)
                                lst.Add(row[i].ToString());                            
                            lstSource.Add(new AutoCompleteEntry(LLanguage.SearchResourceByKey(row[2].ToString()), lst.ToArray()));
                        }
                        else
                        {
                            lstSource.Add(new AutoCompleteEntry(LLanguage.SearchResourceByKey(row[2].ToString()), row[1].ToString(), row[0].ToString()));
                        }
                    }
                }
                if (lstMaKhoangChon != null)
                {
                    lstSource = lstSource.Where(e => lstMaKhoangChon.Contains(e.KeywordStrings.First())).ToList();
                }
                
                //while (comboBox.Items.Count > 0)
                //    comboBox.Items.RemoveAt(comboBox.Items.Count - 1);

                foreach (AutoCompleteEntry auto in lstSource)
                {
                    comboBox.Items.Add(auto);
                }
                if (!string.IsNullOrEmpty(maChon))
                {
                    if (maChon.Equals("Default"))
                        comboBox.SelectedIndex = 0;
                    else
                        comboBox.SelectedIndex = lstSource.IndexOf(lstSource.FirstOrDefault(e => e.KeywordStrings.First().Equals(maChon)));
                }
            }
            catch (Exception e)
            {
                LLogging.WriteLog("", LLogging.LogType.ERR, e);
            }
        }
コード例 #15
0
        /// <summary>
        /// Tạo AutocomboBox
        /// </summary>
        /// <param name="lstSource">Source cho Combobox</param>
        /// <param name="comboBox">Tên control Combobox được gen</param>
        /// <param name="maTruyVan">Mã truy vấn để lấy source cho combobox</param>
        /// <param name="lstDieuKien">Giá trị các điều kiện tương ứng với truy vấn</param>
        /// <param name="maChon">Mã Item sẽ được chọn nếu có</param>
        /// <param name="lstMaKhoangChon">Danh sách các Item sẽ được gen vào Combobox nếu có.</param>
        public void GenAutoComboBox(ref List <AutoCompleteEntry> lstSource, ref DropDownList comboBox, string maTruyVan, List <string> lstDieuKien = null, string maChon = "Default", List <string> lstMaKhoangChon = null)
        {
            Func <AutoCompleteEntry, bool> predicate = null;
            Func <AutoCompleteEntry, bool> func2     = null;

            try
            {
                if (!string.IsNullOrEmpty(maTruyVan))
                {
                    TruyVanProcess process       = new TruyVanProcess();
                    DataSet        dataSetSource = new DataSet();
                    dataSetSource = process.getDanhSachInformation(maTruyVan, lstDieuKien).DataSetSource;
                    foreach (DataRow row in dataSetSource.Tables[0].Rows)
                    {
                        if (row.Table.Columns.Count > 3)
                        {
                            List <string> list = new List <string> {
                                row[1].ToString(),
                                row[0].ToString()
                            };
                            for (int i = 3; i < dataSetSource.Tables[0].Columns.Count; i++)
                            {
                                list.Add(row[i].ToString());
                            }
                            lstSource.Add(new AutoCompleteEntry(LanguageEngine.Instance().GetContent(0, row[2].ToString()), list.ToArray()));
                        }
                        else
                        {
                            string content = LanguageEngine.Instance().GetContent(0, row[2].ToString());
                            if (content == "")
                            {
                                content = LanguageEngine.Instance().GetContent(0, row[1].ToString());
                            }
                            lstSource.Add(new AutoCompleteEntry(content, new string[] { row[1].ToString(), row[0].ToString() }));
                        }
                    }
                }
                if (lstMaKhoangChon != null)
                {
                    if (predicate == null)
                    {
                        predicate = e => lstMaKhoangChon.Contains(e.KeywordStrings.First <string>());
                    }
                    lstSource = lstSource.Where <AutoCompleteEntry>(predicate).ToList <AutoCompleteEntry>();
                }
                foreach (AutoCompleteEntry entry in lstSource)
                {
                    string displayName = entry.DisplayName;
                    string str3        = entry.KeywordStrings[0];
                    if (displayName == "")
                    {
                        try
                        {
                            displayName = entry.KeywordStrings[2];
                        }
                        catch
                        {
                            displayName = entry.KeywordStrings[1];
                        }
                        if (displayName == "")
                        {
                            displayName = entry.KeywordStrings[0];
                        }
                        str3 = entry.KeywordStrings[0];
                    }
                    ListItem item = new ListItem(displayName, str3);
                    comboBox.Items.Add(item);
                }
                if (!string.IsNullOrEmpty(maChon))
                {
                    if (maChon.Equals("Default"))
                    {
                        comboBox.SelectedIndex = 0;
                    }
                    else
                    {
                        if (func2 == null)
                        {
                            func2 = e => e.KeywordStrings.First <string>().Equals(maChon);
                        }
                        comboBox.SelectedIndex = lstSource.IndexOf(lstSource.FirstOrDefault <AutoCompleteEntry>(func2));
                    }
                }
            }
            catch (Exception exception)
            {
                LLogging.WriteLog("", LLogging.LogType.ERR, exception);
            }
        }