private void allBarDiagramBtn_Click(object sender, EventArgs e)//+ { if (Document != null) { try { string dirPath = CommonService.GetFolderPath(); string newDirPath = string.Empty; if (dirPath != null) { newDirPath = ProccesingDataService.GroupDiagramSave(Document, dirPath, SeriesChartType.Bar); Dictionary <string, ExcelProfile> excelProfileMap = new Dictionary <string, ExcelProfile>(); foreach (var excelProfileItem in Document.ProfilesListContent) { excelProfileMap.Add(excelProfileItem.Name, excelProfileItem); } DataManipulationService.SaveExcel("Опросы", "Ответы", excelProfileMap, Document, newDirPath + "\\" + Document.DocumentName + ".xlsx"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { MessageBox.Show("Сначала необходимо загрузить анкету."); } }
private void deleteDataBtn_Click(object sender, EventArgs e)//+ { try { List <MainProfile> mainProfiles = null; using (ChooseMainProfileForm dsf = new ChooseMainProfileForm()) { dsf.Type = "delete"; dsf.ShowDialog(); if (dsf.Status) { mainProfiles = dsf.SelectedMainProfiles; DataManipulationService.DeleteMainProfile(mainProfiles); MessageBox.Show("Данные успешно удалены."); } else { return; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void saveExcelBtn_Click(object sender, EventArgs e)//+ { try { string infoFileName = string.Empty; string resultFileName = string.Empty; Dictionary <string, ExcelProfile> excelProfileMap = null; using (SheetsSettigsForm ssf = new SheetsSettigsForm()) { ssf.Type = "save"; ssf.Format = "excel"; ssf.Document = Document; ssf.ShowDialog(); if (ssf.Status) { infoFileName = ssf.InfoFileName; resultFileName = ssf.ResultFileName; excelProfileMap = ssf.ExcelProfileMap; } else { return; } } string filePath = CommonService.SaveFilePath("*.xlsx|*.xlsx", Document.DocumentName); DataManipulationService.SaveExcel(infoFileName, resultFileName, excelProfileMap, Document, filePath); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void saveQuestionInfo_Click(object sender, EventArgs e) { string filePath = CommonService.SaveFilePath("*.xlsx|*.xlsx", Document.DocumentName + " результаты"); if (filePath != null) { DataManipulationService.SaveAllQuestionInfoExcel(Document, filePath); } }
private void saveQuestionInfoBtn_Click(object sender, EventArgs e) { DataGridViewRow selectedDataGridRow = saveQuestionInfoBtn.Tag as DataGridViewRow; ExcelQuestion selectedQuestion = selectedDataGridRow.Cells["question"].Value as ExcelQuestion; ExcelProfile selectedProfile = mainTab.SelectedTab.Tag as ExcelProfile; string filePath = CommonService.SaveFilePath("*.xlsx|*.xlsx", "Вопрос " + selectedQuestion.Id + " результаты"); if (filePath != null) { DataManipulationService.SaveQuestionInfoExcel(selectedQuestion, selectedProfile, Document, filePath); } }
private void loadDataExcelBtn_Click(object sender, EventArgs e)//+ { try { string filePath = CommonService.OpenFilePath("*.xlsx|*.xlsx", "физвоспитание анкета"); if (string.IsNullOrEmpty(filePath)) { return; } string fileName = Path.GetFileNameWithoutExtension(filePath); string infoFileName = string.Empty; string resultFileName = string.Empty; Dictionary <string, string> excelProfileMap = null; using (SheetsSettigsForm ssf = new SheetsSettigsForm()) { ssf.Type = "load"; ssf.FilePath = filePath; ssf.ShowDialog(); if (ssf.Status) { infoFileName = ssf.InfoFileName; resultFileName = ssf.ResultFileName; excelProfileMap = ssf.ExcelSheetMap; } else { return; } Document = SortDocument(DataManipulationService.LoadMainProfileExcel(filePath, infoFileName, resultFileName, excelProfileMap)); if (Document != null) { ShowOnTabControl(Document); InitAutoComplete(questionTB, Document); saveBtn.Enabled = true; closeProfileBtn.Enabled = true; visDataBtn.Enabled = true; questionBtn.Enabled = true; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void saveDBBtn_Click(object sender, EventArgs e)//+ { try { using (profileContext db = new profileContext()) { using (Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction tr = db.Database.BeginTransaction()) { try { try { DataManipulationService.SaveProfileToDB(db, tr, Document); tr.Commit(); } catch (Exception ex) { tr.Rollback(); MessageBox.Show(ex.Message); return; } DataManipulationService.SaveResultToDB(db, tr, Document); } catch (Exception ex) { MainProfile mainProfile = db.MainProfile.SingleOrDefault(p => p.Name == Document.DocumentName); if (mainProfile != null) { db.MainProfile.Remove(mainProfile); db.SaveChanges(); } MessageBox.Show(ex.Message); return; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void loadDataDBBtn_Click(object sender, EventArgs e)//+ { try { MainProfile mainProfile = null; using (ChooseMainProfileForm cmp = new ChooseMainProfileForm()) { cmp.Type = "load"; cmp.ShowDialog(); if (cmp.Status) { mainProfile = cmp.SelectedMainProfiles[0]; Document = SortDocument(DataManipulationService.LoadMainProfileDB(mainProfile)); if (Document != null) { ShowOnTabControl(Document); InitAutoComplete(questionTB, Document); saveBtn.Enabled = true; closeProfileBtn.Enabled = true; visDataBtn.Enabled = true; questionBtn.Enabled = true; MessageBox.Show("Данные успешно загружены."); } } else { return; } } } catch (Exception ex) { MessageBox.Show(ex.Message + " Исправте ошибки и попытайтесь снова!"); return; } }