Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel;
- using System.Data;
- using System.Windows.Forms;
- namespace BriggForms
- {
- public partial class PickBoxes : Form
- {
- BriggData _brigg = BriggData.GetInstance();
- public PickBoxes()
- {
- InitializeComponent();
- }
- private void PickBoxes_Load(object sender, EventArgs e)
- {
- DataSet ds = _brigg.Set;
- DataTable tabLeft = new DataTable("PickLeft");
- ds.Tables.Add(tabLeft);
- tabLeft.Columns.Add("Id", typeof(System.Int64));
- ds.Relations.Add("PickLeft_Schueler",
- ds.Tables["Schueler"].Columns["PK_Schueler"],
- ds.Tables["PickLeft"].Columns["Id"],
- false);
- ds.Tables["PickLeft"].Columns.Add("Text", typeof(string), "SUBSTRING(Parent.Vorname, 1, 1) + '. ' + Parent.Nachname");
- foreach (DataRow rs in _brigg["Schueler"].Rows)
- {
- DataRow rn = tabLeft.NewRow();
- rn["Id"] = rs["PK_Schueler"];
- tabLeft.Rows.Add(rn);
- }
- internSetGridValues(_gridView1, "PickLeft");
- DataTable tabRight = new DataTable("PickRight");
- ds.Tables.Add(tabRight);
- tabRight.Columns.Add("Id", typeof(System.Int64));
- ds.Relations.Add("PickRight_Schueler",
- ds.Tables["Schueler"].Columns["PK_Schueler"],
- ds.Tables["PickRight"].Columns["Id"],
- false);
- ds.Tables["PickRight"].Columns.Add("Text", typeof(string), "Parent.Vorname + ' ' + SUBSTRING(Parent.Nachname, 1, 1) + '.'");
- internSetGridValues(_gridView2, "PickRight");
- }
- private void internSetGridValues(DataGridView gridView, string tableName)
- {
- gridView.DataSource = _brigg.Set.Tables[tableName];
- gridView.AllowUserToAddRows = false;
- gridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
- gridView.RowHeadersVisible = false;
- gridView.EditMode = DataGridViewEditMode.EditProgrammatically;
- gridView.AllowUserToResizeRows = false;
- gridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
- gridView.Sort(gridView.Columns["Id"], ListSortDirection.Ascending);
- }
- private void _button1_Click(object sender, EventArgs e)
- {
- DataTable tabRight = _brigg.getTable("PickRight");
- foreach (DataGridViewRow gridRow in _gridView1.SelectedRows)
- {
- DataRow row = ((DataRowView)gridRow.DataBoundItem).Row;
- DataRow rowNew = tabRight.NewRow();
- rowNew["Id"] = row["Id"];
- tabRight.Rows.Add(rowNew);
- row.Delete();
- }
- }
- private void _button2_Click(object sender, EventArgs e)
- {
- DataTable tabLeft = _brigg.getTable("PickLeft");
- foreach (DataGridViewRow gridRow in _gridView2.SelectedRows)
- {
- DataRow row = ((DataRowView)gridRow.DataBoundItem).Row;
- DataRow rowNew = tabLeft.NewRow();
- rowNew["Id"] = row["Id"];
- tabLeft.Rows.Add(rowNew);
- row.Delete();
- }
- }
- private void _textFilter_TextChanged(object sender, EventArgs e)
- {
- DataSet ds = _brigg.Set;
- DataTable tabLeft = ds.Tables["PickLeft"];
- tabLeft.DefaultView.RowFilter = string.Format("Text LIKE '%{0}%'", _textFilter.Text);
- }
- private void _buttonOk_Click(object sender, EventArgs e)
- {
- System.Windows.Forms.Application.Exit();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement