Esempio n. 1
0
        private void btnJSerialize_Click(object sender, EventArgs e) //JSON
        {
            Employee emp = new Employee();

            emp.preluare_date(txtName.Text, txtPhoneNo.Text, dtpDoB.Value, txtDepartment.Text, Int32.Parse(txtSalary.Text));

            File.WriteAllText("JSON.txt", JsonConvert.SerializeObject(emp));

            golire_controale();
        }
Esempio n. 2
0
        private void XmlSerialize_Click(object sender, EventArgs e) //XML
        {
            Employee emp = new Employee();

            emp.preluare_date(txtName.Text, txtPhoneNo.Text, dtpDoB.Value, txtDepartment.Text, Int32.Parse(txtSalary.Text));

            XmlSerializer bf = new XmlSerializer(typeof(Employee));
            FileStream    fs = new FileStream("serialized.xml", FileMode.Create, FileAccess.ReadWrite);

            try
            {
                using (fs)
                {
                    bf.Serialize(fs, emp);
                    lblStatus.Text = "Serialized";
                    golire_controale();
                }
            }
            catch
            {
                lblStatus.Text = "Error while serializing";
            }
        }