Ejemplo n.º 1
0
        public Dictionary <string, CalcArg> LoadCalcArgs(string file)
        {
            Dictionary <string, CalcArg> calcArgs = new Dictionary <string, CalcArg>();

            if (String.IsNullOrEmpty(file))
            {
                return(calcArgs);
            }
            else if (!File.Exists(file))
            {
                return(calcArgs);
            }

            using (StreamReader reader = File.OpenText(file))
            {
                string line = string.Empty;
                while (!string.IsNullOrEmpty((line = reader.ReadLine())))
                {
                    CalcArg arg = new CalcArg();
                    arg.FromString(line);
                    if (!string.IsNullOrEmpty(arg.m_employeeId))
                    {
                        calcArgs.Add(arg.m_employeeId, arg);
                    }
                }
            }

            return(calcArgs);
        }
Ejemplo 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());
        }
Ejemplo n.º 3
0
 private void numericUpDownOtherCut_ValueChanged(object sender, EventArgs e)
 {
     if (m_currentListViewItem != null)
     {
         Salary  s    = (Salary)m_currentListViewItem.Tag;
         CalcArg args = s.m_args;
         args.m_otherCut = numericUpDownOtherCut.Value;
         m_currentListViewItem.SubItems[(int)Field.OtherCut].Text = args.m_otherCut.ToString("0.00");
     }
 }
Ejemplo n.º 4
0
 private void numericUpDownLate_ValueChanged(object sender, EventArgs e)
 {
     if (m_currentListViewItem != null)
     {
         Salary  s    = (Salary)m_currentListViewItem.Tag;
         CalcArg args = s.m_args;
         args.m_late = (int)numericUpDownLate.Value;
         m_currentListViewItem.SubItems[(int)Field.Late].Text = args.m_late.ToString();
     }
 }
Ejemplo n.º 5
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            //加载计薪参数
            DateTime targetMonth = GetTargetMonth();
            string   file        = BuildCalcArgsFileName(targetMonth.Year, targetMonth.Month);
            Dictionary <string, CalcArg> calcArgs = DataCenter.Instance.LoadCalcArgs(file);

            if (calcArgs.Count == 0)
            {
                //准备好上个月的数据
                DateTime lastMonth       = targetMonth.AddMonths(-1);
                string   fileOfLastMonth = BuildSalariesFileName(lastMonth.Year, lastMonth.Month);
                Dictionary <string, Salary> salariesOfLastMonth = DataCenter.Instance.LoadSalaries(fileOfLastMonth);//可能没查到, 空列表

                foreach (Salary s in salariesOfLastMonth.Values)
                {
                    CalcArg c = new CalcArg();
                    c.m_employeeId     = s.m_args.m_employeeId;
                    c.m_previousTaxCut = s.m_taxToCut;
                    calcArgs.Add(s.m_args.m_employeeId, c);
                }
            }

            foreach (Employee employee in DataCenter.Instance.Employees.Values)
            {
                Salary s = new Salary();
                s.m_employee = employee;

                if (calcArgs.ContainsKey(employee.m_id))
                {
                    s.m_args = calcArgs[employee.m_id];
                }
                else
                {
                    s.m_args = new CalcArg();
                    s.m_args.m_employeeId = s.m_employee.m_id;
                }

                ListViewItem item = new ListViewItem(BuildInfo(s));
                item.Tag = s;
                listView1.Items.Add(item);
            }

            if (listView1.Items.Count > 0)
            {
                m_currentListViewItem = listView1.Items[0];
            }
        }
Ejemplo n.º 6
0
 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());
     }
 }
Ejemplo n.º 7
0
        private void MainForm_Load(object sender, EventArgs e)
        {          
            //加载计薪参数
            DateTime targetMonth = GetTargetMonth();
            string file = BuildCalcArgsFileName(targetMonth.Year, targetMonth.Month);
            Dictionary<string, CalcArg> calcArgs = DataCenter.Instance.LoadCalcArgs(file);

            if (calcArgs.Count == 0)
            {
                //准备好上个月的数据
                DateTime lastMonth = targetMonth.AddMonths(-1);
                string fileOfLastMonth = BuildSalariesFileName(lastMonth.Year, lastMonth.Month);
                Dictionary<string, Salary> salariesOfLastMonth = DataCenter.Instance.LoadSalaries(fileOfLastMonth);//可能没查到, 空列表

                foreach (Salary s in salariesOfLastMonth.Values)
                {
                    CalcArg c = new CalcArg();
                    c.m_employeeId = s.m_args.m_employeeId;
                    c.m_previousTaxCut = s.m_taxToCut;
                    calcArgs.Add(s.m_args.m_employeeId, c);
                }
            }

            foreach (Employee employee in DataCenter.Instance.Employees.Values)
            {
                Salary s = new Salary();
                s.m_employee = employee;

                if (calcArgs.ContainsKey(employee.m_id))
                {
                    s.m_args = calcArgs[employee.m_id];
                }
                else
                {
                    s.m_args = new CalcArg();
                    s.m_args.m_employeeId = s.m_employee.m_id;
                }

                ListViewItem item = new ListViewItem(BuildInfo(s));
                item.Tag = s;
                listView1.Items.Add(item);
            }

            if (listView1.Items.Count > 0)
            {
                m_currentListViewItem = listView1.Items[0];
            }
        }
Ejemplo n.º 8
0
        public Dictionary<string, CalcArg> LoadCalcArgs(string file)
        {
            Dictionary<string, CalcArg> calcArgs = new Dictionary<string, CalcArg>();

            if (String.IsNullOrEmpty(file))
            {
                return calcArgs;
            }
            else if (!File.Exists(file))
            {
                return calcArgs;
            }

            using (StreamReader reader = File.OpenText(file))
            {
                string line = string.Empty;
                while (!string.IsNullOrEmpty((line = reader.ReadLine())))
                {
                    CalcArg arg = new CalcArg();
                    arg.FromString(line);
                    if (!string.IsNullOrEmpty(arg.m_employeeId))
                    {
                        calcArgs.Add(arg.m_employeeId, arg);
                    }
                }
            }

            return calcArgs;
        }