public IntegratedView bindToView(DataGridView dataGrid) { DataManager dm = new DataManager(database); string viewName = dataGrid.Name; IntegratedView view = database.getView(viewName); dataGrid.AutoGenerateColumns = false; dataGrid.DataSource = view.Table; foreach (SzpifColumn column in view.Columns.Values) { dataGrid.Columns.Add(column.createDataGridViewColumn()); } // dataGrid.Columns[dataGrid.Columns.Count - 1].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; foreach (SzpifColumn column in view.Columns.Values) { if (column.CanUpdate && view.Table.Columns.Contains(column.Name) == false) { view.Table.Columns.Add(new DataColumn(column.Name)); } } if (views.ContainsKey(viewName)) { views.Remove(viewName); } views.Add(viewName, view); return(view); }
public GetViewTransaction(string viewName) { this.view = new IntegratedView(); this.view.Table = new DataTable(); this.columnNames = new List<string>(); this.viewName = viewName; string selectCommandString = "exec get" + viewName + ";"; selectCommand = SzpifDatabase.Factory.CreateCommand(); selectCommand.CommandText = selectCommandString; selectCommand.Connection = SzpifDatabase.Connection; updateCommand = new SqlCommand(); updateCommand.Connection = (SqlConnection)SzpifDatabase.Connection; updateCommand.CommandType = CommandType.StoredProcedure; updateCommand.CommandText = "update" + viewName; insertCommand = new SqlCommand(); insertCommand.Connection = (SqlConnection)SzpifDatabase.Connection; insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.CommandText = "insert" + viewName; deleteCommand = new SqlCommand(); deleteCommand.Connection = (SqlConnection)SzpifDatabase.Connection; deleteCommand.CommandType = CommandType.StoredProcedure; deleteCommand.CommandText = "delete" + viewName;//"delete from Employees where Id = @original_id";//"delete" + viewName; }
public void setDataInGrid(List<SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view, int row) { foreach (SzpifControl c in valueBoxes) { gridView.Rows[row].Cells[c.Name].Value = c.getData(); } }
public GetViewTransaction(string viewName) { this.view = new IntegratedView(); this.view.Table = new DataTable(); this.columnNames = new List <string>(); this.viewName = viewName; string selectCommandString = "exec get" + viewName + ";"; selectCommand = SzpifDatabase.Factory.CreateCommand(); selectCommand.CommandText = selectCommandString; selectCommand.Connection = SzpifDatabase.Connection; updateCommand = new SqlCommand(); updateCommand.Connection = (SqlConnection)SzpifDatabase.Connection; updateCommand.CommandType = CommandType.StoredProcedure; updateCommand.CommandText = "update" + viewName; insertCommand = new SqlCommand(); insertCommand.Connection = (SqlConnection)SzpifDatabase.Connection; insertCommand.CommandType = CommandType.StoredProcedure; insertCommand.CommandText = "insert" + viewName; deleteCommand = new SqlCommand(); deleteCommand.Connection = (SqlConnection)SzpifDatabase.Connection; deleteCommand.CommandType = CommandType.StoredProcedure; deleteCommand.CommandText = "delete" + viewName;//"delete from Employees where Id = @original_id";//"delete" + viewName; }
public void addRowToView(List<SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view) { DataTable dt = (DataTable)gridView.DataSource; DataRow dr = dt.NewRow(); foreach (SzpifControl c in valueBoxes) { dr[c.Name] = c.getData(); } Int32 last = 0; if(dt.Rows.Count > 0)last = (Int32)dt.Rows[dt.Rows.Count - 1]["Id"] + 1; dr["Id"] = last; dt.Rows.Add(dr); }
/// <summary> /// Generates the content for insert Form. /// </summary> /// <param name="InsertForm">The insert form.</param> /// <param name="grid">Grid, którego kolumny będziemy podpinać.</param> /// <param name="schema">Schemat widoku, który jest podpięty do datagridu.</param> public List<SzpifControl> generateContent(Control parent, DataGridView gridView, IntegratedView view) { List<SzpifControl> valueBoxes = new List<SzpifControl>(); int aktY = 10; foreach(SzpifColumn column in view.Columns.Values) if (column.CanUpdate) { SzpifControl control = column.createControl(); control.Location = new Point(control.Location.X, aktY); aktY += control.Size.Height; valueBoxes.Add(control); parent.Controls.Add(control); } return valueBoxes; }
public UserSettingsPage(string text) : base(text) { contManager = Program.Context.ContentManager; bindManager = Program.Context.ViewToGridManager; InitializeComponent(); // initializing dataGridView employeesForUser = new DataGridView(); employeesForUser.Name = "EmployeesForUser"; employeesForUser.Visible = false; this.Controls.Add(employeesForUser); // binding view = bindManager.bindToView(employeesForUser); valueBoxes = contManager.generateContent(this, employeesForUser, view); }
public ICollection <string> getCurrentUserRoles() { ICollection <string> roles = new List <string>(); IntegratedView view = database.getView("EmployeesForUser"); string help = view.Table.Rows[0]["Roles"].ToString(); //string help = gridView.Rows[row].Cells[valueBox.Name].Value.ToString(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(new StringReader(help)); XElement xml = XElement.Load(new StringReader(help)); var query = from x in xml.Elements("Item") where (int)x.Attribute("Value") == 1 select x; foreach (var record in query) { roles.Add(record.Attribute("Name").Value); } return(roles); //return DataManager.getValues(view.Table, columnName); }
public IntegratedView reconnect(DataGridView dataGrid) { // DataManager dm = new DataManager(database); string viewName = dataGrid.Name; IntegratedView view = database.getView(viewName); dataGrid.AutoGenerateColumns = false; dataGrid.DataSource = view.Table; if (views.ContainsKey(viewName)) { views.Remove(viewName); } views.Add(viewName, view); foreach (SzpifColumn column in view.Columns.Values) { if (column.CanUpdate && view.Table.Columns.Contains(column.Name) == false) { view.Table.Columns.Add(new DataColumn(column.Name)); } } return(view); }
public ICollection <string> getColumnValuesFromView(string viewName, string columnName) { IntegratedView view = database.getView(viewName); return(DataManager.getValues(view.Table, columnName)); }
public void getDataFromGrid(List <SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view, int row) { foreach (SzpifControl c in valueBoxes) { if (gridView.Columns.Contains(c.Name) && gridView.Columns[c.Name].Visible == true) { c.fill(gridView.Rows[row].Cells[c.Name].Value.ToString()); } } }
public void setDataInGrid(List <SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view, int row) { foreach (SzpifControl c in valueBoxes) { gridView.Rows[row].Cells[c.Name].Value = c.getData(); } }
public void addRowToView(List <SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view) { DataTable dt = (DataTable)gridView.DataSource; DataRow dr = dt.NewRow(); foreach (SzpifControl c in valueBoxes) { dr[c.Name] = c.getData(); } Int32 last = 0; if (dt.Rows.Count > 0) { last = (Int32)dt.Rows[dt.Rows.Count - 1]["Id"] + 1; } dr["Id"] = last; dt.Rows.Add(dr); }
/// <summary> /// Generates the content for insert Form. /// </summary> /// <param name="InsertForm">The insert form.</param> /// <param name="grid">Grid, którego kolumny będziemy podpinać.</param> /// <param name="schema">Schemat widoku, który jest podpięty do datagridu.</param> public List <SzpifControl> generateContent(Control parent, DataGridView gridView, IntegratedView view) { List <SzpifControl> valueBoxes = new List <SzpifControl>(); int aktY = 10; foreach (SzpifColumn column in view.Columns.Values) { if (column.CanUpdate) { SzpifControl control = column.createControl(); control.Location = new Point(control.Location.X, aktY); aktY += control.Size.Height; valueBoxes.Add(control); parent.Controls.Add(control); } } return(valueBoxes); }
public void getDataFromGrid(List<SzpifControl> valueBoxes, DataGridView gridView, IntegratedView view, int row) { foreach (SzpifControl c in valueBoxes) if (gridView.Columns.Contains(c.Name) && gridView.Columns[c.Name].Visible == true) c.fill(gridView.Rows[row].Cells[c.Name].Value.ToString()); }