Пример #1
0
 private int GetWorkdayCount()
 {
     return(Salary.GetWorkdayCount(GetTargetMonth()));
 }
Пример #2
0
 private String[] BuildInfo(Salary s)
 {
     string[] infos = new string[8];
     infos[(int)Field.Name] = s.m_employee.m_name;
     infos[(int)Field.Allowance] = s.m_args.m_allowance.ToString("0.00");
     infos[(int)Field.Late] = s.m_args.m_late.ToString();
     infos[(int)Field.Absent] = s.m_args.m_absent.ToString("0.00");
     infos[(int)Field.PreviousTaxCut] = s.m_args.m_previousTaxCut.ToString("0.00");
     infos[(int)Field.OtherCut] = s.m_args.m_otherCut.ToString("0.00");
     infos[(int)Field.Receipt] = s.ToString();
     return infos;
 }
Пример #3
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];
            }
        }
Пример #4
0
        //目前只需要加载个税数据
        public Dictionary<string, Salary> LoadSalaries(String file)
        {
            Dictionary<string, Salary> salaries = new Dictionary<string, Salary>();

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

            using (StreamReader reader = File.OpenText(file))
            {
                string line = string.Empty;
                while (!string.IsNullOrEmpty((line = reader.ReadLine())))
                {
                    string[] data = line.Split(',');
                    if (data != null && data.Length >=2)
                    {
                        Salary s = new Salary();

                        s.m_employee.m_id = data[0];
                        s.m_args.m_employeeId = data[0];
                        
                        decimal.TryParse(data[13], out s.m_taxToCut);//tax to cut

                        salaries.Add(s.m_employee.m_id, s);
                    }
                }
            }

            return salaries;
        }