示例#1
0
        public static void Save(PersistData data)
        {
            var fileName = Path.Combine(Environment.GetFolderPath(
                                            Environment.SpecialFolder.ApplicationData), "SendSheetsViaMail.json");

            var jsonValue = JsonConvert.SerializeObject(data);

            File.WriteAllText(fileName, jsonValue);
        }
示例#2
0
        public static PersistData Load()
        {
            var fileName = Path.Combine(Environment.GetFolderPath(
                                            Environment.SpecialFolder.ApplicationData), "SendSheetsViaMail.json");

            if (File.Exists(fileName))
            {
                string      jsonValue        = File.ReadAllText(fileName);
                PersistData deserializedData = JsonConvert.DeserializeObject <PersistData>(jsonValue);

                return(deserializedData);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
        private void CSVInput_Load(object sender, EventArgs e)
        {
            PersistData data = PersistData.Load();

            if (data != null)
            {
                txtBody.Text    = data.MailBody;
                dt              = data.CSVConfig;
                txtSubject.Text = data.MailTitle;
            }
            else
            {
                dt.Clear();
                dt.Columns.AddRange(new DataColumn[] { new DataColumn("Department"),
                                                       new DataColumn("Slides"),
                                                       new DataColumn("E-Mails") });
            }
            BindingSource SBind = new BindingSource();

            SBind.DataSource = dt;
            grdData.Columns.Clear();
            grdData.DataSource = SBind;
        }
示例#4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     PersistData.Save(new PersistData {
         MailTitle = txtSubject.Text, MailBody = txtBody.Text, CSVConfig = dt
     });
 }