private void red_Click(object sender, RoutedEventArgs e) { string db_name = "C:\\Users\\Admin\\Documents\\ри-89\\progLab4\\db.db"; SQLiteConnection m_dbConnection; m_dbConnection = new SQLiteConnection("Data Source=" + db_name + ";Version=3;"); m_dbConnection.Open(); Window1 dialog = new Window1(); CTest redData = (CTest)data.SelectedItem; dialog.fio.AppendText(redData.fio); dialog.rateM.AppendText(redData.rateM.ToString()); dialog.rateP.AppendText(redData.rateP.ToString()); if (dialog.ShowDialog() == true) { string sql = "UPDATE fio SET fio = '" + dialog.fio.Text + "' WHERE number = " + redData.number.ToString(); SQLiteCommand command = new SQLiteCommand(sql, m_dbConnection); command.ExecuteNonQuery(); string sql1 = "UPDATE rate SET rateM = " + dialog.rateM.Text + ", rateP = " + dialog.rateP.Text + " WHERE number = " + redData.number.ToString(); SQLiteCommand command1 = new SQLiteCommand(sql1, m_dbConnection); command1.ExecuteNonQuery(); redData.fio = dialog.fio.Text; redData.rateM = int.Parse(dialog.rateM.Text); redData.rateP = int.Parse(dialog.rateP.Text); } if (data.SelectedIndex > -1) { data.Items.Insert(data.SelectedIndex, redData); data.Items.RemoveAt(data.SelectedIndex); } data.Items.Refresh(); m_dbConnection.Close(); }
//Tworzenie raportu private void Button_1_Click(object sender, RoutedEventArgs e) { //Brak wybranego raportu raportu if (Text_changed == false) { Window1 window1 = new Window1("Wybierz plik ze wzorem XSLT!"); window1.ShowDialog(); return; } if (radioButton.IsChecked == true || radioButton_Copy.IsChecked == true) { IfAnyRadioButtonSelected = true; } //Brak wybranego raportu raportu if (!IfAnyRadioButtonSelected) { Window1 window1 = new Window1("Wybierz ze zliczaniem czy bez!"); window1.ShowDialog(); return; } //Brak wybranego raportu raportu if (radioButton.IsChecked == true) { RadioButtonWithSummary = true; } else { RadioButtonWithSummary = false; } Xstl_content = File.ReadAllText(Path.GetFullPath(OpenFileDialog.FileName)); File.WriteAllText(Path2, Xstl_content); Correct = true; this.Close(); }
public void Execute(object parameter) { var command = (string)parameter; switch (command) { case "exitWnd": viewModel.Close(); break; case "openDlg": var wnd = new Window1(); var result = wnd.ShowDialog(); if (result.HasValue) { if (result.Value) { viewModel.SelectedValue = (ForSelection)wnd.comboBoxEnum.SelectedValue; } } viewModel.DialogResult = result?.ToString(); break; } }
private void button4_Click(object sender, RoutedEventArgs e) { Window1 window = new Window1(); window.ShowDialog(); }
private void SettingsButton_Click(object sender, RoutedEventArgs e) { var w = new Window1(); w.ShowDialog(); }
//Główny przycisk private void Button_1_Click(object sender, RoutedEventArgs e) { try { Error = false; if ((text_box_text_change_flag == false) || (text_box_2_text_change_flag == false)) { Window1 window1 = new Window1("Ustaw datę!"); window1.ShowDialog(); return; } foldersNameFromConfigXmlFile.ConfigFolderNamesFromConfigFile(Error); if (Error) { ResetGUIElementsAfterXSLT(); return; } DateRange dateRange = new DateRange(); ArrayOfListDates = dateRange.MonthRange(DataPicker_1, DataPicker_2); SelectedAuditionFolderFromReturn = SelectedAuditionFolder.WhichAuditionFolderIsSelected(radioButton_3, radioButton_4, TextBox_1, TextBox_2, foldersNameFromConfigXmlFile); if (SelectedAuditionFolderFromReturn.Error == true || SelectedAuditionFolderFromReturn.auditonFolder == null) { Error = true; ResetGUIElementsAfterXSLT(); return; } AuditonFolder = SelectedAuditionFolderFromReturn.auditonFolder; Error = SelectedAuditionFolderFromReturn.Error; SelectedRaport selectedRaport = new SelectedRaport(ArrayOfListDates, foldersNameFromConfigXmlFile.DestinationFolder, AuditonFolder); SelectedRaportFromReturn = selectedRaport.WhichRaportHasBeenSelected(radioButton_1, radioButton_2, radioButton_5, radioButton_9, radioButton_10); if (SelectedRaportFromReturn.Error == true || SelectedRaportFromReturn.ArrayOfAllXmlFiles == null || SelectedRaportFromReturn.OutputFileInfo == null) { ResetGUIElementsAfterXSLT(); return; } OutputFileInfo = SelectedRaportFromReturn.OutputFileInfo; ArrayOfAllXmlFiles = SelectedRaportFromReturn.ArrayOfAllXmlFiles; Error = SelectedRaportFromReturn.Error; CustomRaportWithCalculating = SelectedRaportFromReturn.CustomRaportWithCalculatingOrNo; List <string> array3 = new List <string>(); List <string> array4 = new List <string>(); OverwrtieFileFlag = true; int z = 0; //Sprawdzanie czy dany plik wyjściowy już istnieje if (File.Exists(OutputFileInfo.FileName)) { Window2 window2 = new Window2(); window2.ShowDialog(); if (!window2.Czynadpisac) { OverwrtieFileFlag = false; return; } FileInfo fff = new FileInfo(OutputFileInfo.FileName); fff.Delete(); } if (OverwrtieFileFlag) { List <string> path = new List <string>(); foreach (string file in ArrayOfAllXmlFiles) { path.Add(Path.GetFileNameWithoutExtension(file)); } DirectoryInfo di = new DirectoryInfo(folder_for_xslt_files); Parallel.ForEach(di.GetFiles(), file => { file.Delete(); }); //Osbługa transformaty XSLT na osobnym wątku w celu nie zastygania UI BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += new DoWorkEventHandler((sender1, args) => XsltTransform.DoXsltTransform(ArrayOfAllXmlFiles, path, OutputFileInfo.MainFileXslt, z)); byte wichRadioButtonIsChecked = 0; if (radioButton_2.IsChecked == true) { wichRadioButtonIsChecked = 1; } else if (radioButton_9.IsChecked == true || (radioButton_10.IsChecked == true) && (CustomRaportWithCalculating == true)) { wichRadioButtonIsChecked = 2; } bool deleteAdditionalXsltFile = false; if (radioButton_9.IsChecked == true || radioButton_10.IsChecked == true) { deleteAdditionalXsltFile = true; } bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler((sender1, args) => { XsltTranfromGetResult.GetXsltResults(wichRadioButtonIsChecked, deleteAdditionalXsltFile, OutputFileInfo.MainFileXslt, OutputFileInfo.FileName, OutputFileInfo.FirstLineOfTheOutputFile, folder_for_xslt_files, ArrayOfAllXmlFiles); ResetGUIElementsAfterXSLT(); }); bw.RunWorkerAsync(); bw.Dispose(); ProgressBar_1.IsIndeterminate = true; ProgressBar_1.Opacity = 100; Button_1.IsEnabled = groupBox_1.IsEnabled = groupBox_2.IsEnabled = DataPicker_1.IsEnabled = DataPicker_2.IsEnabled = false; } } catch (Exception ex) { MessageBox.Show("Błąd:\t" + ex, "Raport Maker V3"); FileInfo ffff = new FileInfo(OutputFileInfo.FileName); ffff.Delete(); ArrayOfAllXmlFiles.Clear(); return; } }
/// <summary> /// mainloop循环,是保证点击发送按钮后能够直接调用 /// </summary> void mainloop() { int i, k, len = 0; string filename = " "; string tempchange = " "; string lim = " "; char[] chr = textbox2.Text.ToCharArray(); char[] chname = new char[chr.Length]; char[] chos = new char[chname.Length]; char[] chok = new char[chos.Length]; for (i = 0; i < chr.Length; i++) { if (chr[i] == ' ') { i++; for (k = i; k < chr.Length; k++) { chname[k - i] = chr[k]; chr[k] = ' '; } break; } } if (chname[0] != ' ') { for (i = 0; i < chname.Length; i++) { if (chname[i] == ' ') { i++; for (k = i; k < chname.Length; k++) { chos[k - i] = chname[k]; chname[k] = ' '; } break; } } } if (chos[0] != ' ') { for (i = 0; i < chos.Length; i++) { if (chos[i] == ' ') { i++; for (k = i; k < chos.Length; k++) { chok[k - i] = chos[k]; chos[k] = ' '; } break; } } } DATA.com = new string(chr); filename = new string(chname); tempchange = new string(chos); lim = new string(chok); DATA.com = DATA.com.Trim(' '); filename = filename.Trim(' '); tempchange = tempchange.Trim(' '); DATA.com = DATA.com.Trim('\0'); filename = filename.Trim('\0'); tempchange = tempchange.Trim('\0'); lim = lim.Trim('\0'); for (i = 0; i < 22; i++) { if (DATA.com == DATA.cmd[i].com) { DATA.p = i; break; } } if (i >= 22) //如果没有这个语句以后输入的命令都和第一次输入的效果一样 { DATA.p = -1; //随便的一个值 } switch (DATA.p) { case 0: format(); //初始化 break; case 1: display_curdir(); //查看当前目录下的文件列表 break; case 2: DATA.tmp = filename; //查看文件 show_file(DATA.tmp); break; case 3: display_sys(); //查看系统信息 break; case 4: DATA.tmp = filename; //创建目录 create_dir(DATA.tmp); break; case 5: DATA.tmp = filename; //创建文件 len = Convert.ToInt32(tempchange); int limit; limit = Convert.ToInt32(lim); create_file(DATA.tmp, len, ID.login_userid, limit); break; case 6: DATA.tmp = filename; //删除文件 for (i = 0; i < 640; i++) //判断文件是不是正规文件 { DATA.j = DATA.root[i].i_num; if ((DATA.tmp == DATA.root[i].file_name) && (DATA.i_node[DATA.j].file_style == 1)) { del_file(DATA.tmp); break; } } if (i == 640) { textbox1.Text += "这个不是正规文件文件\n"; } break; case 7: DATA.tmp = filename; //删除目录 del_dir(DATA.tmp); break; case 8: DATA.tmp1 = filename; //进入当前目录下的指定目录 相当于进入目录 cd + 目录名 display_dir(DATA.tmp1); break; case 9: back_dir(); //返回上一级目录 break; case 10: help(); break; case 11: write_file(); //将磁盘利用信息写进系统文件,退出 Close(); break; case 12: DATA.tmp = filename; //打开文件 open(DATA.tmp); break; case 13: DATA.tmp = filename; //读文件 read(DATA.tmp); break; case 14: DATA.tmp = filename; //写文件 string writec; writec = tempchange; // printf("tmp=%s writec=%c\n",tmp,writec); write(DATA.tmp, writec); // printf("return here?"); break; case 15: write_file(); //退出登录 Close(); //关闭页面 Window1 mw = new Window1(); mw.ShowDialog(); //返回登陆页面框 break; case 16: DATA.tmp = filename; //关闭文件 close(DATA.tmp); break; case 17: DATA.tmp = filename; //改变目录 string dirf; dirf = tempchange; chdir(DATA.tmp, dirf); break; case 18: DATA.tmp = filename; //改变权限 int limf; limf = Convert.ToInt32(tempchange); chlim(DATA.tmp, limf); break; case 19: DATA.tmp = filename; //重命名 string namf; namf = tempchange; chnam(DATA.tmp, namf); break; case 20: DATA.tmp = filename; //复制文件 string fnam; fnam = tempchange; cp(DATA.tmp, fnam); break; case 21: DATA.tmp = filename; //创建快捷方式 string cnam; cnam = tempchange; clin(DATA.tmp, cnam); break; default: textbox1.Text += "SORRY,没有这个命令\n"; break; } DATA.j = 0; //必须重新给恢复0否则出错 DATA.tmp = DATA.cur_dir; while (DATA.tmp != "filsystem") { for (i = 0; i < 640; i++) { DATA.p = DATA.root[i].i_num; if ((DATA.tmp == DATA.root[i].file_name) && (DATA.i_node[DATA.p].file_style == 0)) { DATA.tmp2[DATA.j].com = DATA.tmp; DATA.j++; DATA.tmp = DATA.root[i].dir_name; } } } DATA.tmp2.Add(new command()); DATA.tmp2[DATA.j].com = DATA.tmp; for (i = DATA.j; i >= 0; i--) { textbox1.Text += DATA.tmp2[i].com.ToString(); textbox1.Text += "/"; } }
private void Button_Click(object sender, RoutedEventArgs e) { var child = new Window1(AddStudent); child.ShowDialog(); }
private void MenuItem_Click(object sender, RoutedEventArgs e) { Window1 win = new Window1(); win.ShowDialog(); }
private void Button_Click(object sender, RoutedEventArgs e) { Window1 w1 = new Window1(list); w1.ShowDialog(); }
private void Button_1_Click(object sender, RoutedEventArgs e) { Xstl_content = File.ReadAllText(Path1); //Sprawdzanie czy jest wybrana opcja Klasy if (checkBox_1.IsChecked == true) { if (radioButton_1.IsChecked == true) { NameOfTheClassWrittenByUser = "******"; Part_1_of_File_Name1 = radioButton_1.Content.ToString(); } else if (radioButton_2.IsChecked == true) { NameOfTheClassWrittenByUser = "******"; Part_1_of_File_Name1 = radioButton_2.Content.ToString(); } else if (radioButton_3.IsChecked == true) { NameOfTheClassWrittenByUser = "******"; Part_1_of_File_Name1 = radioButton_3.Content.ToString(); } else if (radioButton_4.IsChecked == true) { NameOfTheClassWrittenByUser = "******"; Part_1_of_File_Name1 = radioButton_4.Content.ToString(); } else if (radioButton_5.IsChecked == true) { NameOfTheClassWrittenByUser = "******"; Part_1_of_File_Name1 = radioButton_5.Content.ToString(); } else if (radioButton_6.IsChecked == true) { NameOfTheClassWrittenByUser = "******"; Part_1_of_File_Name1 = radioButton_6.Content.ToString(); } else if (radioButton_7.IsChecked == true) { NameOfTheClassWrittenByUser = "******"; Part_1_of_File_Name1 = radioButton_7.Content.ToString(); } else { Window1 window1 = new Window1("Wybierz klasę!"); window1.ShowDialog(); return; } } //Sprawdzanie czy jest wybrana opcja Nazwy if (checkBox_2.IsChecked == true) { if (Text_changed == true) { NameOfTheTitleWrittenByUser = TextBox_1.Text; Part_2_of_File_Name1 = TextBox_1.Text; } else { Window1 window1 = new Window1("Wpisz nazwę!"); window1.ShowDialog(); return; } } //Ustawianie pliku do raportu //Tylko klasa if ((checkBox_1.IsChecked == true) && (checkBox_2.IsChecked == false)) { string regex_class = @"Element[Class='" + NameOfTheClassWrittenByUser + "']"; Xstl_content = Regex.Replace(Xstl_content, "PetlaForEachDlaElementu", regex_class); Xstl_content = Regex.Replace(Xstl_content, "LengthOfTheTitleWrittenByUser", "2"); Xstl_content = Regex.Replace(Xstl_content, "WarunekIfPoczatek", ""); Xstl_content = Regex.Replace(Xstl_content, "WarunekIfKoniec", ""); Part_of_File_Name = Part_1_of_File_Name1; } //Tylko nazwa else if ((checkBox_1.IsChecked == false) && (checkBox_2.IsChecked == true)) { Xstl_content = Regex.Replace(Xstl_content, "PetlaForEachDlaElementu", "Element"); string regex_title_name_1 = "<xsl:if test=" + '"' + "$part_of_title='" + NameOfTheTitleWrittenByUser + "'" + '"' + ">"; string regex_title_name_2 = "</xsl:if>"; Xstl_content = Regex.Replace(Xstl_content, "WarunekIfPoczatek", regex_title_name_1); Xstl_content = Regex.Replace(Xstl_content, "WarunekIfKoniec", regex_title_name_2); Xstl_content = Regex.Replace(Xstl_content, "LengthOfTheTitleWrittenByUser", (NameOfTheTitleWrittenByUser.Length + 1).ToString()); Part_of_File_Name = Part_2_of_File_Name1; } //Klasa i nazwa else if ((checkBox_1.IsChecked == true) && (checkBox_2.IsChecked == true)) { string regex_class = @"Element[Class='" + NameOfTheClassWrittenByUser + "']"; Xstl_content = Regex.Replace(Xstl_content, "PetlaForEachDlaElementu", regex_class); string regex_title_name_1 = "<xsl:if test=" + '"' + "$part_of_title='" + NameOfTheTitleWrittenByUser + "'" + '"' + ">"; string regex_title_name_2 = "</xsl:if>"; Xstl_content = Regex.Replace(Xstl_content, "WarunekIfPoczatek", regex_title_name_1); Xstl_content = Regex.Replace(Xstl_content, "WarunekIfKoniec", regex_title_name_2); Xstl_content = Regex.Replace(Xstl_content, "LengthOfTheTitleWrittenByUser", (NameOfTheTitleWrittenByUser.Length + 1).ToString()); Part_of_File_Name = Part_1_of_File_Name1 + "_" + Part_2_of_File_Name1; } //Brak zaznaczenia else if ((checkBox_1.IsChecked == false) && (checkBox_2.IsChecked == false)) { Window1 window1 = new Window1("Zaznacz jedną z opcji!"); window1.ShowDialog(); return; } File.WriteAllText(Path2, Xstl_content); Correct = true; this.Close(); }
private void StartWindow1() { window2Timer.Enabled = true; window1.ShowDialog(); }