private void EqualDGV() { EditBox.Visible = !is_guest; ImportBut.Visible = !is_guest; DataBase DB = new DataBase(); DataSet ds = DB.DGView("SELECT * FROM participants;"); ds.Tables[0].Columns[1].ColumnName = "Имя"; ds.Tables[0].Columns[2].ColumnName = "Фамилия"; ds.Tables[0].Columns[3].ColumnName = "Пол"; ds.Tables[0].Columns[4].ColumnName = "Год"; ds.Tables[0].Columns[5].ColumnName = "Город рождения"; ds.Tables[0].Columns[6].ColumnName = "Место проживания"; ds.Tables[0].Columns[7].ColumnName = "Клуб"; ds.Tables[0].Columns[8].ColumnName = "Вес"; dataGridView1.DataSource = ds.Tables[0].DefaultView; dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].Width = 95; dataGridView1.Columns[2].Width = 125; dataGridView1.Columns[3].Width = 35; dataGridView1.Columns[4].Width = 85; dataGridView1.Columns[5].Width = 150; dataGridView1.Columns[6].Width = 300; dataGridView1.Columns[7].Width = 125; dataGridView1.Columns[8].Width = 85; }
private object[,] DGView(string command) { DataBase DB = new DataBase(); DataSet bd = DB.DGView(command); object[,] BDTable = new object[bd.Tables[0].Rows.Count, bd.Tables[0].Columns.Count]; foreach (DataTable dt in bd.Tables) { int i = 0; foreach (DataRow row in dt.Rows) { int b = 0; var cells = row.ItemArray; foreach (object cell in cells) { BDTable[i, b] = cell; ++b; } ++i; } } return(BDTable); }
private void button1_Click(object sender, EventArgs e) { DataBase DB = new DataBase(); DataSet bd = DB.DGView("SELECT * FROM participants;"); for (int i = 0; i < 4; i++) { string command = String.Format("DROP TABLE Group{0}", i + 1); DB.SendCommand(command); } object[,] BDTable = new object[bd.Tables[0].Rows.Count, bd.Tables[0].Columns.Count]; foreach (DataTable dt in bd.Tables) { int i = 0; foreach (DataRow row in dt.Rows) { int b = 0; var cells = row.ItemArray; foreach (object cell in cells) { BDTable[i, b] = cell; ++b; } ++i; } } object[,] GroupM = sort(BDTable, "m"); object[,] GroupF = sort(BDTable, "f"); object[][,] SLFSLM = new object[][, ] { sort(GroupF, "8", dateTimePicker1.Value.Date), sort(GroupF, "10", dateTimePicker1.Value.Date), sort(GroupM, "8", dateTimePicker1.Value.Date), sort(GroupM, "10", dateTimePicker1.Value.Date) }; object[][][,] HL = new object[4][][, ]; for (int i = 0; i < SLFSLM.Length; i++) { if (SLFSLM[i].GetLength(0) != 0) { HL[i] = MinMax(SLFSLM[i]); } } for (int i = 0; i < HL.Length; i++) { if (HL[i] != null) { int count = 0; for (int b = 0; b < HL[i].Length; b++) { if (HL[i][b].GetLength(0) > 1) { ++count; } } object[][,] temp = new object[count][, ]; count = 0; for (int b = 0; b < HL[i].Length; b++) { if (HL[i][b].GetLength(0) > 1) { temp[count] = HL[i][b]; ++count; } } HL[i] = temp; } } for (int i = 0; i < HL.Length; i++) { string command = String.Format("CREATE TABLE Group{0} (idLg INT NOT NULL, idSg INT NOT NULL);", i + 1); //string command = String.Format("DROP TABLE Group{0}", i + 1); DB.SendCommand(command); if (HL[i] != null) { for (int b = 0; b < HL[i].Length; b++) { for (int c = 0; c < HL[i][b].GetLength(0); c++) { command = String.Format("INSERT INTO Group{0} VALUES('{1}', '{2}');", i + 1, b, HL[i][b][c, 0]); DB.SendCommand(command); } } } } this.Hide(); TatamiForm tatamiForm = new TatamiForm(); tatamiForm.Show(); }