private static void Zapytania(WYNIK_DIODA myNewForm, int pion, int ilosc_powercon, double pc, int rj45, double etercon) { string zapytanie4 = "INSERT INTO " + dioda_led.dioda + " (id,nazwa,ilosc) VALUES ('3','Pion','" + pion + "');"; NowyElement(myNewForm, zapytanie4); string zapytanie5 = "INSERT INTO " + dioda_led.dioda + " (id,nazwa,ilosc) VALUES ('4','powercon 230V','" + ilosc_powercon + "');"; NowyElement(myNewForm, zapytanie5); string zapytanie6 = "INSERT INTO " + dioda_led.dioda + " (id,nazwa,ilosc) VALUES ('5','powercon','" + pc + "');"; NowyElement(myNewForm, zapytanie6); string zapytanie7 = "INSERT INTO " + dioda_led.dioda + " (id,nazwa,ilosc) VALUES ('6','etercon','" + etercon + "');"; NowyElement(myNewForm, zapytanie7); string zapytanie8 = "INSERT INTO " + dioda_led.dioda + " (id,nazwa,ilosc) VALUES ('7','rozdzielnia','" + pion + "');"; NowyElement(myNewForm, zapytanie8); string zapytanie9 = "INSERT INTO " + dioda_led.dioda + " (id,nazwa,ilosc) VALUES ('8','rj45','" + rj45 + "');"; NowyElement(myNewForm, zapytanie9); }
private static void NowyElement(WYNIK_DIODA myNewForm, string zapytanie) { string myConnectionString = "server=localhost;user=root;database=sport_media"; var polocznie = new MySqlConnection(myConnectionString); polocznie.Open(); MySqlCommand komenda = new MySqlCommand(zapytanie, polocznie); komenda.Prepare(); komenda.ExecuteNonQuery(); polocznie.Close(); }
private static double Pobor(WYNIK_DIODA myNewForm, double pole, double pobor, double maxpobor) { pobor = pole * pobor; maxpobor = pole * maxpobor; myNewForm.pobor.Text += Environment.NewLine; myNewForm.pobor.Text += "SREDNI POBOR TO: " + pobor.ToString() + "V"; myNewForm.pobor.Text += Environment.NewLine; myNewForm.pobor.Text += "MAX POBOR TO: " + maxpobor.ToString() + "V"; myNewForm.pobor.Text += Environment.NewLine; myNewForm.pobor.Text += Environment.NewLine; return(maxpobor); }
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< PANEL NOWY EVENT Z WYNIK.DIODA >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> public void button6_Click(object sender, EventArgs e) { WYNIK_DIODA myNewForm = new WYNIK_DIODA(); myNewForm.Visible = true; NOWY_EVENT.Visible = false; dioda_led.dioda = NazwaEvent.Text; myNewForm.nazwaevent.Text = dioda_led.dioda; Diody.dioda[] smd = DaneDiody(); dioda_led.szerokosc = double.Parse(szerokosc.Text.ToString()); dioda_led.wysokosc = double.Parse(wysokosc.Text.ToString()); string rodzaj_diody = "1"; int potrzeba = 0; double pole = 0; double maxpobor = 0; double smallpole = 0; string myConnectionString = "server=localhost;user=root;database=sport_media"; var pol = new MySqlConnection(myConnectionString); pol.Open(); string zapytanieSQL1 = "CREATE TABLE " + dioda_led.dioda + "(id int(100) NOT NULL,nazwa varchar(100),ilosc int(100),PRIMARY KEY(id))"; MySqlCommand komenda = new MySqlCommand(zapytanieSQL1, pol); komenda.Prepare(); komenda.ExecuteNonQuery(); pol.Close(); double kabinet = 0; myNewForm.SMDilosc.Text = ""; myNewForm.pobor.Text = ""; myNewForm.pobor.Text += Environment.NewLine; if (SMD1.Checked) { pole = dioda_led.szerokosc * dioda_led.wysokosc; rodzaj_diody = SMD1.Text; dioda_led.szerokosc = dioda_led.szerokosc / smd[1].szerokosc; dioda_led.wysokosc = dioda_led.wysokosc / smd[1].wysokosc; dioda_led.ilosckabinetow = dioda_led.szerokosc * dioda_led.wysokosc; kabinet = dioda_led.ilosckabinetow; myNewForm.SMDilosc.Text += "KABINET SMD 1" + Environment.NewLine + "ILOSC: " + dioda_led.ilosckabinetow.ToString(); //POBÓR DIODY SMD 1 myNewForm.pobor.Text += "POBOR DIODY SMD 1"; maxpobor = Pobor(myNewForm, pole, smd[1].pobor, smd[1].maxpobor); } else if (SMD2.Checked) { pole = dioda_led.szerokosc * dioda_led.wysokosc; //POBÓR DIODY SMD 2 myNewForm.pobor.Text += "POBOR DIODY SMD 2"; maxpobor = Pobor(myNewForm, pole, smd[2].pobor, smd[2].maxpobor); rodzaj_diody = SMD2.Text; dioda_led.szerokosc = dioda_led.szerokosc / smd[2].szerokosc; dioda_led.wysokosc = dioda_led.wysokosc / smd[2].wysokosc; dioda_led.ilosckabinetow = dioda_led.szerokosc * dioda_led.wysokosc; kabinet = dioda_led.ilosckabinetow; myNewForm.SMDilosc.Text += "KABINET SMD 2" + Environment.NewLine + "ILOSC: " + dioda_led.ilosckabinetow.ToString(); } else if (SMD3.Checked) { potrzeba = WymiarDiody(dioda_led.wysokosc, smd[4].wysokosc); dioda_led.szerokosc = dioda_led.szerokosc / smd[3].szerokosc; pole = dioda_led.szerokosc * dioda_led.wysokosc; if (potrzeba == 1) { kabinet += dioda_led.szerokosc; //POBÓR DIODY SMD 3 smallpole = dioda_led.szerokosc * 0.5; //POBÓR DIODY SMD 3 myNewForm.pobor.Text += "POBOR DIODY SMD 3"; maxpobor = Pobor(myNewForm, smallpole, smd[3].pobor, smd[3].maxpobor); dioda_led.wysokosc = dioda_led.wysokosc - smd[3].wysokosc; dioda_led.wysokosc = dioda_led.wysokosc / smd[4].wysokosc; myNewForm.SMDilosc.Text += "KABINET SMD 3" + Environment.NewLine + "ILOSC: " + dioda_led.szerokosc.ToString() + Environment.NewLine; string zapytanie3 = "INSERT INTO " + dioda_led.dioda + " (id,nazwa,ilosc) VALUES ('2','SMD 3','" + dioda_led.szerokosc.ToString() + "');"; NowyElement(myNewForm, zapytanie3); } rodzaj_diody = "SMD 4"; pole = pole - smallpole; myNewForm.pobor.Text += "POBOR DIODY SMD 4"; maxpobor = Pobor(myNewForm, smallpole, smd[4].pobor, smd[4].maxpobor); dioda_led.ilosckabinetow = dioda_led.szerokosc * dioda_led.wysokosc; kabinet += dioda_led.ilosckabinetow; myNewForm.SMDilosc.Text += "KABINET SMD 4" + Environment.NewLine + "ILOSC: " + dioda_led.ilosckabinetow.ToString(); } string zapytanie2 = "INSERT INTO " + dioda_led.dioda + " (id,nazwa,ilosc) VALUES ('1','" + rodzaj_diody + "','" + dioda_led.ilosckabinetow.ToString() + "');"; NowyElement(myNewForm, zapytanie2); pol.Close(); int pion = 0; double kwpobor = maxpobor / 1000; do { pion++; kwpobor = kwpobor - 21; } while (kwpobor > 21); myNewForm.pobor.Text += Environment.NewLine; myNewForm.pobor.Text += Environment.NewLine; int ilosc_powercon = 0; double powercon = maxpobor / 3680; do { ilosc_powercon++; powercon--; } while (powercon > 1); double pc = ((kabinet * 2) - ilosc_powercon) - 1; int rj45 = 0; //jedna rj45 moze byc na 15 kabinetow for (int t = 0; t < kabinet; t = t + 15) { rj45++; } double etercon; etercon = ((kabinet * 2) - rj45) - 1; Zapytania(myNewForm, pion, ilosc_powercon, pc, rj45, etercon); int kabinet_rys = 0; if (SMD1.Checked || SMD2.Checked) { int columnCount = Convert.ToInt32(dioda_led.szerokosc); int rowCount = Convert.ToInt32(dioda_led.wysokosc); //Clear out the existing controls, we are generating a new table layout myNewForm.tableLayoutPanel1.Controls.Clear(); //Clear out the existing row and column styles myNewForm.tableLayoutPanel1.ColumnStyles.Clear(); myNewForm.tableLayoutPanel1.RowStyles.Clear(); //Now we will generate the table, setting up the row and column counts first myNewForm.tableLayoutPanel1.ColumnCount = columnCount; myNewForm.tableLayoutPanel1.RowCount = rowCount; myNewForm.tableLayoutPanel1.AutoScroll = true; for (int x = 0; x < columnCount; x++) { //First add a column myNewForm.tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); for (int y = 0; y < rowCount; y++) { kabinet_rys++; //Next, add a row. Only do this when once, when creating the first column myNewForm.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize)); //Create the control, in this case we will add a button Label cmd = new Label(); cmd.Size = new System.Drawing.Size(100, 100); cmd.Font = new Font("Arial", 20, FontStyle.Bold); cmd.Margin = new Padding(10, 10, 10, 10); cmd.BackColor = Color.Blue; cmd.Text = kabinet_rys.ToString(); //Finally, add the control to the correct location in the table myNewForm.tableLayoutPanel1.Controls.Add(cmd); } } } else { kabinet_rys = 0; int rowCount1 = Convert.ToInt32(dioda_led.wysokosc); int columnCount1 = Convert.ToInt32(dioda_led.szerokosc); //Clear out the existing controls, we are generating a new table layout myNewForm.tableLayoutPanel1.Controls.Clear(); //Clear out the existing row and column styles myNewForm.tableLayoutPanel1.ColumnStyles.Clear(); myNewForm.tableLayoutPanel1.RowStyles.Clear(); //Now we will generate the table, setting up the row and column counts first myNewForm.tableLayoutPanel1.ColumnCount = columnCount1; myNewForm.tableLayoutPanel1.RowCount = rowCount1; myNewForm.tableLayoutPanel1.AutoScroll = true; if (potrzeba == 1) { //First add a column myNewForm.tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); for (int y = 0; y < columnCount1; y++) { kabinet_rys++; //Next, add a row. Only do this when once, when creating the first column myNewForm.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize)); //Create the control, in this case we will add a button Label small = new Label(); small.Size = new System.Drawing.Size(100, 100); small.Font = new Font("Arial", 20, FontStyle.Bold); small.Margin = new Padding(10, 10, 10, 10); small.BackColor = Color.Red; small.Text = kabinet_rys.ToString(); //Finally, add the control to the correct location in the table myNewForm.tableLayoutPanel1.Controls.Add(small); } } for (int x = 0; x < columnCount1; x++) { //First add a column myNewForm.tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize)); for (int y = 0; y < rowCount1; y++) { kabinet_rys++; //Next, add a row. Only do this when once, when creating the first column myNewForm.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize)); //Create the control, in this case we will add a button Label cmd = new Label(); cmd.Size = new System.Drawing.Size(100, 200); cmd.Font = new Font("Arial", 20, FontStyle.Bold); cmd.Margin = new Padding(10, 10, 10, 10); cmd.BackColor = Color.Blue; cmd.Text = kabinet_rys.ToString(); //Finally, add the control to the correct location in the table myNewForm.tableLayoutPanel1.Controls.Add(cmd); } } NazwaEvent.Text = ""; szerokosc.Text = ""; wysokosc.Text = ""; SMD1.Checked = false; SMD2.Checked = false; SMD3.Checked = false; } }