Esempio n. 1
0
        public void Send()
        {
            List <OneDayData> Rows = db.GetTable(dtMain.Value.Year, dtMain.Value.Month);

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            Rows.ForEach((i) => {
                i.family  = Tabel_client.Properties.Settings.Default.family;
                i.name    = Tabel_client.Properties.Settings.Default.name; i.parentName = Tabel_client.Properties.Settings.Default.parentName;
                i.subject = subject; i.message = message; i.mail = this.mail; i.tabelNumber = Tabel_client.Properties.Settings.Default.TabelNumber; i.daynumber = i.daynumber.ToUniversalTime(); i.startday = i.startday.ToUniversalTime(); i.endday = i.endday.ToUniversalTime();
            });
            string json = serializer.Serialize(Rows);

            //StreamWriter sw = new StreamWriter(new FileStream(Application.StartupPath + "\\Табель от " + Tabel_client.Properties.Settings.Default.FIO + " табельный №" + Tabel_client.Properties.Settings.Default.TabelNumber + " за " + DateTime.Now.ToString("MMM") + " " + DateTime.Now.Year + " года" + ".json", FileMode.Create, FileAccess.Write));
            //sw.Write(json);
            File.WriteAllText(Application.StartupPath + "\\Табель от " + Tabel_client.Properties.Settings.Default.family + " табельный №" + Tabel_client.Properties.Settings.Default.TabelNumber + " за " + dtMain.Value.ToString("MMMM yyyy") + ".tt", json);
            //sw.Close();
            SendForm Send = new SendForm();
            Settings s    = new Settings(new TabelLibrary.Crypto.Xor());

            s.Open();

            SendMail mail = new SendMail();

            if (mail.Send(new MailSet(s.saveParam.ToString(), Application.StartupPath + "\\Табель от " + Tabel_client.Properties.Settings.Default.family + " табельный №" + Tabel_client.Properties.Settings.Default.TabelNumber + " за " + dtMain.Value.ToString("MMMM yyyy") + ".tt")))
            {
                MessageBox.Show("Табель отправлен");
                this.Close();
            }
            else
            {
                MessageBox.Show(mail.Error);
            }
        }
Esempio n. 2
0
        private void btSend_Click(object sender, EventArgs e)
        {
            List <OneDayData> Rows = db.GetTable(dtMain.Value.Year, dtMain.Value.Month);

            JavaScriptSerializer serializer = new JavaScriptSerializer();

            Rows.ForEach((i) => {
                i.family  = Tabel_client.Properties.Settings.Default.family;
                i.name    = Tabel_client.Properties.Settings.Default.name; i.parentName = Tabel_client.Properties.Settings.Default.parentName;
                i.subject = subject; i.message = message; i.mail = mail; i.tabelNumber = Tabel_client.Properties.Settings.Default.TabelNumber; i.daynumber = i.daynumber.ToUniversalTime(); i.startday = i.startday.ToUniversalTime(); i.endday = i.endday.ToUniversalTime();
            });
            string       json = serializer.Serialize(Rows);
            StreamWriter sw   = new StreamWriter(new FileStream(Application.StartupPath + "\\Табель от " + Tabel_client.Properties.Settings.Default.family + " табельный №" + Tabel_client.Properties.Settings.Default.TabelNumber + " За " + DateTime.Now.ToString("MMM") + ".json", FileMode.Create, FileAccess.Write));

            sw.Write(json);
            sw.Close();
            SendForm Send = new SendForm();

            Send.ShowDialog();
        }