Morning.
Problem:
I have a class called Reports. Two constructors. One gives no parameters, the other a string array. The string array should be the reports that they would like to display. I would like to do the following:
string strSQL = this.Queries[strReportName];
I have a feeling that this is possible, because in the dataGridView that I use, I get the column index:
int nColumnIndex = dgvParts.Columns[strColumnName].Index;
Both of these examples use a string to determine what value in the array they are retrieving, but I'm not sure how to do this. Can anyone help me? Any help is appreciated.
To editions and mods: Yes, part of the reports is closely related to another message that I have about dynamic loading of DLLs, but I would like to leave another open. My boss and I decided for a short time, we will have only one DLL, and everything will be hardcoded, but in the end we want to dynamically drop the DLL as reports, so please do not put this as a duplicate. This weekend I plan to try and implement the methods provided to me in another thread. Thanks.
Edit - part 2 of the question : Ok, here is my class, as of now:
public class Queries { #region Report Queries #region Missing Code string strMissingCode = "SELECT * FROM PARTS WHERE CODE IS NULL OR CODE = ''"; #endregion #endregion }
I would like to change it to something like this:
public class Queries : Dictionary<string, string> { }
But I do not want them to use the constructor to create it. I want static sorts so that I can run the code like this:
class Reports { private List<ReportRecord> _lstRecrods = new List<ReportRecord>(); public List<ReportRecord> Records { get { return _lstRecords; } } public Reports(string[] strDisplayedReports) { foreach (string strReportTitle in strDisplayedReports) { this.BuildReportList(strReportTitle); } } private void BuildReportList(string strReportTitle) { using (DataSet ds = Database.GetDataSet(Queries[strReportTitle])) { ... } } }
How to make it static sorts where I don't need to instantiate queries? Thank you guys and girls.