private void typeButton_Click(object sender, RoutedEventArgs e) { GetStartedAsAdmin getStarted = Window.GetWindow(this) as GetStartedAsAdmin; getStarted.scrollViewer.Width = 900; /* getStarted.button1.Visibility = Visibility.Visible;*/ getStarted.itemPanel.Children.Clear(); getStarted.PopulateWithUsers(Convert.ToString(typeLabel.Content)); }
private void Delete_User_Click(object sender, RoutedEventArgs e) { GetStartedAsAdmin getStarted = Window.GetWindow(this) as GetStartedAsAdmin; PersonInf.Status = lblStatus.Text; person.PersonNameInfo(); if (PersonInf.Status == "Pacientas") { string selected = String.Format(lblName.Text + " " + lblSurname.Text + " ----- Deleted from DataBase!"); string conn = "C:\\Users\\s034240\\Desktop\\DB BRowser\\SQLiteDatabaseBrowserPortable\\Data\\Ligonine.db"; SQLiteConnection dbConection = new SQLiteConnection("Data Source=" + conn); dbConection.Open(); string sqldelete = $"delete from tbl_Pacientas where name=@name"; SQLiteCommand command = new SQLiteCommand(sqldelete, dbConection); command.Parameters.AddWithValue("@name", lblName.Text); command.ExecuteNonQuery(); dbConection.Close(); MessageBox.Show("Deleted! "); } else if (PersonInf.Status == "Gydytojas") { string selected = String.Format(lblName.Text + " " + lblSurname.Text + " ----- Deleted from DataBase!"); string conn = "C:\\Users\\s034240\\Desktop\\DB BRowser\\SQLiteDatabaseBrowserPortable\\Data\\Ligonine.db"; SQLiteConnection dbConection = new SQLiteConnection("Data Source=" + conn); dbConection.Open(); string sqldelete = $"delete from tbl_Gydytojas where name=@name"; SQLiteCommand command = new SQLiteCommand(sqldelete, dbConection); command.Parameters.AddWithValue("@name", lblName.Text); command.ExecuteNonQuery(); dbConection.Close(); MessageBox.Show("Deleted! "); } else { MessageBox.Show("Jus Jau Pasalinuote Sita Useri "); } }
//////////////////////////////////////////////////////////////////////// ////////////////////LOGIN//////////////////////////////////////////// ////////////////////////////////////////////////////////////////// private void Button_Click(object sender, RoutedEventArgs e) { string uName = TxtName.Text; string uPassword = TxtPass.Text; string uGeneral = uName + "," + uPassword; ////////////////////LOGIN AND PASS TIKRINIMAS//////////////////////////////////////////// string conn = "C:\\Users\\s034240\\Desktop\\DB BRowser\\SQLiteDatabaseBrowserPortable\\Data\\Ligonine.db"; SQLiteConnection dbConection = new SQLiteConnection("Data Source=" + conn); string sqlGydytojas = "select * from tbl_Gydytojas;"; string sqlPacientas = "select * from tbl_Pacientas;"; SQLiteCommand commandGydytojas = new SQLiteCommand(sqlGydytojas, dbConection); SQLiteCommand commandPacientas = new SQLiteCommand(sqlPacientas, dbConection); dbConection.Open(); // SQLiteDataReader reader = command.ExecuteReader(); // while (reader.Read()) { } if (TxtName.Text == "") { MessageBox.Show("Please enter user name", "Error", MessageBoxButton.OK, MessageBoxImage.Error); TxtName.Focus(); return; } if (TxtPass.Text == "") { MessageBox.Show("Please enter Password", "Error", MessageBoxButton.OK, MessageBoxImage.Error); TxtName.Focus(); return; } try { person.PersonLoginInfo(); if (person.PersonLogin.Contains(uGeneral)) { SQLiteDataReader readerGydytojas = commandGydytojas.ExecuteReader(); SQLiteDataReader readerPacientas = commandPacientas.ExecuteReader(); while (readerGydytojas.Read()) { PersonData.Name = Convert.ToString(readerGydytojas[2]); if (uName == PersonData.Name) { PersonData.User_Status = Convert.ToString(readerGydytojas[9]); PersonData.Status = Convert.ToString(readerGydytojas[1]); if (PersonData.User_Status == "Admin") { MessageBox.Show("WELCOME Admin: " + TxtName.Text + "!"); this.Hide(); GetStartedAsAdmin LogedInAdmin = new GetStartedAsAdmin(); LogedInAdmin.Show(); } else if (PersonData.Status == "Gydytojas") { MessageBox.Show("WELCOME Gydytaju: " + TxtName.Text + "!"); this.Hide(); GetStartedAsGydytojas LogedInUserDoc = new GetStartedAsGydytojas(); LogedInUserDoc.Show(); } /* if (PersonData.Status == "Pacientas") * { * MessageBox.Show("WELCOME Pacientas: " + TxtName.Text + "!"); * this.Hide(); * GetStartedAsPacientas LogedInUserPac = new GetStartedAsPacientas(TxtName.Text); * LogedInUserPac.Show(); * * } */ } } while (readerPacientas.Read()) { PersonData.Name = Convert.ToString(readerPacientas[2]); if (uName == PersonData.Name) { PersonData.User_Status = Convert.ToString(readerPacientas[9]); PersonData.Status = Convert.ToString(readerPacientas[1]); if (PersonData.User_Status == "Admin") { MessageBox.Show("WELCOME Admin: " + TxtName.Text + "!"); this.Hide(); GetStartedAsAdmin LogedInAdmin = new GetStartedAsAdmin(); LogedInAdmin.Show(); } if (PersonData.Status == "Pacientas") { MessageBox.Show("WELCOME Pacientas: " + TxtName.Text + "!"); this.Hide(); GetStartedAsPacientas LogedInUserPac = new GetStartedAsPacientas(TxtName.Text); LogedInUserPac.Show(); } } } dbConection.Close(); } else { MessageBox.Show("Login Failed.. Try again !", "Login Denied", MessageBoxButton.OK, MessageBoxImage.Error); } } catch (Exception ex) { MessageBox.Show(Convert.ToString(ex.LineNumber()) + " Line Eror ", "Login Denied", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Button_Click_2(object sender, RoutedEventArgs e) { GetStartedAsAdmin getStarted = Window.GetWindow(this) as GetStartedAsAdmin; PersonInf.Status = lblStatus.Text; person.PersonNameInfo(); if (PersonInf.Status == "Pacientas") { string selected = String.Format(lblName.Text + " " + lblSurname.Text + " ----- Deleted from DataBase!"); string conn = "C:\\Users\\s034240\\Desktop\\DB BRowser\\SQLiteDatabaseBrowserPortable\\Data\\Ligonine.db"; SQLiteConnection dbConection = new SQLiteConnection("Data Source=" + conn); dbConection.Open(); string sqldeletePac = $"delete from tbl_Pacientas where name=@name"; string sqldeleteReg = $"delete from tbl_Registration where Pacientas_ID=@Pacientas_ID"; string sqlPacientas = "select * from tbl_Pacientas;"; SQLiteCommand commandPacientas = new SQLiteCommand(sqlPacientas, dbConection); SQLiteDataReader readerPacientas = commandPacientas.ExecuteReader(); while (readerPacientas.Read()) { if (lblName.Text == Convert.ToString(readerPacientas[2])) { RegistrationInf.PacientoID = Convert.ToString(readerPacientas[0]); } } SQLiteCommand commandPac = new SQLiteCommand(sqldeletePac, dbConection); SQLiteCommand commandReg = new SQLiteCommand(sqldeleteReg, dbConection); commandPac.Parameters.AddWithValue("@name", lblName.Text); commandReg.Parameters.AddWithValue("@Pacientas_ID", RegistrationInf.PacientoID); commandPac.ExecuteNonQuery(); commandReg.ExecuteNonQuery(); dbConection.Close(); MessageBox.Show("Deleted! "); } else if (PersonInf.Status == "Gydytojas") { string selected = String.Format(lblName.Text + " " + lblSurname.Text + " ----- Deleted from DataBase!"); string conn = "C:\\Users\\s034240\\Desktop\\DB BRowser\\SQLiteDatabaseBrowserPortable\\Data\\Ligonine.db"; SQLiteConnection dbConection = new SQLiteConnection("Data Source=" + conn); dbConection.Open(); string sqldelete = $"delete from tbl_Gydytojas where name=@name"; string sqldeleteReg = $"delete from tbl_Registration where Gydytojas_ID=@Gydytojas_ID"; string sqlGydytojas = "select * from tbl_Gydytojas;"; SQLiteCommand commandGydytojas = new SQLiteCommand(sqlGydytojas, dbConection); SQLiteDataReader readerGydytojas = commandGydytojas.ExecuteReader(); while (readerGydytojas.Read()) { if (lblName.Text == Convert.ToString(readerGydytojas[2])) { RegistrationInf.GydytojoID = Convert.ToString(readerGydytojas[0]); } } SQLiteCommand commandGyd = new SQLiteCommand(sqldelete, dbConection); SQLiteCommand commandReg = new SQLiteCommand(sqldeleteReg, dbConection); commandGyd.Parameters.AddWithValue("@name", lblName.Text); commandReg.Parameters.AddWithValue("@Pacientas_ID", Convert.ToString(person.ID)); commandGyd.ExecuteNonQuery(); commandReg.ExecuteNonQuery(); dbConection.Close(); MessageBox.Show("Deleted! "); } else { MessageBox.Show("Jus Jau Pasalinuote Sita Useri "); } }