merged
This commit is contained in:
166
Form1.cs
166
Form1.cs
@@ -1,62 +1,104 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace it_projekt
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private void searchBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach(DataGridViewRow row in dataGrid.Rows)
|
||||
{
|
||||
List<int> markedUsers = new List<int>();
|
||||
if (row.Cells[4].Value != null)
|
||||
{
|
||||
if (row.Cells[4].Value.ToString() == "True")
|
||||
{
|
||||
MessageBox.Show("geht");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void loginBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadUsersFromTable(userTxt.Text,passTxt.Text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void LoadUsersFromTable(string user, string password)
|
||||
{
|
||||
Database db = new Database(user, password);
|
||||
foreach (Person person in db.Persons)
|
||||
{
|
||||
this.dataGrid.Rows.Add(person.Id, person.Firstname, person.Lastname, person.CreationDate, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace it_projekt
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
|
||||
private Database db = null;
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private void exportBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
exportJSON();
|
||||
}
|
||||
|
||||
private void loginBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadUsersFromTable(this.userTxt.Text, this.passTxt.Text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void LoadUsersFromTable(string user, string password)
|
||||
{
|
||||
if (db == null)
|
||||
{
|
||||
db = new Database(user, password);
|
||||
}
|
||||
foreach (Person person in db.Persons)
|
||||
{
|
||||
this.dataGrid.Rows.Add(person.Id, person.Firstname, person.Lastname, person.CreationDate, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void dataGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void exportJSON()
|
||||
{
|
||||
Stream myStream;
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
||||
|
||||
saveFileDialog1.Filter = "All files (*.*)|*.*|json files (*.json)|*.json";
|
||||
saveFileDialog1.FilterIndex = 2;
|
||||
saveFileDialog1.RestoreDirectory = true;
|
||||
saveFileDialog1.FileName = "benutzer.json";
|
||||
|
||||
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if ((myStream = saveFileDialog1.OpenFile()) != null)
|
||||
{
|
||||
List<Person> markedUsers = new List<Person>();
|
||||
foreach (DataGridViewRow row in dataGrid.Rows)
|
||||
{
|
||||
if (row.Cells[4].Value != null)
|
||||
{
|
||||
if (row.Cells[4].Value.ToString() == "True")
|
||||
{
|
||||
markedUsers.Add(db.Persons.Find(person => person.Id == row.Cells[0].Value.ToString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
string json = JsonSerializer.Serialize(markedUsers);
|
||||
StreamWriter sw = new StreamWriter(myStream);
|
||||
sw.Write(json);
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
myStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void jsonRBtn_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
xmlRBtn.Checked = false;
|
||||
if (!jsonRBtn.Checked)
|
||||
jsonRBtn.Checked = true;
|
||||
}
|
||||
|
||||
private void xmlRBtn_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
xmlRBtn.Checked = false;
|
||||
if (!xmlRBtn.Checked)
|
||||
xmlRBtn.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user