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; } }
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()); }
private void buttonSendMail_Click(object sender, EventArgs e) { try { this.Enabled = false; labelProgress.Visible = true; StringBuilder sb = new StringBuilder(); ArrayList c = new ArrayList(); if (checkBoxSelectedOnly.Checked) { c.Add(m_currentListViewItem); } else { c.AddRange(listView1.Items); } SendMail(c); } catch (System.Exception ex) { QMessageBox.ShowError(ex.ToString()); } finally { this.Enabled = true; labelProgress.Visible = false; } }
//每次退出的时候, 保存已经输入的数据 private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { SaveCalcArgs(); } catch (System.Exception ex) { QMessageBox.ShowError(ex.ToString()); } }
//当目标月份改变时, 一是要计算出这个月的工作天数, 另外要加载对应的工资数据, 没有数据就创建数据 private void UpdateWorkdayCount() { try { numericUpDownWorkDayCount.Value = (decimal)GetWorkdayCount(); } catch (System.Exception ex) { QMessageBox.ShowError(ex.ToString()); } }
private void buttonCalcTax_Click(object sender, EventArgs e) { try { decimal start = numericUpDownTaxStartPoint.Value; decimal amount = numericUpDownTaxAmount.Value; numericUpDownTax.Value = IndividualIncomeTax.GetTax(start, amount); } catch (System.Exception ex) { QMessageBox.ShowError(ex.ToString()); } }
private void OnSelectedEmployeeChanged() { try { if (listView1.SelectedItems.Count > 0) { m_currentListViewItem = listView1.SelectedItems[0]; Salary s = (Salary)m_currentListViewItem.Tag; CalcArg args = s.m_args; numericUpDownAllowance.Value = args.m_allowance; numericUpDownLate.Value = args.m_late; numericUpDownAbsent.Value = (decimal)args.m_absent; numericUpDownPreviousTaxCut.Value = args.m_previousTaxCut; numericUpDownOtherCut.Value = args.m_otherCut; richTextBoxReceipt.Text = m_currentListViewItem.SubItems[(int)Field.Receipt].Text; } } catch (System.Exception ex) { QMessageBox.ShowError(ex.ToString()); } }
private void buttonCalcSalary_Click(object sender, EventArgs e) { try { this.Enabled = false; int workdayCount = (int)numericUpDownWorkDayCount.Value; if (checkBoxSelectedOnly.Checked) { CalcSalary(m_currentListViewItem, workdayCount); } else { foreach (ListViewItem item in listView1.Items) { CalcSalary(item, workdayCount); } } UpdateTotalInfo(); OnSelectedEmployeeChanged(); buttonSaveResult.Enabled = true; buttonSendMail.Enabled = true; buttonExport.Enabled = true; } catch (System.Exception ex) { QMessageBox.ShowError(ex.ToString()); } finally { this.Enabled = true; } }