private void LoadComponent(string pid)
        {
            DBConnect db = new DBConnect();

            db.Connect();

            DataTable dttotal = db.Select("SELECT [id],[frmid],[Timing] AS [تاریخ ثبت] FROM [Which]" +
                                          " WHERE [personalid] = '" + pid + "' ORDER BY CAST([Timing] AS NVARCHAR(30)) ");

            db.DisConnect();

            GridTotal.DataSource = dttotal;
            GridTotal.DataBind();
        }
Exemple #2
0
        private void FilterAdvandedStart_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                AcynsUser1 TexTo = new AcynsUser1();
                Dictionary <string, dynamic> mapEx = new Dictionary <string, dynamic>();
                string        path1                 = appPath + @"\LuuFile" + strfile + "]ex.tex";
                List <string> listend               = new List <string>();
                List <SortId> listcodeId            = new List <SortId>();
                DataGridCollectionViewSource source = GridTotal.FindResource("cvsDataGrid") as DataGridCollectionViewSource;
                foreach (var item in DataGrid.Items)
                {
                    DataGrid.CurrentItem = item;
                    Xceed.Wpf.DataGrid.DataRow row = DataGrid.GetContainerFromItem(DataGrid.CurrentItem) as Xceed.Wpf.DataGrid.DataRow;
                    if (row != null)
                    {
                        int    numberExerciseselect = 0;
                        string codeId = row.Cells[0].Content.ToString();
                        var    itit   = row.Cells[3].Content;
                        if (row.Cells[2].Content != null)
                        {
                            numberExerciseselect = (int)row.Cells[3].Content;
                        }
                        int numberExercise = (int)row.Cells[2].Content;
                        if (numberExerciseselect > numberExercise)
                        {
                            listend = null;
                            break;
                        }
                        else
                        {
                            bool isCheck = (bool)row.Cells[4].Content;
                            if (isCheck == true && numberExerciseselect > 0)
                            {
                                List <string> list      = new List <string>();
                                List <string> listItem  = Dic[codeId];
                                int           itemCount = listItem.Count;
                                Random        random    = new Random();
                                if (sortoder.IsChecked == false)
                                {
                                    for (int i = 0; i < numberExerciseselect; i++)
                                    {
                                        list.Add(listItem[random.Next(0, itemCount)]);
                                    }
                                    listend.AddRange(list);
                                }
                                else
                                {
                                    for (int i = 0; i < numberExerciseselect; i++)
                                    {
                                        list.Add(listItem[random.Next(0, itemCount)]);
                                    }
                                    mapEx.Add(codeId, list);
                                }
                            }
                        }
                    }
                }

                if (sortoder.IsChecked == true)
                {
                    List <SortId> listsort = Dic["listid"];
                    if (Sort1.IsChecked == true)
                    {
                        listsort = listsort.OrderBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ThenBy(m => m.LevelId).ToList <SortId>();
                    }
                    if (Sort2.IsChecked == true)
                    {
                        listsort = listsort.OrderBy(m => m.ObjectId).ThenBy(m => m.ClassId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ThenBy(m => m.LevelId).ToList <SortId>();
                    }
                    if (Sort3.IsChecked == true)
                    {
                        listsort = listsort.OrderBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.LevelId).ThenBy(m => m.SectionId).ToList <SortId>();
                    }
                    if (Sort4.IsChecked == true)
                    {
                        listsort = listsort.OrderBy(m => m.LevelId).ThenBy(m => m.ClassId).ThenBy(m => m.ObjectId).ThenBy(m => m.CharterId).ThenBy(m => m.SectionId).ToList <SortId>();
                    }
                    foreach (SortId item in listsort)
                    {
                        string codeId = item.CodeId;
                        if (mapEx.ContainsKey(codeId))
                        {
                            List <string> list = mapEx[codeId];
                            listend.AddRange(list);
                            listcodeId.Add(item);
                        }
                    }
                }
                mapEx.Add("listid", listcodeId);
                string strHeader = "";
                string strFooter = "";
                if (Form.IsChecked == true)
                {
                    strHeader = File.ReadAllText(fileForm.Text);
                    string FooterPath = app + @"\MauFile\Footer.tex";
                    strFooter = File.ReadAllText(FooterPath);
                }
                if (listend != null && listend.Count > 0 && DevideFile.IsChecked == true)
                {
                    TexTo.DevideFile2("ex", mapEx, appPath, strHeader, strFooter, Boxbt.IsChecked, AutoWord.IsChecked, Devide1.IsChecked, Devide2.IsChecked, Devide3.IsChecked, Devide4.IsChecked);
                }
                if (listend != null && listend.Count > 0)
                {
                    if (commentorder.IsChecked == true)
                    {
                        User1Before classBefore = new User1Before();
                        listend = classBefore.CommentOrder(listend);
                    }
                    if (Boxex.IsChecked == true)
                    {
                        string pathnew = appPath + @"\LuuFile[" + strfile + "]ex.tex";
                        classlist.newFileTex(listend, pathnew, strHeader, strFooter);
                        FileTexEx.Text = path1;
                        NumberEx.Text  = listend.Count.ToString();
                        if (AutoWord.IsChecked == true)
                        {
                            List <string> listExNew = new List <string>();
                            foreach (string item in listend)
                            {
                                string itemnew = "e" + item.Remove(item.Length - 8, 8).Remove(0, 11);
                                listExNew.Add(itemnew);
                            }
                            string path2nem = appPath + @"\LuuFile[" + strfile + "]ex";
                            if (DevideFile.IsChecked == false)
                            {
                                TexTo.startListTexToWord1(listExNew, path2nem);
                            }
                        }
                    }
                    System.Windows.Forms.MessageBoxEx.Show("Các chức năng BankEx sẽ ko sử dụng khi lọc nâng cao,chức năng tách file, tex to word sẽ chạy bất đồng bộ, các file sẽ được lưu trong folder lọc file hoặc folder LuuFile,sẽ có thông báo khi thành công", 4000);
                }
                else
                {
                    System.Windows.MessageBox.Show("Tạo file không thành công", "Thoát");
                }
            }
            catch (Exception a)
            {
                System.Windows.MessageBox.Show(a.Message, "Thoát");
            }
        }
Exemple #3
0
        private void FilterAdvandedEx_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (System.Windows.MessageBox.Show("Tiến hành lọc Id", "Xác nhận lọc Id", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    Dic = new Dictionary <string, dynamic>();
                    List <dynamic> listMapEx = new List <dynamic>();
                    string         str       = "";
                    string         type      = "ex";
                    List <string>  listex    = new List <string>();
                    List <string>  listbt    = new List <string>();
                    List <string>  listregex = CreatRegex();
                    str     = listregex[0];
                    strfile = listregex[1];
                    Regex rx = new Regex(str);
                    listMapEx = classlist.mapNewFile(rx, type, listPath);
                    if ((listMapEx == null || listMapEx.Count == 0))
                    {
                        System.Windows.MessageBox.Show("Không có câu hỏi nào trắc nghiệm được lọc ra", "Thoát");
                    }
                    List <string> listLabel = new List <string>();
                    List <SortId> listsort  = new List <SortId>();
                    Dic = new Dictionary <string, dynamic>();
                    var listDataGrid = new List <DataGrid1>();
                    foreach (var item in listMapEx)
                    {
                        string stringId   = item["codeId"];
                        string stringEcer = item["exersice"];
                        if (listLabel.Contains(stringId))
                        {
                            Dic[stringId].Add(stringEcer);
                        }
                        else
                        {
                            List <string> listEcer = new List <string>();
                            listEcer.Add(stringEcer);
                            Dic.Add(stringId, listEcer);
                            listLabel.Add(stringId);
                            SortId sort = new SortId();
                            sort.ClassId = int.Parse(stringId[0].ToString());
                            if (stringId[1] == 'D')
                            {
                                sort.ObjectId = 1;
                            }
                            else
                            {
                                sort.ObjectId = 2;
                            }
                            sort.CharterId = int.Parse(stringId[2].ToString());
                            switch (stringId[3])
                            {
                            case 'Y':
                                sort.LevelId = 1;
                                break;

                            case 'B':
                                sort.LevelId = 2;
                                break;

                            case 'K':
                                sort.LevelId = 3;
                                break;

                            case 'G':
                                sort.LevelId = 5;
                                break;

                            case 'T':
                                sort.LevelId = 4;
                                break;
                            }
                            sort.SectionId = int.Parse(stringId[4].ToString());
                            sort.CodeId    = stringId;
                            listsort.Add(sort);
                        }
                    }
                    Dic.Add("listid", listsort);
                    Dic.Add("listCodeId", listLabel);
                    foreach (var item in listLabel)
                    {
                        DataGrid1 getDataGrid1 = new DataGrid1();
                        int       classId      = Int32.Parse(item[0].ToString());
                        if (classId > 3)
                        {
                            getDataGrid1.ClassName = "Lớp " + classId;
                        }
                        if (classId <= 3)
                        {
                            getDataGrid1.ClassName = "Lớp 1" + classId;
                        }
                        char strChapterName1 = item[1];
                        char strChapterName2 = item[2];
                        if (strChapterName1 == 'H')
                        {
                            getDataGrid1.ChapterName = "Hình  chương " + strChapterName2;
                        }
                        if (strChapterName1 == 'D')
                        {
                            getDataGrid1.ChapterName = "Đại  chương " + strChapterName2;
                        }
                        char strSectionName = item[4];
                        getDataGrid1.SectionName = "Bài " + strSectionName;
                        char levelName = item[3];
                        if (levelName == 'Y')
                        {
                            getDataGrid1.LevelId = "Yếu";
                        }
                        if (levelName == 'B')
                        {
                            getDataGrid1.LevelId = "Trung bình";
                        }
                        if (levelName == 'K')
                        {
                            getDataGrid1.LevelId = "Khá";
                        }
                        if (levelName == 'G')
                        {
                            getDataGrid1.LevelId = "Giỏi";
                        }
                        getDataGrid1.CodeId               = item;
                        getDataGrid1.NumberExersice       = Dic[item].Count;
                        getDataGrid1.NumberExersiceSelect = 0;
                        getDataGrid1.IsSelected           = false;
                        listDataGrid.Add(getDataGrid1);
                    }
                    DataGridCollectionViewSource source = GridTotal.FindResource("cvsDataGrid") as DataGridCollectionViewSource;
                    source.Source = listDataGrid;
                }
            }
            catch (Exception a)
            {
                System.Windows.MessageBox.Show(a.Message, "Thoát");
            }
        }