working
This commit is contained in:
2
Form1.Designer.cs
generated
2
Form1.Designer.cs
generated
@@ -147,6 +147,7 @@ namespace it_projekt
|
||||
// jsonRBtn
|
||||
//
|
||||
this.jsonRBtn.AutoSize = true;
|
||||
this.jsonRBtn.Checked = true;
|
||||
this.jsonRBtn.Location = new System.Drawing.Point(380, 54);
|
||||
this.jsonRBtn.Name = "jsonRBtn";
|
||||
this.jsonRBtn.Size = new System.Drawing.Size(53, 19);
|
||||
@@ -163,7 +164,6 @@ namespace it_projekt
|
||||
this.xmlRBtn.Name = "xmlRBtn";
|
||||
this.xmlRBtn.Size = new System.Drawing.Size(49, 19);
|
||||
this.xmlRBtn.TabIndex = 9;
|
||||
this.xmlRBtn.TabStop = true;
|
||||
this.xmlRBtn.Text = "XML";
|
||||
this.xmlRBtn.UseVisualStyleBackColor = true;
|
||||
this.xmlRBtn.CheckedChanged += new System.EventHandler(this.xmlRBtn_CheckedChanged);
|
||||
|
||||
46
Form1.cs
46
Form1.cs
@@ -20,7 +20,10 @@ namespace it_projekt
|
||||
|
||||
private void exportBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (jsonRBtn.Checked)
|
||||
exportJSON();
|
||||
else
|
||||
exportXML();
|
||||
}
|
||||
|
||||
private void loginBtn_Click(object sender, EventArgs e)
|
||||
@@ -82,6 +85,41 @@ namespace it_projekt
|
||||
}
|
||||
}
|
||||
|
||||
private void exportXML()
|
||||
{
|
||||
Stream myStream;
|
||||
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
|
||||
|
||||
saveFileDialog1.Filter = "All files (*.*)|*.*|xml files (*.xml)|*.xml";
|
||||
saveFileDialog1.FilterIndex = 2;
|
||||
saveFileDialog1.RestoreDirectory = true;
|
||||
saveFileDialog1.FileName = "benutzer.xml";
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
StreamWriter sw = new StreamWriter(myStream);
|
||||
var writer = new System.Xml.Serialization.XmlSerializer(typeof(List<Person>));
|
||||
writer.Serialize(sw, markedUsers);
|
||||
sw.Flush();
|
||||
sw.Close();
|
||||
myStream.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@@ -89,16 +127,12 @@ namespace it_projekt
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
Form1.resx
15
Form1.resx
@@ -72,19 +72,4 @@
|
||||
<metadata name="markItem.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="firstname.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="lastname.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="creationDate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="markItem.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -6,13 +6,17 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace it_projekt
|
||||
{
|
||||
class Person
|
||||
public class Person
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Lastname { get; set; }
|
||||
public string Firstname { get; set; }
|
||||
public DateTime CreationDate { get; set; }
|
||||
|
||||
public Person()
|
||||
{
|
||||
|
||||
}
|
||||
public Person(string Id, string Lastname, string Firstname, DateTime CreationDate)
|
||||
{
|
||||
this.Id = Id;
|
||||
|
||||
Reference in New Issue
Block a user