private void btnPreview_Click(object sender, EventArgs e) { try { string connStr = string.Empty; if (cmbAuthentication.Text == "Windows Authentication") { connStr = ConnectionString.SQL_Windows(cmbServer.Text, cmbDatabase.Text); } else { connStr = ConnectionString.SQL_Server(cmbServer.Text, cmbDatabase.Text, txtUsername.Text, txtPassword.Text); } DataSet ds = Data.SQL.TestQuery(connStr, txtQuery.Text); if (ds.IsEmpty() == false) { DataPreview dp = new DataPreview(ds); dp.ShowDialog(); } } catch (Exception ex) { ex.Write(); } }
private void btnPreview_Click(object sender, EventArgs e) { try { string userEmail = ShowDialog("Please enter the e-mail of a user to preview.", "CGoogleDrive"); if (string.IsNullOrEmpty(userEmail)) { MessageBox.Show("You must enter an e-mail address to preview!", "CGoogleDrive"); return; } GoogleAccess ga = new GoogleAccess(); DataSet ds = ga.Preview(settings, userEmail).ToDataSet(); List <KeyValuePair <string, string> > columns = new List <KeyValuePair <string, string> >(); columns.Add(new KeyValuePair <string, string>("Id", "Id")); columns.Add(new KeyValuePair <string, string>("MimeType", "MimeType")); columns.Add(new KeyValuePair <string, string>("Name", "Name")); columns.Add(new KeyValuePair <string, string>("Size", "Size")); columns.Add(new KeyValuePair <string, string>("WebViewLink", "WebViewLink")); DataPreview dp = new DataPreview(ds, columns); dp.ShowDialog(); } catch (Exception ex) { ex.Write(); } }
private void btnPreview_Click(object sender, EventArgs e) { try { string connStr = string.Empty; if (txtUsername.Text != string.Empty || txtPassword.Text != string.Empty) { connStr = ConnectionString.MongoDB(txtServer.Text, txtUsername.Text, txtPassword.Text); } else { connStr = ConnectionString.MongoDB(txtServer.Text); } DataSet ds = Data.Mongo_DB.GetData(connStr, cmbDatabase.Text, cmbCollection.Text); if (ds.IsEmpty() == false) { DataPreview dp = new DataPreview(ds); dp.ShowDialog(); } } catch (Exception ex) { ex.Write(); } }
private void btnPreview_Click(object sender, EventArgs e) { try { if (!string.IsNullOrEmpty(txtQuery.Text)) { DataSet ds = Data.MySQL.GetData(connStr, txtQuery.Text); if (ds.IsEmpty() == false) { DataPreview dp = new DataPreview(ds); dp.ShowDialog(); } } } catch (Exception ex) { ex.Write(); } }
private void btnPreview_Click(object sender, EventArgs e) { try { StreamReader sr = new StreamReader(txtPath.Text); DataTable dt = sr.ConvertCSVtoDataTable(); if (dt.IsEmpty() == false) { DataSet ds = new DataSet(); ds.Tables.Add(dt); DataPreview dp = new DataPreview(ds); dp.ShowDialog(); } } catch (Exception ex) { ex.Write(); } }
private void PreviewExportProtocolPatients(int protocolId) { string datasetSQL = CacheManager.GetDatasetSQL(Session[SessionKey.DatasetId]); bool canViewIdentifiers = new Caisis.Controller.UserController().CanViewPatientIdentifiers(); bool includeDeceased = ExportProtocolIncludeDeceased.Checked; bool unmaskedDates = UnmaskedCheck.Checked; // get all patients on protocol var allPatients = Caisis.DataAccess.ProtocolMgmtDa.GetPatientsByProtocol(protocolId, datasetSQL, canViewIdentifiers, includeDeceased); var eligiblePatients = ProtocolMgmtServices.GetEligibleProtocolExportPatients(datasetSQL, protocolId, unmaskedDates); // create view of data, validating exportable patients var exportPatientsView = from record in allPatients.AsEnumerable() let ptProtocolId = (int)record[PatientProtocol.PatientProtocolId] let patientId = (int)record["PatientId"] let name = record["Name"].ToString() let mrn = record["PtMRN"].ToString() let screeningId = record["PtProtocolScreeningId"].ToString() let studyId = record["PtProtocolStudyId"].ToString() let schemaId = record["ProtocolSchemaId"].ToString() let schema = GetSchemaName(schemaId) let eligibleRecord = eligiblePatients.Select(PatientProtocol.PatientProtocolId + " = " + ptProtocolId).FirstOrDefault() let isExportable = eligibleRecord != null let ptAge = isExportable ? eligibleRecord[PatientProtocolRegistration.PtRegistrationAge].ToString() : "" let passedScreeningDate = isExportable ? (DateTime?)eligibleRecord["PassedScreeningDate"] : null orderby name ascending// isExportable ? 0 : 1 ascending, studyId ascending select new { Exportable = isExportable ? "Yes" : "No", PatientId = patientId, Arm = schema, Name = name, MRN = mrn, RegistrationAge = ptAge, ScreeningId = screeningId, StudyId = studyId, PassedScreeningDate = string.Format("{0:d}", passedScreeningDate) }; ExportProtocolPatientsControls.Visible = true; ExportProtocolPatientsBtns.Visible = true; // set count int totalPatientsCount = exportPatientsView.Count(); int eligiblePatientsCount = exportPatientsView.Where(p => p.Exportable == "Yes").Count(); ExportPatientCount.Text = string.Format("<b>{0}</b> of <b>{1}</b> patients eligible for export.", eligiblePatientsCount, totalPatientsCount); // build patient export preview DataPreview.DataKeyNames = new string[] { Patient.PatientId }; DataPreview.DataSource = exportPatientsView; DataPreview.DataBind(); DataPreview.Columns[0].Visible = true; // build patient export tables var exportTableNames = from table in ProtocolMgmtServices.GetPatientTableNames() let label = pdec.GetTableLabel(table) orderby table == "Patients" ? 0 : 1 ascending, label ascending select new { TableName = table, TableLabel = string.Format("{0} [{1}]", label, table) }; ExportTableNames.DataSource = exportTableNames; ExportTableNames.DataBind(); // set header SetProtocolTitle(protocolId); // set dataset var dataset = new BOL.Dataset(); dataset.Get(int.Parse(Session[SessionKey.DatasetId].ToString())); string datasetName = dataset[BOL.Dataset.DatasetName].ToString(); CurrentDataset.Text = datasetName; // set filter text MaskedDatesPanel.Visible = !unmaskedDates; UnmaskedDatesPanel.Visible = unmaskedDates; }
private void InitialiseDataPreview() { DataTable sheetOneDatatable = new DataTable(); char delimeter = Convert.ToChar(delimiters.FirstOrDefault(x => x.Key == DelimiterText.SelectedItem.ToString()).Value); // Get the column count from the first line of the file int SheetOnecolumnCount = (File.ReadLines(DataFileText.Text).First().Split(delimeter).Length); if (DataPreview.Columns.Count > 0 || DataPreview.Rows.Count > 0) { DataPreview.DataSource = null; } // TODO: Currently rowCount isn't needed - probably clean it //int rowCount = File.ReadLines(getPathFile.Element("CustomerFile").Value).Count(); try { using (StreamReader sr = File.OpenText(DataFileText.Text)) { int lineCounter = 0; int tabulatorCounter = 0; int columnCount = 0; string s = ""; string[] wholeLine = { "" }; DataRow dr = null; DataPreview.AllowUserToAddRows = false; // Disable the default row DataPreview.DoubleBuffered(true); // Enable the boublebuffering for fast scrolling while ((s = sr.ReadLine()) != null) { wholeLine = s.Split(delimeter); tabulatorCounter = 0; columnCount = s.Count(x => x == delimeter); dr = null; lineCounter++; if (!string.IsNullOrWhiteSpace(s)) { foreach (string tabulator in wholeLine) { tabulatorCounter++; // The tabulatorCounter represents the columns and is always 1 time bigger because the tabulator is inbetween the columns if (lineCounter == 1) { // TODO: Check if it is possible to add multiple columns with the same name sheetOneDatatable.Columns.Add(tabulator); } else if (lineCounter != 1) { if (dr == null) { dr = sheetOneDatatable.NewRow(); } dr[tabulatorCounter - 1] = tabulator; } } if (dr != null) { sheetOneDatatable.Rows.Add(dr); } } else { continue; } } } } catch (Exception err) { // TODO: Protocoll it } // Create a BindingSource the datatable to it BindingSource sheetOneBindingsSource = new BindingSource { DataSource = sheetOneDatatable, }; // *********************************************************************** // ******** Needed if you're on another thread as the main thread ******** // *********************************************************************** MethodInvoker AsignNewDataSource = delegate { // Asign the BindingSource to the DataGridView DataPreview.DataSource = sheetOneBindingsSource; }; if (DataPreview.InvokeRequired) { Invoke(AsignNewDataSource); } else { // Asign the BindingSource to the DataGridView DataPreview.DataSource = sheetOneBindingsSource; } //DataPreview.Columns["Sorting"].Visible = false; }