Esempio n. 1
0
        private void buttonSaveResult_Click(object sender, EventArgs e)
        {
            try
            {
                this.Enabled = false;

                List <Salary> salaries = new List <Salary>();

                foreach (ListViewItem item in listView1.Items)
                {
                    salaries.Add((Salary)item.Tag);
                }
                string file = BuildSalariesFileName((int)numericUpDownTargetYear.Value, (int)numericUpDownTargetMonth.Value);
                DataCenter.Instance.SaveSalaries(file, salaries);
                QMessageBox.ShowInfomation(String.Format("数据已保存至{0}", file));
            }
            catch (System.Exception ex)
            {
                QMessageBox.ShowError(ex.ToString());
            }
            finally
            {
                this.Enabled = true;
            }
        }
Esempio n. 2
0
        private void SendMail(ArrayList items)
        {
            Email         email   = new Email();
            StringBuilder sb      = new StringBuilder();
            String        subject = String.Format("{0}年{1}月工资单", (int)numericUpDownTargetYear.Value, (int)numericUpDownTargetMonth.Value);
            int           i       = 1;

            foreach (ListViewItem item in items)
            {
                string receipt = item.SubItems[(int)Field.Receipt].Text;

                if (!string.IsNullOrEmpty(receipt))
                {
                    Salary   s            = (Salary)item.Tag;
                    CalcArg  args         = s.m_args;
                    Employee emp          = s.m_employee;
                    string   emailAddress = emp.m_email;
                    if (!string.IsNullOrEmpty(emailAddress))
                    {
                        labelProgress.Text = string.Format("正在发送{0}/{1}...", i, items.Count);
                        this.Refresh();
                        email.SendMail(emailAddress, subject, receipt);
                        sb.AppendLine(emailAddress);
                        ++i;
                    }
                }
            }
            QMessageBox.ShowInfomation("已发送邮件到下列账号:\n" + sb.ToString());
        }