InitializeForm(string _verseny, Korosztály _korosztály) { Text = "Korosztály"; ClientSize = new Size(400 - 64, 304); MinimumSize = ClientSize; StartPosition = FormStartPosition.CenterScreen; FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; }
public Form_Korosztály(string _verseny, Korosztály _korosztály) { eredeti_verseny = _verseny; InitializeForm(_verseny, _korosztály); InitializeContent(_verseny, _korosztály); InitializeData(_korosztály); }
public bool KorosztályMódosítás(string _azonosító, Korosztály _korosztály) { lock (Program.datalock) { connection.Open( ); SQLiteCommand command = connection.CreateCommand(); if (_azonosító != _korosztály.Azonosito) { command.CommandText = "SELECT KOAZON FROM Korosztályok WHERE VEAZON = '" + _korosztály.Verseny + "';"; SQLiteDataReader reader = command.ExecuteReader(); bool found = false; while (reader.Read( )) { if (_korosztály.Azonosito == reader.GetString(0)) { found = true; } } command.Dispose( ); if (found) { connection.Close( ); return(false); } } command = connection.CreateCommand( ); command.CommandText = "UPDATE Korosztályok SET KOAZON = '" + _korosztály.Azonosito + "', KOMEGN = '" + _korosztály.Megnevezes + "', " + "KOEKMI = " + _korosztály.AlsoHatar + ", KOEKMA = " + _korosztály.FelsoHatar + ", KONOK = " + (_korosztály.Nokre ? "1" : "0") + ", KOFERF = " + (_korosztály.Ferfiakra ? "1" : "0") + ", KOINSF = " + _korosztály.InduloFerfiak + ", KOINSN = " + _korosztály.InduloNok + ", KOEGYB = " + (_korosztály.Egyben ? "1" : "0") + " WHERE KOAZON = '" + _azonosító + "' AND VEAZON = '" + _korosztály.Verseny + "';"; try { command.ExecuteNonQuery( ); } catch (System.Data.SQLite.SQLiteException) { return(false); } finally { command.Dispose( ); connection.Close( ); } return(true); } }
private void InitializeData(Korosztály _korosztály) { eredeti_azonosító = _korosztály.Azonosito; eredeti_verseny = _korosztály.Verseny; txtAzonosito.Text = _korosztály.Azonosito; txtMegnevezes.Text = _korosztály.Megnevezes; txtAlso.Text = _korosztály.AlsoHatar.ToString( ); txtFelso.Text = _korosztály.FelsoHatar.ToString( ); chkNok.Checked = _korosztály.Nokre; chkFerfiak.Checked = _korosztály.Ferfiakra; txtNo.Text = _korosztály.InduloNok.ToString( ); txtFerfi.Text = _korosztály.InduloFerfiak.ToString( ); chkEgyben.Checked = _korosztály.Egyben; }
public void Korosztály_Módosítás(string _azonosító, Korosztály _korosztály) { if (InvokeRequired) { Korosztály_Módosítás_Callback callback = new Korosztály_Módosítás_Callback(Korosztály_Módosítás); Invoke(callback, new object[] { _azonosító, _korosztály }); } else { if (!Program.database.KorosztályMódosítás(_azonosító, _korosztály)) { MessageBox.Show("Adatbázis hiba!\nLehet, hogy van már ilyen azonosító?", "Hiba", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_korosztály.Verseny == box_vazon.SelectedItem.ToString( )) { foreach (DataRow current in data.Rows) { if (_azonosító == current[1].ToString( )) { current[0] = _korosztály.Verseny; current[1] = _korosztály.Azonosito; current[2] = _korosztály.Megnevezes; current[3] = _korosztály.AlsoHatar; current[4] = _korosztály.FelsoHatar; current[5] = _korosztály.Nokre; current[6] = _korosztály.Ferfiakra; current[7] = _korosztály.InduloNok; current[8] = _korosztály.InduloFerfiak; current[9] = _korosztály.Egyben; break; } } } if (korosztály_módosítva != null) { korosztály_módosítva(_azonosító, _korosztály); } } //rendezés table.Sort(table.Columns[3], System.ComponentModel.ListSortDirection.Ascending); }
public void Korosztály_Hozzáadás(Korosztály _korosztály) { if (InvokeRequired) { Korosztály_Hozzáadás_Callback callback = new Korosztály_Hozzáadás_Callback(Korosztály_Hozzáadás); Invoke(callback, new object[] { _korosztály }); } else { if (!Program.database.ÚjKorosztály(_korosztály)) { MessageBox.Show("Adatbázis hiba!\nLehet, hogy van már ilyen azonosító?", "Hiba", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (_korosztály.Verseny == box_vazon.SelectedItem.ToString( )) { DataRow row = data.NewRow(); row[0] = _korosztály.Verseny; row[1] = _korosztály.Azonosito; row[2] = _korosztály.Megnevezes; row[3] = _korosztály.AlsoHatar; row[4] = _korosztály.FelsoHatar; row[5] = _korosztály.Nokre; row[6] = _korosztály.Ferfiakra; row[7] = _korosztály.InduloNok; row[8] = _korosztály.InduloFerfiak; row[9] = _korosztály.Egyben; data.Rows.Add(row); } if (korosztály_hozzáadva != null) { korosztály_hozzáadva(_korosztály); } } //rendezés table.Sort(table.Columns[3], System.ComponentModel.ListSortDirection.Ascending); }
public bool ÚjKorosztály(Korosztály _korosztály) { lock (Program.datalock) { connection.Open( ); SQLiteCommand command = connection.CreateCommand(); command.CommandText = "SELECT KOAZON FROM Korosztályok WHERE VEAZON = '" + _korosztály.Verseny + "';"; SQLiteDataReader reader = command.ExecuteReader(); bool found = false; while (reader.Read( )) { if (_korosztály.Azonosito == reader.GetString(0)) { found = true; } } if (found) { command.Dispose( ); connection.Close( ); return(false); } command = connection.CreateCommand( ); command.CommandText = "INSERT INTO Korosztályok (VEAZON, KOAZON, KOMEGN, KOEKMI, KOEKMA, KONOK, KOFERF, KOINSF, KOINSN, KOEGYB) VALUES('" + _korosztály.Verseny + "', '" + _korosztály.Azonosito + "', '" + _korosztály.Megnevezes + "', " + +_korosztály.AlsoHatar + ", " + _korosztály.FelsoHatar + ", " + (_korosztály.Nokre ? "1" : "0") + ", " + (_korosztály.Ferfiakra ? "1" : "0") + ", " + _korosztály.InduloFerfiak + ", " + _korosztály.InduloFerfiak + (_korosztály.Egyben ? " ,1" : " ,0") + ");"; command.ExecuteNonQuery( ); command.Dispose( ); connection.Close( ); return(true); } }
private void InitializeContent(string _verseny, Korosztály _korosztály) { Label lblAzonosito = new iLabel("Azonosító:", new Point(16, 16 + 0 * 32), this); Label lblMegnevezes = new iLabel("Megnevezés:", new Point(lblAzonosito.Location.X, 16 + 1 * 32), this); Label lblAlso = new iLabel("Alsó életkorhatár:", new Point(lblAzonosito.Location.X, 16 + 2 * 32), this); Label lblFelso = new iLabel("Felső életkorhatár:", new Point(lblAzonosito.Location.X, 16 + 3 * 32), this); Label lblNok = new iLabel("Nők:", new Point(lblAzonosito.Location.X, 16 + 4 * 32), this); lblNok.Size = new Size(64, 24); Label lblFerfiak = new iLabel("Férfiak:", new Point(lblAzonosito.Location.X + 128, 16 + 4 * 32), this); lblFerfiak.Size = new Size(64, 24); Label lblNoIndulok = new iLabel("Nő indulók:", new Point(lblAzonosito.Location.X, 16 + 6 * 32), this); Label lblFerfiIndulok = new iLabel("Férfi indulók:", new Point(lblAzonosito.Location.X, 16 + 7 * 32), this); Label lblEgyben = new iLabel("Egyben:", new Point(lblAzonosito.Location.X, 16 + 5 * 32), this); txtAzonosito = new iTextBox(new Point(lblAzonosito.Location.X + lblAzonosito.Width + 32 + 16, lblAzonosito.Location.Y), null, null, null, this); txtMegnevezes = new iTextBox(new Point(txtAzonosito.Location.X, lblMegnevezes.Location.Y), null, null, null, this); txtAlso = new iTextBox(new Point(txtAzonosito.Location.X, lblAlso.Location.Y), null, null, null, this); txtFelso = new iTextBox(new Point(txtAzonosito.Location.X, lblFelso.Location.Y), null, null, null, this); chkNok = new iCheckBox(null, new Point(lblNok.Location.X + lblNok.Size.Width + 16, lblNok.Location.Y), null, this); chkFerfiak = new iCheckBox(null, new Point(lblFerfiak.Location.X + lblFerfiak.Size.Width + 16, lblFerfiak.Location.Y), null, this); txtNo = new iLabel(null, new Point(txtAzonosito.Location.X, lblNoIndulok.Location.Y), this); txtNo.Size = new Size(64, 24); txtFerfi = new iLabel(null, new Point(txtAzonosito.Location.X, lblFerfiIndulok.Location.Y), this); txtFerfi.Size = new Size(64, 24); chkEgyben = new iCheckBox(null, new Point(txtAzonosito.Location.X, lblEgyben.Location.Y), null, this); /// Button btnRrendben = new iButton("Rendben", new Point(ClientRectangle.Width - 96 - 16, ClientRectangle.Height - 32 - 16), new Size(96, 32), btnRendben_Click, this); }