private void NaudButton_Click(object sender, EventArgs e) { toolPanel.Visible = true; revivePanel.Visible = false; Button b = (Button)sender; Naudotojai u = (Naudotojai)b.Tag; ID = u.GetID().ToString(); Button typeButton = new Button(); Button type1Button = new Button(); Button deleteButton = new Button(); typeButton.Text = "Padaryti Admin"; typeButton.Width = 110; typeButton.Height = 23; typeButton.Tag = (Button)sender; typeButton.Click += TypeButton_Click; typeButton.Location = new Point(0, 0); type1Button.Text = "Padaryti Ne_Admin"; type1Button.Width = 110; type1Button.Height = 23; type1Button.Tag = (Button)sender; type1Button.Click += Type1Button_Click; type1Button.Location = new Point(0, 23); deleteButton.Click += DeleteButton_Click; deleteButton.Text = ">>"; deleteButton.Width = 110; deleteButton.Height = 23; deleteButton.Tag = (Button)sender; deleteButton.Location = new Point(0, 46); toolPanel.Controls.Add(typeButton); toolPanel.Controls.Add(deleteButton); toolPanel.Controls.Add(type1Button); }
private void DeletedButton_Click(object sender, EventArgs e) { toolPanel.Visible = false; revivePanel.Visible = true; Button b = (Button)sender; Naudotojai u = (Naudotojai)b.Tag; ID = u.GetID().ToString(); Button reviveButton = new Button(); reviveButton.Text = "<<"; reviveButton.Width = 110; reviveButton.Height = 23; reviveButton.Tag = (Button)sender; reviveButton.Click += ReviveButton_Click; reviveButton.Location = new Point(0, 0); revivePanel.Controls.Add(reviveButton); }
public void ReadNaudotojai() { try { string connString = ConfigurationManager.ConnectionStrings["connect"].ConnectionString; SqlConnection conn = new SqlConnection(connString); conn.Open(); SqlCommand command = conn.CreateCommand(); command.CommandType = System.Data.CommandType.Text; command.CommandText = controller.Read(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { Naudotojai n = new Naudotojai(Convert.ToInt32(reader[0]), reader[1].ToString(), reader[2].ToString(), Convert.ToInt32(reader[3])); naud.Add(n); } conn.Close(); } catch (SqlException) { MessageBox.Show("Patikrinkite ar duomenų bazė yra pasiekiama!"); Application.Exit(); } }
private void LoginButton_Click(object sender, EventArgs e) { try { string connString = ConfigurationManager.ConnectionStrings["connect"].ConnectionString; SqlConnection conn = new SqlConnection(connString); SqlCommand command = conn.CreateCommand(); command.CommandType = CommandType.Text; conn.Open(); if (loginTextBox.Text == "" || pswTextBox.Text == "") { MessageBox.Show("Įveskite prisijungimo vardą ir slaptažodį!"); } else { command.CommandText = "select * from [Login] where username ='******'"; SqlDataReader reader = command.ExecuteReader(); int i = 0; while (reader.Read()) { naud = new Naudotojai(Convert.ToInt32(reader[0]), reader[1].ToString(), reader[2].ToString(), Convert.ToInt32(reader[3])); i++; } if (i == 0) { retries++; MessageBox.Show("Neteisingas prisijungimo vardas arba slaptažodis!"); loginTextBox.Text = ""; pswTextBox.Text = ""; loginTextBox.Select(); } else { usrn = naud.GetVardas(); if (naud.GetSlap().TrimEnd() == pswTextBox.Text) { this.Hide(); if (naud.GetTypeN() == 0) { f1 = new Form1(); f1.Show(); } else { f2 = new Form2(); f2.Show(); } } else { retries++; MessageBox.Show("Neteisingas prisijungimo vardas arba slaptažodis!"); loginTextBox.Text = ""; pswTextBox.Text = ""; loginTextBox.Select(); } } if (retries > 2) { Application.Exit(); } conn.Close(); } } catch (System.Data.SqlClient.SqlException) { System.Windows.Forms.MessageBox.Show("Patikrinkite ar duomenų bazė yra pasiekiama!"); System.Windows.Forms.Application.Exit(); } }