Example #1
0
 public ViewForm(RedComboBox[] comboboxes, RedContext context)
 {
     InitializeComponent();
     dataGridView1.AutoGenerateColumns = false;
     parametrs = new List<string>();
     InitGrid(comboboxes, context);
 }
Example #2
0
 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;
        }
Example #4
0
 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;
 }
Example #5
0
        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;
        }
Example #6
0
 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;
 }
Example #7
0
        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);
        }
Example #8
0
 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();
 }
Example #9
0
 public int Update(RedContext context)
 {
     try
     {
         context.Provider.OpenConnection();
         return(dataAdapter.Update(this));
     }
     catch (Exception e)
     {
         throw;
     }
     finally
     {
         context.Provider.CloseConnection();
     }
 }
Example #10
0
        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);
        }
Example #11
0
        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;
        }
Example #12
0
 public DataTable GetColumnValues(string columnName, RedContext context)
 {
     return(ComboBoxes[columnName].GetValues(context));
 }
Example #13
0
 public LoginForm(RedContext context)
 {
     InitializeComponent();
     this.context = context;
 }
Example #14
0
 public void Refresh(RedContext context)
 {
     this.Rows.Clear();
     FillAdapter(context);
 }
Example #15
0
 private void FillAdapter(RedContext context)
 {
     context.Provider.OpenConnection();
     dataAdapter.Fill(this);
     context.Provider.CloseConnection();
 }
Example #16
0
 public DataTable GetValues(RedContext context)
 {
     var table = context.Provider.ExecuteSelectCommand(query);
     return table;
 }
Example #17
0
 public void Refresh(RedContext context)
 {
     this.Rows.Clear();
     FillAdapter(context);
 }
Example #18
0
 private void FillAdapter(RedContext context)
 {
     context.Provider.OpenConnection();
     dataAdapter.Fill(this);
     context.Provider.CloseConnection();
 }
Example #19
0
 public void AddView(string query, string name, string description, RedContext context)
 {
     views.Add(name, new RedView(name, query, description));
 }
Example #20
0
 public void AddTable(string query, string name, string searchQuery, RedContext context)
 {
     tables.Add(name, new RedTable(name, query, context, searchQuery));
 }
Example #21
0
 public void AddTable(string query, string name, string searchQuery, RedContext context)
 {
     tables.Add(name, new RedTable(name, query, context, searchQuery));
 }
Example #22
0
 public void AddView(string query, string name, string description, RedContext context)
 {
     views.Add(name, new RedView(name, query, description));
 }
Example #23
0
 public int Update(RedContext context)
 {
     try
     {
         context.Provider.OpenConnection();
         return dataAdapter.Update(this);
     }
     catch (Exception e)
     {
         throw;
     }
     finally
     {
         context.Provider.CloseConnection();
     }
 }
Example #24
0
        public DataTable GetValues(RedContext context)
        {
            var table = context.Provider.ExecuteSelectCommand(query);

            return(table);
        }
Example #25
0
 public DataTable GetColumnValues(string columnName, RedContext context)
 {
     return ComboBoxes[columnName].GetValues(context);
 }