private double getAllSubsSumRate(int id, DateTime dateEnd)
        {
            double result = STSysTechEmployeesData.GetEmployeeById(id).GetRate(dateEnd);

            foreach (STSysTechEmployee emp in STSysTechEmployeesData.GetChildren(id))
            {
                result += getAllSubsSumRate(emp.ID, dateEnd);
            }
            return(result);
        }
Example #2
0
        public override double GetRate(DateTime dateEnd)
        {
            double max_percent    = 0.4;
            double stazh_premia   = 0.05 * YearsOfWorking(dateEnd);
            double current_premia = (stazh_premia > max_percent ? max_percent:stazh_premia) * BaseRate;

            double result = this.BaseRate + current_premia;

            foreach (STSysTechEmployee emp in STSysTechEmployeesData.GetChildren(this.ID))
            {
                result += emp.GetRate(dateEnd) * 0.005;
            }

            return(result);
        }
        private void RefreshData()
        {
            STSysTechEmployeesData.AllEmployees.Clear();
            DataTable dt = STDemoSqlData.GetDataFromDataBase();


            List <STSysTechEmployee> employees = (from d in dt.AsEnumerable()
                                                  where (d.Field <Int64>("group") == 1)
                                                  select new STEmployee()
            {
                ID = Convert.ToInt32(d["id"]),
                Name = d["name"].ToString(),
                Group = Convert.ToInt32(d["group"]),
                BaseRate = Convert.ToDouble(d["baserate"]),
                DateStart = Convert.ToDateTime(d["datestart"]),
                ParentId = ConvertNullableInt(d["parent_id"])
            }).ToList <STSysTechEmployee>();

            STSysTechEmployeesData.AddEmployees(employees);

            List <STSysTechEmployee> managers = (from d in dt.AsEnumerable()
                                                 where (d.Field <Int64>("group") == 2)
                                                 select new STManager()
            {
                ID = Convert.ToInt32(d["id"]),
                Name = d["name"].ToString(),
                Group = Convert.ToInt32(d["group"]),
                BaseRate = Convert.ToDouble(d["baserate"]),
                DateStart = Convert.ToDateTime(d["datestart"]),
                ParentId = ConvertNullableInt(d["parent_id"])
            }).ToList <STSysTechEmployee>();

            STSysTechEmployeesData.AddEmployees(managers);

            List <STSysTechEmployee> salesmans = (from d in dt.AsEnumerable()
                                                  where (d.Field <Int64>("group") == 3)
                                                  select new STSalesMan()
            {
                ID = Convert.ToInt32(d["id"]),
                Name = d["name"].ToString(),
                Group = Convert.ToInt32(d["group"]),
                BaseRate = Convert.ToDouble(d["baserate"]),
                DateStart = Convert.ToDateTime(d["datestart"]),
                ParentId = ConvertNullableInt(d["parent_id"])
            }).ToList <STSysTechEmployee>();

            STSysTechEmployeesData.AddEmployees(salesmans);
        }