private void Search_Log(object sender, RoutedEventArgs e) { if (!(String.IsNullOrEmpty(SearchBox.Text))) { string connectionString = ConfigurationManager.ConnectionStrings["MainPage.Properties.Settings.LocalDBConnectionString"].ConnectionString; CaseDAO caseDb = new CaseDAO(); int case_id = caseDb.getCaseId(C_Name); string query = "SELECT Log_Name, Log_Desc FROM Network_Log WHERE Case_Id = @cId AND Log_Name = @logName"; using (SqlConnection myConnection = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand(query, myConnection)) using (SqlDataAdapter adapt = new SqlDataAdapter(cmd)) { cmd.Parameters.AddWithValue("@cId", case_id); cmd.Parameters.AddWithValue("@logName", SearchBox.Text); DataTable table = new DataTable("Network_Log"); adapt.Fill(table); LogTable.ItemsSource = table.DefaultView; } } else { FillDataGrid(); } }
private void validation_button(object sender, RoutedEventArgs e) { LogsDAO logdb = new LogsDAO(); //Validation if (!(String.IsNullOrEmpty(Log_Name.Text)) && (logdb.checkIfLogs(Log_Name.Text))) { if (!(String.IsNullOrEmpty(Log_Desc.Text))) { if (!(String.IsNullOrEmpty(filePath))) { if (formatBox.SelectedIndex > -1 && formatBox.SelectedIndex == 0) { CaseDAO casedb = new CaseDAO(); int caseId = casedb.getCaseId(c_name); Boolean checker = logdb.addLogToTable(Log_Name.Text, Log_Desc.Text, caseId, filePath, formatBox.Text); if (checker) { int logId = logdb.getLogId(Log_Name.Text); SY_TagDAO tagdb = new SY_TagDAO(); tagdb.addTagToTable(Log_Name.Text, logId); Console.WriteLine("WE DID IT!"); SY_ViewSpecificCase wnd = new SY_ViewSpecificCase(c_name); wnd.Show(); Close(); } } else { MessageBox.Show("Please select a file format"); } } else { MessageBox.Show("Please upload a path to load into"); } } else { MessageBox.Show("Please fill up the Log Description"); } } else { MessageBox.Show("Please fill up in the Log Name"); } }
private void FillDataGrid() { string connectionString = ConfigurationManager.ConnectionStrings["MainPage.Properties.Settings.LocalDBConnectionString"].ConnectionString; CaseDAO caseDb = new CaseDAO(); int case_id = caseDb.getCaseId(C_Name); string query = "SELECT Log_Name, Log_Desc FROM Network_Log WHERE Case_Id = @cId"; using (SqlConnection myConnection = new SqlConnection(connectionString)) using (SqlCommand cmd = new SqlCommand(query, myConnection)) using (SqlDataAdapter adapt = new SqlDataAdapter(cmd)) { cmd.Parameters.AddWithValue("@cId", case_id); DataTable table = new DataTable("Network_Log"); adapt.Fill(table); LogTable.ItemsSource = table.DefaultView; } }
private void Remove_Row(object sender, RoutedEventArgs e) { var button = sender as DependencyObject; while ((button != null) && !(button is DataGridRow)) { button = VisualTreeHelper.GetParent(button); } if (button is DataGridRow) { Console.WriteLine("YOSH"); DataGridRow cell = button as DataGridRow; TextBlock potatoe = CaseTable.Columns[0].GetCellContent(cell) as TextBlock; CaseDAO Case = new CaseDAO(); int caseId = Case.getCaseId(potatoe.Text); LogsDAO logs = new LogsDAO(); SY_TagDAO tagdb = new SY_TagDAO(); String logName = logs.getLogName(caseId); Boolean checker3 = tagdb.deleteTagFile(logName); Boolean checker = logs.deleteThroughIdFromTable(caseId); Boolean checker2 = Case.deleteCaseFromTable(potatoe.Text); if (checker && checker2 && checker3) { Console.WriteLine("WORKS"); FillDataGrid(); } } else { Console.WriteLine("No Works"); } }
private void validation_button(object sender, RoutedEventArgs e) { //Validation if (!(String.IsNullOrEmpty(Log_Name.Text))) { if (!(String.IsNullOrEmpty(Log_Desc.Text))) { if (!(String.IsNullOrEmpty(filePath))) { if (formatBox.SelectedIndex > -1) { LogsDAO logDb = new LogsDAO(); if (logDb.checkIfLogs(Log_Name.Text)) { CaseDAO db = new CaseDAO(); SY_TagDAO tagdb = new SY_TagDAO(); Boolean checker = db.addCaseToTable(c_name, c_desc, investList); Boolean checker2 = false; Boolean checker3 = false; if (checker) { int caseId = db.getCaseId(c_name); checker2 = logDb.addLogToTable(Log_Name.Text, Log_Desc.Text, caseId, filePath, formatBox.Text); } if (checker2) { int logId = logDb.getLogId(Log_Name.Text); checker3 = tagdb.addTagToTable(Log_Name.Text, logId); Console.WriteLine("WE DID IT!"); SY_CreatedSuccessCase wnd = new SY_CreatedSuccessCase(); wnd.Show(); Close(); } else { Console.WriteLine("Its not there"); } } } else { MessageBox.Show("Please select a file format"); } } else { MessageBox.Show("Please upload a path to load into"); } } else { MessageBox.Show("Please fill up the Log Description"); } } else { MessageBox.Show("Please fill up in the Log Name"); } }