public ViewForm(RedComboBox[] comboboxes, RedContext context) { InitializeComponent(); dataGridView1.AutoGenerateColumns = false; parametrs = new List<string>(); InitGrid(comboboxes, context); }
private void InitGrid(RedComboBox[] comboboxes, RedContext context) { foreach(RedComboBox cb in comboboxes) { var row = new DataGridViewRow(); var c1 = new DataGridViewTextBoxCell(); c1.Value = cb.Name; DataGridViewCell c2; if (cb.query.ToLowerInvariant() == "textedit") { c2 = new DataGridViewTextBoxCell(); c2.Value = ""; } else { c2 = new DataGridViewComboBoxCell(); var t = cb.GetValues(context); foreach (DataRow r in t.Rows) { (c2 as DataGridViewComboBoxCell).Items.Add(r[0].ToString()); } (c2 as DataGridViewComboBoxCell).Value = (c2 as DataGridViewComboBoxCell).Items[0]; } c2.ReadOnly = false; row.Cells.Add(c1); row.Cells.Add(c2); dataGridView1.Rows.Add(row); } }
public StudentCompetitionReportGeneration(RedContext context) { InitializeComponent(); this.context = context; var students = context.Provider.ExecuteSelectCommand(studQuery); comboBox1.ValueMember = "Id"; comboBox1.DisplayMember = "Name"; comboBox1.DataSource = students; }
public RedTable(string tablename, string query, RedContext context, string searchQuery=null ) : base(tablename) { this.query = query; context.Provider.OpenConnection(); dataAdapter = new SqlDataAdapter(query, context.Provider.Connection); var builder = new SqlCommandBuilder(dataAdapter); FillAdapter(context); dataAdapter.UpdateCommand = builder.GetUpdateCommand(); context.Provider.CloseConnection(); ComboBoxes = new Dictionary<string, RedComboBox>(); columnHeaders = new Dictionary<string, string>(); SearchQuery = searchQuery; }
public RedTable(string tablename, string query, RedContext context, string searchQuery = null) : base(tablename) { this.query = query; context.Provider.OpenConnection(); dataAdapter = new SqlDataAdapter(query, context.Provider.Connection); var builder = new SqlCommandBuilder(dataAdapter); FillAdapter(context); dataAdapter.UpdateCommand = builder.GetUpdateCommand(); context.Provider.CloseConnection(); ComboBoxes = new Dictionary <string, RedComboBox>(); columnHeaders = new Dictionary <string, string>(); SearchQuery = searchQuery; }
public DataTable GetViewData(string[] parameters_, RedContext context) { string nq = query; try { nq = string.Format(query, parameters_); }catch(FormatException e) { throw new FormatException("Не коректные параметры. Вводите коректные параметры из выпадающего списка.",e); } table = context.Provider.ExecuteSelectCommand(nq); table.TableName = name; return table; }
public DataTable GetViewData(string[] parameters_, RedContext context) { string nq = query; try { nq = string.Format(query, parameters_); }catch (FormatException e) { throw new FormatException("Не коректные параметры. Вводите коректные параметры из выпадающего списка.", e); } table = context.Provider.ExecuteSelectCommand(nq); table.TableName = name; return(table); }
public ChartForm(RedContext context) { InitializeComponent(); this.context = context; var sectTable = context.Provider.ExecuteSelectCommand(sectionsQuery); comboBox1.DisplayMember = sectTable.Columns[0].ColumnName; comboBox1.DataSource = sectTable; minYear = DateTime.Parse(context.Provider.ExecuteSelectCommand(minYearQuery).Rows[0][0].ToString()).Year; maxYear = DateTime.Parse(context.Provider.ExecuteSelectCommand(maxYearQuery).Rows[0][0].ToString()).Year; zedGraphControl1.GraphPane.XAxis.Type = AxisType.Text; zedGraphControl1.GraphPane.Title.Text = graphLable; zedGraphControl1.GraphPane.XAxis.Title.Text = "Навчальні роки"; zedGraphControl1.GraphPane.YAxis.Title.Text = "Кількість студентів"; zedGraphControl1.Refresh(); }
public int Update(RedContext context) { try { context.Provider.OpenConnection(); return(dataAdapter.Update(this)); } catch (Exception e) { throw; } finally { context.Provider.CloseConnection(); } }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); XmlSerializer serializer = new XmlSerializer(typeof(DBConfig)); var conf = new DBConfig(); using (var stream = File.OpenRead(@"d:\TK\Lesia\LabaBoiko\FizDb\ProjectsManager\FizDb.WebClient\bin\DBConfig.xml")) { conf = (DBConfig)serializer.Deserialize(stream); } var context = new RedContext() { Provider = new RedDBProvider(conf.ConnectionString) }; Container.Context = context; Container.Dataset = GetDataSet(conf, context); }
private Red.RedDataSet GetDataSet(DBConfig config, RedContext context) { var dataSet = new RedDataSet(); foreach (var t in config.Tables) { dataSet.AddTable(t.query, t.name, t.SearchQuery==null? null: t.SearchQuery.Query, context); if (t.Comboboxes != null) { foreach (var c in t.Comboboxes) { dataSet.tables[t.name].AddComboBox(c.name, new RedComboBox(c.query, c.name)); } } if(t.Columns!=null) { foreach (var c in t.Columns) { dataSet.tables[t.name].AddColumnAliasHere(c.Name, c.Alias); } } } foreach (var r in config.Requests) { dataSet.AddView(r.query, r.name, r.desc, context); if (r.Comboboxes != null) { foreach (var c in r.Comboboxes) { dataSet.views[r.name].AddComboBox(c.name, new RedComboBox(c.query, c.name)); } } } return dataSet; }
public DataTable GetColumnValues(string columnName, RedContext context) { return(ComboBoxes[columnName].GetValues(context)); }
public LoginForm(RedContext context) { InitializeComponent(); this.context = context; }
public void Refresh(RedContext context) { this.Rows.Clear(); FillAdapter(context); }
private void FillAdapter(RedContext context) { context.Provider.OpenConnection(); dataAdapter.Fill(this); context.Provider.CloseConnection(); }
public DataTable GetValues(RedContext context) { var table = context.Provider.ExecuteSelectCommand(query); return table; }
public void AddView(string query, string name, string description, RedContext context) { views.Add(name, new RedView(name, query, description)); }
public void AddTable(string query, string name, string searchQuery, RedContext context) { tables.Add(name, new RedTable(name, query, context, searchQuery)); }
public int Update(RedContext context) { try { context.Provider.OpenConnection(); return dataAdapter.Update(this); } catch (Exception e) { throw; } finally { context.Provider.CloseConnection(); } }
public DataTable GetValues(RedContext context) { var table = context.Provider.ExecuteSelectCommand(query); return(table); }
public DataTable GetColumnValues(string columnName, RedContext context) { return ComboBoxes[columnName].GetValues(context); }