예제 #1
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");
            }
        }
        /// <summary>
        /// Begins edit current cell.
        /// </summary>
        /// <param name="row">Parent row for cell.</param>
        public void BeginEditCurrentCell(DataRow row)
        {
            Debug.Assert(null != row);

            ColumnBase currentColumn = this.CurrentColumn;
            Debug.Assert(null != currentColumn);
            Debug.Assert(null != row.Cells[currentColumn.FieldName]);
            row.Cells[currentColumn.FieldName].BeginEdit();
        }