private void SetSalaryItemElement(SalaryItem salaryItem, TeacherSalary teacherSalary) { if (teacherSalary != null && teacherSalary.GetSalaryInItemElements() != null) { foreach (SalaryItemElement salaryItemElement in teacherSalary.GetSalaryInItemElements()) { if (salaryItem.salaryItemId.ToString() == salaryItemElement.salaryItemId) { SalaryItemElement element = new SalaryItemElement(); if (int.Parse(string.Format("{0:0}", salaryItemElement.times)) != 0) { element.times = salaryItemElement.times / salaryItemElement.MonthNum; element.times = CommonUtility.ConvertFormatedFloat("{0:F2}", element.times.ToString()); } if (salaryItemElement.salaryStandard != 0) { element.salaryStandard = salaryItemElement.salaryStandard; } else if (salaryItemElement.itemCost != 0) { element.salaryStandard = salaryItemElement.itemCost / salaryItemElement.MonthNum; element.salaryStandard = CommonUtility.ConvertFormatedFloat("{0:F2}", element.salaryStandard.ToString()); } salaryItem.salaryItemElement = element; break; } } } if (salaryItem.salaryItemElement == null) { SalaryItemElement element = new SalaryItemElement(); element.salaryStandard = 1; element.times = 1; } }
private void AddSalaryEntryDefault(TeacherSalary teacherSalary) { List<SalaryItemElement> teacherSalaryElements = teacherSalary.GetSalaryInItemElements(); int maxMonth = 1; foreach(SalaryItemElement teacherSalaryElement in teacherSalaryElements){ if (teacherSalaryElement.MonthNum > maxMonth) { maxMonth = teacherSalaryElement.MonthNum; } } List<string> salaryInValueListForMonth = new List<string>(); List<float> salaryWithTax = new List<float>(); List<float> salaryWithoutTax = new List<float>(); string salaryInValueStringForMonth; string singleSalaryItemValue; float salaryWithTaxForMonth; float salaryWithoutTaxForMonth; for (int i = 1; i <= maxMonth; i++) { salaryInValueStringForMonth = ""; salaryWithTaxForMonth = 0f; salaryWithoutTaxForMonth = 0f; foreach (SalaryItemElement teacherSalaryElement in teacherSalaryElements) { singleSalaryItemValue = ""; if (i <= teacherSalaryElement.MonthNum) { if (teacherSalaryElement.salaryStandard != 0) { singleSalaryItemValue = (teacherSalaryElement.salaryItemId + ":" + teacherSalaryElement.salaryStandard + "," + CommonUtility.ConvertFormatedFloat("{0:F2}", (teacherSalaryElement.times / teacherSalaryElement.MonthNum).ToString()) + ",1;"); } else { singleSalaryItemValue = (teacherSalaryElement.salaryItemId + ":" + CommonUtility.ConvertFormatedFloat("{0:F2}", (teacherSalaryElement.itemCost / teacherSalaryElement.MonthNum).ToString()) + ",1,1;"); if (teacherSalaryElement.hasTax) { salaryWithTaxForMonth += CommonUtility.ConvertFormatedFloat("{0:F2}", (teacherSalaryElement.itemCost / teacherSalaryElement.MonthNum).ToString()); } else { salaryWithoutTaxForMonth += CommonUtility.ConvertFormatedFloat("{0:F2}", (teacherSalaryElement.itemCost / teacherSalaryElement.MonthNum).ToString()); } } salaryInValueStringForMonth += singleSalaryItemValue; if (teacherSalaryElement.hasTax) { salaryWithTaxForMonth += (teacherSalaryElement.salaryStandard * teacherSalaryElement.times / teacherSalaryElement.MonthNum); }else{ salaryWithoutTaxForMonth += (teacherSalaryElement.salaryStandard * teacherSalaryElement.times / teacherSalaryElement.MonthNum); } } } if (!string.IsNullOrWhiteSpace(salaryInValueStringForMonth)) { salaryInValueStringForMonth = salaryInValueStringForMonth.Substring(0, salaryInValueStringForMonth.Length - 1); salaryInValueListForMonth.Add(salaryInValueStringForMonth); salaryWithTax.Add(salaryWithTaxForMonth); salaryWithoutTax.Add(salaryWithoutTaxForMonth); } } DalOperationAboutSalaryEntry dalse = new DalOperationAboutSalaryEntry(); SalaryEntry salaryEntry = new SalaryEntry(); salaryEntry.teacher = teacherSalary.teacher; salaryEntry.teacherType = teacherSalary.teacherType; salaryEntry.course = teacherSalary.course; salaryEntry.atCourseType = "" + teacherSalary.atCourseType; salaryEntry.termTag = teacherSalary.termTag; salaryEntry.salaryEntryStatus = 1; salaryEntry.memo = "本列表中的税后所得仅为假定你在苏州研究院的所有收入只有此项而计算(因为是兼职,财务默认您的基础收入已经为3500元),仅供参考!实际税后金额,以财务发放为准,有问题可以及时联系教学管理部(0512-68839206)或者财务(0512-87161163)"; DateTime monthDateTime = DateTime.Now; for (int i = 0; i < salaryInValueListForMonth.Count; i++) { salaryEntry.SetSalaryInItemValueList(salaryInValueListForMonth[i], false); salaryEntry.teacherCostWithTax = CommonUtility.ConvertFormatedFloat("{0:F2}", salaryWithTax[i].ToString()); salaryEntry.teacherCostWithoutTax = CommonUtility.ConvertFormatedFloat("{0:F2}", salaryWithoutTax[i].ToString()); salaryEntry.teacherTotalCost = CommonUtility.ConvertFormatedFloat("{0:F2}", ((salaryEntry.teacherCostWithTax - float.Parse(CommonUtility.CalculateTax(decimal.Parse(salaryEntry.teacherCostWithTax.ToString())).ToString())) + salaryEntry.teacherCostWithoutTax).ToString()); int monthValue = monthDateTime.Month; salaryEntry.salaryMonth = (monthDateTime.Year + "-" + (monthValue < 10 ? "0" + monthValue.ToString() : monthValue.ToString())); dalse.AddSalaryEntry(salaryEntry); monthDateTime = monthDateTime.AddMonths(1); } }