public static void InitiateComponents() { library_dbDataSet = new library2.library_dbDataSet(); library_dbDataSet.DataSetName = "library_dbDataSet"; library_dbDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; }
private void Fill_FlowLayoutPanel() // Fills flowLayoutPanel with labels and controls for each column { if (dataGridView.SelectedCells.Count == 0) { dataGridView.Rows[0].Selected = true; } row_index = dataGridView.SelectedCells[0].OwningRow.Index; try { id_value = Int32.Parse(dataGridView.SelectedCells[0].OwningRow.Cells["id"].Value.ToString()); } catch (Exception ex) { } if (id_value == -1) { if (option == FormWithFieldsOptions.edit) { id_value = Int32.Parse(dataGridView.SelectedCells[0].OwningRow.Cells["idDataGridViewTextBoxColumn"].Value.ToString()); } } library_dbDataSet ds = DataGridViews.library_db.library_dbDataSet; DataTable dt = ds.Tables[table_name]; foreach (DataGridViewColumn clmn in dataGridView.Columns) { String type = clmn.ValueType.Name; String name = null; Control control = null; // Will be either null, Form or DateTimePicker String table_to_open = null; String displayed_text = null; if (option == FormWithFieldsOptions.edit) { displayed_text = dataGridView.Rows[row_index].Cells[clmn.Name].Value.ToString(); } //if (option == FormWithFieldsOptions.add && clmn.HeaderText == "id") //{ // try // { // displayed_text = dataGridView.Rows[dataGridView.Rows.Count - 1].Cells["id"].Value.ToString(); // } // catch(Exception ex) // { // displayed_text = (Int32.Parse(dataGridView.Rows[dataGridView.Rows.Count - 2].Cells["idDataGridViewTextBoxColumn"].Value.ToString())+1).ToString(); // } //} if (clmn.GetType().Name == "DataGridViewComboBoxColumn") // If column uses a view than button should open a form { name = (clmn as DataGridViewComboBoxColumn).ValueMember; control = new Form(); (control as Form).TopLevel = false; } else { name = clmn.HeaderText; if (type == "DateTime" || type == "Date") // If it's a date-type than button should open a form with datetimepicker { control = new DateTimePicker(); } if (type == "Byte[]") { control = new PictureBox(); } } if (SettingsClass.tables_dict.ContainsKey(name)) { control.Tag = SettingsClass.tables_dict[name]; } //if (SettingsClass.controls_dict.ContainsKey(name)) //{ // control.Tag = SettingsClass.controls_dict[name].Tag; //} bool required = !dt.Columns[clmn.Index].AllowDBNull; // Is current field necessary if (required) { requiredExists = true; } flowLayoutPanel.Controls.Add(new LabelAndControls(name, control, required, ok_btn, table_to_open, option, displayed_text)); } if (foreign_dict.ContainsKey(table_name)) { foreach (String table in foreign_dict[table_name]) { String name = null; if (table.Contains(".")) { name = table.Split(new char[] { '.' })[2] + " (множественный выбор)"; } else { name = table + " (множественный выбор)"; } Control control = null; control = new Form(); (control as Form).TopLevel = false; control.Tag = table; flowLayoutPanel.Controls.Add(new LabelAndControls(name, control, false, ok_btn, null, FormWithFieldsOptions.chooseMultiple)); } } (flowLayoutPanel.Controls[1] as LabelAndControls).CheckFields(); if (requiredExists) { Label warning = new Label(); warning.Text = "Поля, отмеченные * обязательны для заполнения"; warning.Width = 500; flowLayoutPanel.Controls.Add(warning); } }
public Addresses() { this.addressesBindingSource = new System.Windows.Forms.BindingSource(); this.library_dbDataSet = new library2.library_dbDataSet(); this.addressesTableAdapter = new library2.library_dbDataSetTableAdapters.AddressesTableAdapter(); this.getStreetsBindingSource = new System.Windows.Forms.BindingSource(); this.getStreetsTableAdapter = new library2.library_dbDataSetTableAdapters.GetStreetsTableAdapter(); this.idDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.houseDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.streetidDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.roomDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.AutoGenerateColumns = false; this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.idDataGridViewTextBoxColumn, this.houseDataGridViewTextBoxColumn, this.roomDataGridViewTextBoxColumn, this.streetidDataGridViewTextBoxColumn }); this.DataSource = this.addressesBindingSource; this.Location = new System.Drawing.Point(107, 157); this.Name = "dataGridView1"; this.Size = new System.Drawing.Size(452, 150); this.TabIndex = 0; // // addressesBindingSource // this.addressesBindingSource.DataMember = "Addresses"; this.addressesBindingSource.DataSource = this.library_dbDataSet; // // library_dbDataSet // this.library_dbDataSet.DataSetName = "library_dbDataSet"; this.library_dbDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // addressesTableAdapter // this.addressesTableAdapter.ClearBeforeFill = true; // // getStreetsBindingSource // this.getStreetsBindingSource.DataMember = "GetStreets"; this.getStreetsBindingSource.DataSource = this.library_dbDataSet; // // getStreetsTableAdapter // this.getStreetsTableAdapter.ClearBeforeFill = true; // // idDataGridViewTextBoxColumn // this.idDataGridViewTextBoxColumn.DataPropertyName = "id"; this.idDataGridViewTextBoxColumn.HeaderText = "id"; this.idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn"; // // houseDataGridViewTextBoxColumn // this.houseDataGridViewTextBoxColumn.DataPropertyName = "house"; this.houseDataGridViewTextBoxColumn.HeaderText = "house"; this.houseDataGridViewTextBoxColumn.Name = "houseDataGridViewTextBoxColumn"; // // roomDataGridViewTextBoxColumn // this.roomDataGridViewTextBoxColumn.DataPropertyName = "room"; this.roomDataGridViewTextBoxColumn.HeaderText = "room"; this.roomDataGridViewTextBoxColumn.Name = "roomDataGridViewTextBoxColumn"; // // streetidDataGridViewTextBoxColumn // this.streetidDataGridViewTextBoxColumn.DataPropertyName = "street_id"; this.streetidDataGridViewTextBoxColumn.DataSource = this.getStreetsBindingSource; this.streetidDataGridViewTextBoxColumn.DisplayMember = "name"; this.streetidDataGridViewTextBoxColumn.HeaderText = "street_id"; this.streetidDataGridViewTextBoxColumn.Name = "streetidDataGridViewTextBoxColumn"; this.streetidDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.streetidDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; this.streetidDataGridViewTextBoxColumn.ValueMember = "street_id"; this.streetidDataGridViewTextBoxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; this.getStreetsTableAdapter.Fill(this.library_dbDataSet.GetStreets); this.addressesTableAdapter.Fill(this.library_dbDataSet.Addresses); }
public Authors() { this.library_dbDataSet = new library2.library_dbDataSet(); this.authorsBindingSource = new System.Windows.Forms.BindingSource(); this.authorsTableAdapter = new library2.library_dbDataSetTableAdapters.AuthorsTableAdapter(); this.getGendersBindingSource = new System.Windows.Forms.BindingSource(); this.getGendersTableAdapter = new library2.library_dbDataSetTableAdapters.GetGendersTableAdapter(); this.idDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.nameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.lastnameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.genderidDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.AutoGenerateColumns = false; this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.idDataGridViewTextBoxColumn, this.nameDataGridViewTextBoxColumn, this.lastnameDataGridViewTextBoxColumn, this.genderidDataGridViewTextBoxColumn }); this.DataSource = this.authorsBindingSource; this.Location = new System.Drawing.Point(47, 111); this.Name = "dataGridView1"; this.Size = new System.Drawing.Size(633, 150); this.TabIndex = 0; // // library_dbDataSet // this.library_dbDataSet.DataSetName = "library_dbDataSet"; this.library_dbDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // authorsBindingSource // this.authorsBindingSource.DataMember = "Authors"; this.authorsBindingSource.DataSource = this.library_dbDataSet; // // authorsTableAdapter // this.authorsTableAdapter.ClearBeforeFill = true; // // getGendersBindingSource // this.getGendersBindingSource.DataMember = "GetGenders"; this.getGendersBindingSource.DataSource = this.library_dbDataSet; // // getGendersTableAdapter // this.getGendersTableAdapter.ClearBeforeFill = true; // // idDataGridViewTextBoxColumn // this.idDataGridViewTextBoxColumn.DataPropertyName = "id"; this.idDataGridViewTextBoxColumn.HeaderText = "id"; this.idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn"; // // nameDataGridViewTextBoxColumn // this.nameDataGridViewTextBoxColumn.DataPropertyName = "name"; this.nameDataGridViewTextBoxColumn.HeaderText = "name"; this.nameDataGridViewTextBoxColumn.Name = "nameDataGridViewTextBoxColumn"; // // lastnameDataGridViewTextBoxColumn // this.lastnameDataGridViewTextBoxColumn.DataPropertyName = "lastname"; this.lastnameDataGridViewTextBoxColumn.HeaderText = "lastname"; this.lastnameDataGridViewTextBoxColumn.Name = "lastnameDataGridViewTextBoxColumn"; // // genderidDataGridViewTextBoxColumn // this.genderidDataGridViewTextBoxColumn.DataPropertyName = "gender_id"; this.genderidDataGridViewTextBoxColumn.DataSource = this.getGendersBindingSource; this.genderidDataGridViewTextBoxColumn.DisplayMember = "name"; this.genderidDataGridViewTextBoxColumn.DisplayStyle = System.Windows.Forms.DataGridViewComboBoxDisplayStyle.Nothing; this.genderidDataGridViewTextBoxColumn.HeaderText = "gender_id"; this.genderidDataGridViewTextBoxColumn.Name = "genderidDataGridViewTextBoxColumn"; this.genderidDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.genderidDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; this.genderidDataGridViewTextBoxColumn.ValueMember = "gender_id"; this.getGendersTableAdapter.Fill(this.library_dbDataSet.GetGenders); this.authorsTableAdapter.Fill(this.library_dbDataSet.Authors); }
public Localities() { this.localitiesTableAdapter = new library2.library_dbDataSetTableAdapters.LocalitiesTableAdapter(); this.localitiesBindingSource = new System.Windows.Forms.BindingSource(); this.library_dbDataSet = new library2.library_dbDataSet(); this.getContriesBindingSource = new System.Windows.Forms.BindingSource(); this.getContriesTableAdapter = new library2.library_dbDataSetTableAdapters.GetContriesTableAdapter(); this.getLocalityTypesBindingSource = new System.Windows.Forms.BindingSource(); this.getLocalityTypesTableAdapter = new library2.library_dbDataSetTableAdapters.GetLocalityTypesTableAdapter(); this.idDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.localityTypeidDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.contryidDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); this.nameDataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.AutoGenerateColumns = false; this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.idDataGridViewTextBoxColumn, this.localityTypeidDataGridViewTextBoxColumn, this.contryidDataGridViewTextBoxColumn, this.nameDataGridViewTextBoxColumn1 }); this.DataSource = this.localitiesBindingSource; this.Location = new System.Drawing.Point(78, 62); this.Name = "dataGridView2"; this.Size = new System.Drawing.Size(692, 150); this.TabIndex = 1; // // localitiesBindingSource // this.localitiesBindingSource.DataMember = "Localities"; this.localitiesBindingSource.DataSource = this.library_dbDataSet; // // library_dbDataSet // this.library_dbDataSet.DataSetName = "library_dbDataSet"; this.library_dbDataSet.SchemaSerializationMode = System.Data.SchemaSerializationMode.IncludeSchema; // // getContriesBindingSource // this.getContriesBindingSource.DataMember = "GetContries"; this.getContriesBindingSource.DataSource = this.library_dbDataSet; // // getContriesTableAdapter // this.getContriesTableAdapter.ClearBeforeFill = true; // // getLocalityTypesBindingSource // this.getLocalityTypesBindingSource.DataMember = "GetLocalityTypes"; this.getLocalityTypesBindingSource.DataSource = this.library_dbDataSet; // // getLocalityTypesTableAdapter // this.getLocalityTypesTableAdapter.ClearBeforeFill = true; // // idDataGridViewTextBoxColumn1 // this.idDataGridViewTextBoxColumn.DataPropertyName = "id"; this.idDataGridViewTextBoxColumn.HeaderText = "id"; this.idDataGridViewTextBoxColumn.Name = "idDataGridViewTextBoxColumn"; // // localityTypeidDataGridViewTextBoxColumn // this.localityTypeidDataGridViewTextBoxColumn.DataPropertyName = "localityType_id"; this.localityTypeidDataGridViewTextBoxColumn.DataSource = this.getLocalityTypesBindingSource; this.localityTypeidDataGridViewTextBoxColumn.DisplayMember = "name"; this.localityTypeidDataGridViewTextBoxColumn.HeaderText = "localityType_id"; this.localityTypeidDataGridViewTextBoxColumn.Name = "localityTypeidDataGridViewTextBoxColumn"; this.localityTypeidDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.localityTypeidDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; this.localityTypeidDataGridViewTextBoxColumn.ValueMember = "localityType_id"; this.localityTypeidDataGridViewTextBoxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; // // contryidDataGridViewTextBoxColumn // this.contryidDataGridViewTextBoxColumn.DataPropertyName = "contry_id"; this.contryidDataGridViewTextBoxColumn.DataSource = this.getContriesBindingSource; this.contryidDataGridViewTextBoxColumn.DisplayMember = "name"; this.contryidDataGridViewTextBoxColumn.HeaderText = "contry_id"; this.contryidDataGridViewTextBoxColumn.Name = "contryidDataGridViewTextBoxColumn"; this.contryidDataGridViewTextBoxColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; this.contryidDataGridViewTextBoxColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic; this.contryidDataGridViewTextBoxColumn.ValueMember = "contry_id"; this.contryidDataGridViewTextBoxColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; // // nameDataGridViewTextBoxColumn1 // this.nameDataGridViewTextBoxColumn1.DataPropertyName = "name"; this.nameDataGridViewTextBoxColumn1.HeaderText = "name"; this.nameDataGridViewTextBoxColumn1.Name = "nameDataGridViewTextBoxColumn1"; this.localitiesTableAdapter.Fill(this.library_dbDataSet.Localities); this.getLocalityTypesTableAdapter.Fill(this.library_dbDataSet.GetLocalityTypes); this.getContriesTableAdapter.Fill(this.library_dbDataSet.GetContries); }