private void btnDelete_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are you sure?", "Warning", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { SalaryBLL.DeleteSalary(detail.SalaryID); MessageBox.Show("Salary was deleted!"); FillAllData(); ClearFilters(); } }
/// <summary> /// 工资管理模块 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SalaryButton_Click(object sender, RoutedEventArgs e) { stateflag = 3; RemoveFieldColumns(); pagename.Content = "工资管理"; DataGridTextColumn dgtxtCol; string[] fields = { "id", "基本工资", "最终工资", "Id", "Pre_sal", "Current_sal" }; for (int i = 0; i < 3; i++) { dgtxtCol = new DataGridTextColumn(); dgtxtCol.Header = fields[i]; dgtxtCol.Binding = new Binding(fields[i + 3]); UserGrid.Columns.Insert(1 + i, dgtxtCol); } //List<Salary> salarys = new List<Salary>(); salaryList.Clear(); Salary salary = new Salary(); SalaryBLL salaryBLL = new SalaryBLL(); List <Salary> salary1 = salaryBLL.GetAllSalary(); int id = 0; foreach (Salary item in salary1) { id = item.Id; salary = salaryBLL.GetsalaryByID(id); RP rP = new RP(); RPBLL rpBll = new RPBLL(); List <RP> rps = rpBll.GetRPsByUserId(id); int sum = 0; if (rps != null) { foreach (RP item1 in rps) { sum += item1.Sal; } salary.Current_sal = salary.Pre_sal + sum; salaryBLL.Modifysalary(salary); } Salary salary2 = new Salary(); salary2 = salaryBLL.GetsalaryByID(id); if (salary2 != null) { salaryList.Add(salary2); } } UserGrid.ItemsSource = salaryList; sum = salaryList.Count; //sum是记录总数 SalaryBinding(maxnum, 1); }
/// <summary> /// 列表展示薪酬标准,再由独立控制器处理薪酬标准的具体操作 /// </summary> /// <returns>返回薪酬标准的列表视图</returns> public ActionResult SalaryStandardManage() { //装载所有的薪酬标准 //薪酬管理业务层 ISalaryBLL bLL = new SalaryBLL(); //薪酬项目管理业务层,因为薪酬标准管理和薪酬项目管理是不同模块的 ISalaryItemBLL salaryItemBLL = new SalaryItemBLL(); //获取所有的薪酬标准,这时的薪酬标准是Model中的类型 List <SalaryStandard> standardList = bLL.GetAllSalaryStandard(); List <Models.SalaryStandard> standardListView = new List <Models.SalaryStandard>(); //遍历所有薪酬标准,将其转换成视图模型中的薪酬标准 foreach (var s in standardList) { //通过薪酬标准的id获取所有的映射关系 List <StandardMapItem> tempMapList = bLL.GetAllStandardMapItemByStandardId(s.Id); Models.SalaryStandard tempStandard = new Models.SalaryStandard() { Id = s.Id, StandardName = s.StandardName, StandardFileNumber = s.StandardFileNumber, Registrant = s.Registrant, RegistTime = s.RegistTime, DesignBy = s.DesignBy, Total = s.Total, StandardState = s.StandardState, CheckDesc = s.CheckDesc, CheckBy = s.CheckBy }; //遍历映射关系,分拆装载进视图模型薪酬标准中的字典 foreach (var m in tempMapList) { SalaryItem tempSalaryItem = salaryItemBLL.GetSalaryItemById(m.ItemId); Models.SalaryItem salaryItemView = new Models.SalaryItem { Id = tempSalaryItem.Id, Name = tempSalaryItem.Name }; tempStandard.ItemAmout.Add(salaryItemView, m.Amout); } standardListView.Add(tempStandard); } ViewData["standardListView"] = standardListView; return(View()); }
/// <summary> /// 删除一个用户记录 /// </summary> private void bt_deleteonerecordSalary() { Salary salary = (Salary)UserGrid.SelectedItem; int Id = salary.Id; if (MessageBox.Show("是否删除该用户的信息?", "Tips", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { SalaryBLL salaryBLL = new SalaryBLL(); salaryBLL.DeletSalary(Id); } salaryList = SalaryBLL.GetAllSalary(); SalaryBinding(maxnum, 1); }
private void FrmSalary_Load(object sender, EventArgs e) { dto = SalaryBLL.GetAll(); if (!isUpdate) { dataGridView1.DataSource = dto.Employees; dataGridView1.Columns[0].Visible = false; dataGridView1.Columns[1].HeaderText = "User No"; dataGridView1.Columns[2].HeaderText = "Name"; dataGridView1.Columns[3].HeaderText = "Surname"; dataGridView1.Columns[4].Visible = false; dataGridView1.Columns[5].Visible = false; dataGridView1.Columns[6].Visible = false; dataGridView1.Columns[7].Visible = false; dataGridView1.Columns[8].Visible = false; dataGridView1.Columns[9].Visible = false; dataGridView1.Columns[10].Visible = false; dataGridView1.Columns[11].Visible = false; dataGridView1.Columns[12].Visible = false; dataGridView1.Columns[13].Visible = false; combofull = false; cmbDepartment.DataSource = dto.Departments; cmbDepartment.DisplayMember = "DepartmentName"; cmbDepartment.ValueMember = "ID"; cmbPosition.DataSource = dto.Positions; cmbPosition.DisplayMember = "PositionName"; cmbPosition.ValueMember = "ID"; cmbDepartment.SelectedIndex = -1; cmbPosition.SelectedIndex = -1; if (dto.Departments.Count > 0) { combofull = true; } } cmbMonth.DataSource = dto.Months; cmbMonth.DisplayMember = "MonthName"; cmbMonth.ValueMember = "ID"; cmbMonth.SelectedIndex = -1; if (isUpdate) { panel1.Hide(); txtName.Text = detail.Name; txtSalary.Text = detail.SalaryAmount.ToString(); txtSurname.Text = detail.Surname; txtYear.Text = detail.SalaryYear.ToString(); cmbMonth.SelectedValue = detail.MonthID; } }
public ActionResult DynamicStandardByOcc(string id) { ISalaryBLL bLL = new SalaryBLL(); List <SalaryStandard> list = new List <SalaryStandard>(); List <SalaryStandard> tempList = bLL.GetAllStandardByOccId(Convert.ToInt32(id)); if (tempList != null) { list = tempList; } return(Json(list)); }
public ActionResult DeleteSalaryStandard(string id) { ISalaryBLL bLL = new SalaryBLL(); if (bLL.DeleteSalaryStandard(Convert.ToInt32(id))) { TempData["info"] = "删除成功"; return(Redirect("/SalaryManage/SalaryStandardManage")); } else { TempData["error"] = "删除失败,这个薪酬标准正在使用中"; return(Redirect(Request.UrlReferrer.AbsoluteUri)); } }
public ActionResult AddOccupationName() { IOccupationBLL bLL = new OccupationBLL(); ISalaryBLL salaryBLL = new SalaryBLL(); //装载所有职位类型,作为下拉选择框 List <Models.OccupationClass> occupationgClassList = new List <Models.OccupationClass>(); foreach (var oc in bLL.GetAllOccupationClass()) { Models.OccupationClass tempClass = new Models.OccupationClass { Id = oc.Id, Name = oc.Name }; occupationgClassList.Add(tempClass); } ViewData["occupationClassList"] = occupationgClassList; //装载所有薪酬标准 List <Models.SalaryStandard> standardList = new List <Models.SalaryStandard>(); foreach (var s in salaryBLL.GetAllSalaryStandard()) { Models.SalaryStandard tempS = new Models.SalaryStandard { Id = s.Id, StandardName = s.StandardName, Total = s.Total }; standardList.Add(tempS); } ViewData["standardList"] = standardList; return(View()); }
/// <summary> /// 条件查询 /// </summary> private void search_buttonSalary() { if (combox_search.SelectedItem == null) { MessageBox.Show("请先选择查询条件"); return; } if (txt_search.Text != "" && (combox_search.SelectedItem).ToString() != "") { SalaryBLL salaryBLL = new SalaryBLL(); Salary salary = null; salaryList.Clear(); if (combox_search.SelectedIndex == 1) { if (!isInteger(txt_search.Text)) { MessageBox.Show("请输入数字"); txt_search.Text = ""; return; } int id = int.Parse(txt_search.Text); salary = salaryBLL.GetsalaryByID(id); if (salary != null) { salaryList.Add(salary); UserGrid.ItemsSource = salaryList; } } sum = salaryList.Count; SalaryBinding(maxnum, 1); } else { MessageBox.Show("查找方式和内容不能为空!"); } txt_search.Text = ""; }
/// <summary> /// 批量删除用户记录 /// </summary> private void bt_deletemanySalary() { if (selectedID.Count != 0) { if (MessageBox.Show("是否删除所选中的员工信息?", "Tips", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { foreach (int i in selectedID) { SalaryBLL salaryBLL = new SalaryBLL(); salaryBLL.DeletSalary(i); //循环遍历删除里面的记录 } } else { selectedID.Clear(); } salaryList = SalaryBLL.GetAllSalary(); SalaryBinding(maxnum, 1); //刷新页面 } else { MessageBox.Show("请选择要删除的用户"); } }
private void btnSave_Click(object sender, EventArgs e) { if (txtYear.Text.Trim() == "") { MessageBox.Show("Please fill the year"); } else if (cmbMonth.SelectedIndex == -1) { MessageBox.Show("Please select month"); } else if (txtSalary.Text.Trim() == "") { MessageBox.Show("Please fill the salary"); } else if (txtUserNo.Text.Trim() == "") { MessageBox.Show("Please select the employee"); } else { bool control = false; if (!isUpdated) { if (salary.EmployeeID == 0) { MessageBox.Show("Please select the employee from the table"); } else { salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > oldSalary) { control = true; } SalaryBLL.AddSalary(salary, control); MessageBox.Show("Salary added!"); cmbMonth.SelectedIndex = -1; salary = new SALARY(); } } else { DialogResult dialogResult = MessageBox.Show("Are you sure?", "title", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { SALARY salary = new SALARY(); salary.ID = detail.SalaryID; salary.EmployeeID = detail.EmployeeID; salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > detail.OldSalary) { control = true; } SalaryBLL.UpdateSalary(salary, control); MessageBox.Show("Salary updated!"); this.Close(); } } } }
private void btnSave_Click(object sender, EventArgs e) { if (txtYear.Text.Trim() == "") { MessageBox.Show("Year is empty"); } else if (cmbMonth.SelectedIndex == -1) { MessageBox.Show("Please select a Month"); } else if (txtSalary.Text.Trim() == "") { MessageBox.Show("Salary is empty"); } else if (txtUserNo.Text.Trim() == "") { MessageBox.Show("User number is empty"); } else { //Guardando el salario maximo del empleado bool control = false; if (!isUpdate) { if (salary.EmployeeID == 0) { MessageBox.Show("Select an Employee"); } else { salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > oldsalary) { control = true; } SalaryBLL.AddSalary(salary, control); MessageBox.Show("Salary Added"); cmbMonth.SelectedIndex = -1; salary = new Salary(); } } else { DialogResult result = MessageBox.Show("Are you sure", "Warning", MessageBoxButtons.YesNo); if (DialogResult.Yes == result) { Salary salary = new Salary(); salary.ID = detail.SalaryID; salary.EmployeeID = detail.EmployeeID; salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > detail.OldSalary) { control = true; } SalaryBLL.UpdateSalary(salary, control); MessageBox.Show("Salary Updated"); this.Close(); } } } }
public ActionResult StandardSearch(FormCollection formCollection) { ISalaryBLL bLL = new SalaryBLL(); ISalaryItemBLL salaryItemBLL = new SalaryItemBLL(); List <SalaryStandard> list = new List <SalaryStandard>(); List <SalaryStandard> tempList = new List <SalaryStandard>(); if (formCollection["Keyword"] != "") { list = bLL.GetAllSalaryStandardByKeyword(formCollection["Keyword"]); tempList = list; if (formCollection["BeginDate"] != "") { var l = from s in list where s.RegistTime > Convert.ToDateTime(formCollection["BeginDate"]) select s; tempList = l.ToList(); if (formCollection["EndDate"] != "") { var l2 = from s in tempList where s.RegistTime < Convert.ToDateTime(formCollection["EndDate"]) select s; tempList = l2.ToList(); } } list = tempList; } else { list = bLL.GetAllSalaryStandard(); tempList = list; if (formCollection["BeginDate"] != "") { var l = from s in list where s.RegistTime > Convert.ToDateTime(formCollection["BeginDate"]) select s; tempList = l.ToList(); if (formCollection["EndDate"] != "") { var l2 = from s in tempList where s.RegistTime < Convert.ToDateTime(formCollection["EndDate"]) select s; tempList = l2.ToList(); } } list = tempList; } List <Models.SalaryStandard> standardListView = new List <Models.SalaryStandard>(); if (list != null) { //遍历所有薪酬标准,将其转换成视图模型中的薪酬标准 foreach (var s in list) { //通过薪酬标准的id获取所有的映射关系 List <StandardMapItem> tempMapList = bLL.GetAllStandardMapItemByStandardId(s.Id); Models.SalaryStandard tempStandard = new Models.SalaryStandard() { Id = s.Id, StandardName = s.StandardName, StandardFileNumber = s.StandardFileNumber, Registrant = s.Registrant, RegistTime = s.RegistTime, DesignBy = s.DesignBy, Total = s.Total, StandardState = s.StandardState, CheckDesc = s.CheckDesc, CheckBy = s.CheckBy }; //遍历映射关系,分拆装载进视图模型薪酬标准中的字典 foreach (var m in tempMapList) { SalaryItem tempSalaryItem = salaryItemBLL.GetSalaryItemById(m.ItemId); Models.SalaryItem salaryItemView = new Models.SalaryItem { Id = tempSalaryItem.Id, Name = tempSalaryItem.Name }; tempStandard.ItemAmout.Add(salaryItemView, m.Amout); } standardListView.Add(tempStandard); } } ViewData["standardListView"] = standardListView; return(View("SalaryStandardManage")); }
public ActionResult SalaryPaymentDetail(string id) { ISalaryGrantBLL salaryGrantBLL = new SalaryGrantBLL(); IStaffBLL staffBLL = new StaffBLL(); ISalaryBLL salaryBLL = new SalaryBLL(); ISalaryItemBLL salaryItemBLL = new SalaryItemBLL(); IOrgBLL orgBLL = new OrgBLL(); List <StaffPayment> staffPaymentList = salaryGrantBLL.GetAllStaffPaymentByPaymentId(Convert.ToInt32(id)); List <Models.StaffPayment> staffPaymentListView = new List <Models.StaffPayment>(); foreach (var sp in staffPaymentList) { Models.StaffPayment staffPayment = new Models.StaffPayment { Id = sp.Id, OddAmout = sp.OddAmout, MinusAmout = sp.MinusAmout }; //获取Model.StaffSalary,为StaffPayment装载StaffSalary StaffSalary staffSalary = salaryGrantBLL.GetStaffSalaryById(sp.StaffSalaryId); Models.StaffSalary staffSalaryView = new Models.StaffSalary { Id = staffSalary.Id, StaffFileNumber = staffSalary.StaffFileNumber }; Staff staff = staffBLL.GetStaffById(staffSalary.StaffId); staffSalaryView.Staff = new Models.Staff { Id = staff.Id, StaffName = staff.StaffName }; ThirdOrg thirdOrg = orgBLL.GetThirdOrgById(staff.ThirdOrgId); SecondOrg secondOrg = orgBLL.GetSecondOrgById(thirdOrg.ParentOrgId); FirstOrg firstOrg = orgBLL.GetFirstOrgById(secondOrg.ParentOrgId); Models.FirstOrg firstOrgView = new Models.FirstOrg { Id = firstOrg.Id, OrgLevel = firstOrg.OrgLevel, OrgName = firstOrg.OrgName }; Models.SecondeOrg secondeOrgView = new Models.SecondeOrg { Id = secondOrg.Id, OrgName = secondOrg.OrgName, OrgLevel = secondOrg.OrgLevel, ParentOrg = firstOrgView }; staffSalaryView.ThirdOrg = new Models.ThirdOrg { Id = thirdOrg.Id, ParentOrg = secondeOrgView, OrgLevel = thirdOrg.OrgLevel, OrgName = thirdOrg.OrgName }; SalaryStandard salaryStandard = salaryBLL.GetSalaryStandardById(staffSalary.StandardId); Models.SalaryStandard salaryStandardView = new Models.SalaryStandard { Id = salaryStandard.Id, StandardName = salaryStandard.StandardName, }; List <StandardMapItem> standardMapItemList = salaryBLL.GetAllStandardMapItemByStandardId(salaryStandard.Id); foreach (var item in standardMapItemList) { SalaryItem salaryItem = salaryItemBLL.GetSalaryItemById(item.ItemId); Models.SalaryItem salaryItemView = new Models.SalaryItem { Id = salaryItem.Id, Name = salaryItem.Name }; salaryStandardView.ItemAmout.Add(salaryItemView, item.Amout);; } staffSalaryView.SalaryStandard = salaryStandardView; staffPayment.StaffSalary = staffSalaryView; SalaryPayment salaryPayment = salaryGrantBLL.GetSalaryPaymentById(sp.PaymentId); staffPayment.SalaryPayment = new Models.SalaryPayment { Id = salaryPayment.Id, TotalPerson = salaryPayment.TotalPerson, TotalAmout = salaryPayment.TotalAmout, FileState = salaryPayment.FileState, FileNumber = salaryPayment.FileNumber, Registrant = salaryPayment.Registrant, RegistTime = salaryPayment.RegistTime, TotalReal = salaryPayment.TotalReal, CheckBy = salaryPayment.CheckBy, CheckTime = salaryPayment.CheckTime }; staffPaymentListView.Add(staffPayment); } ViewData["staffPaymentListView"] = staffPaymentListView; return(View()); }
/// <summary> /// 保存薪酬标准,编辑或添加 /// </summary> /// <param name="formCollection">表单值容器</param> /// <returns>成功则重定向到刚刚保存的薪酬标准的详情页,否则回到源URL</returns> public ActionResult SaveStandard(FormCollection formCollection) { //薪酬管理的业务层 ISalaryBLL salaryBLL = new SalaryBLL(); //薪酬项目的业务层 ISalaryItemBLL bLL = new SalaryItemBLL(); //数据层Model的薪酬标准 SalaryStandard salaryStandard = new SalaryStandard(); Type type = salaryStandard.GetType(); var props = type.GetProperties(); //反射,遍历,把表单数据装载到对象的属性中 foreach (var p in props) { if (p.Name != "StandardState" && p.Name != "Id") { p.SetValue(salaryStandard, Convert.ChangeType(formCollection[p.Name], p.PropertyType)); } } //装载id,因为当添加薪酬标准时,id为空,null类型不能转换 salaryStandard.Id = Convert.ToInt32(formCollection["Id"]); //装载状态,枚举类型不能转换 if (formCollection["StandardChecked"] == "Checked") { salaryStandard.StandardState = EnumState.StandardStateEnum.Checked; } else { salaryStandard.StandardState = EnumState.StandardStateEnum.WaitCheck; } //先保存该薪酬标准,否则,无法insert映射记录 salaryBLL.SaveSalaryStandard(salaryStandard); //根据全局唯一的编号获取刚刚保存的薪酬标准的id salaryStandard.Id = salaryBLL.GetSalaryStandardIdByfileNumber(salaryStandard.StandardFileNumber); var itemcheckbox = formCollection["ItemCheckbox"]; decimal total = 0; //遍历复选框,只有复选框勾选,下面对应的输入框的数值才有效 foreach (var i in itemcheckbox.Split(',')) { StandardMapItem tempMap = new StandardMapItem { StandardId = salaryStandard.Id, ItemId = Convert.ToInt32(i), Amout = Convert.ToDecimal(formCollection["value" + i]) }; salaryBLL.SaveMapItem(tempMap); total += tempMap.Amout; } //更新总金额 salaryStandard.Total = total; //判断该薪酬标准在映射表中有没有记录 if (salaryBLL.GetAllStandardMapOccByStandardId(salaryStandard.Id) != null) { if (!salaryBLL.DeleteAllOccMapByStandardId(salaryStandard.Id)) { TempData["error"] = "保存失败"; return(Redirect(Request.UrlReferrer.AbsoluteUri)); } } //往数据库添加未存在的映射关系 for (int i = Convert.ToInt32(formCollection["eCount"]); i < 3; i++) { if (Convert.ToInt32(formCollection["occName" + i]) != 0) { StandardMapOccupationName standardMapOccupationName = new StandardMapOccupationName { StandardId = salaryStandard.Id, OccupationNameId = Convert.ToInt32(formCollection["occName" + i]) }; salaryBLL.SaveMapOcc(standardMapOccupationName); } } //重新保存一次薪酬标准 if (salaryBLL.SaveSalaryStandard(salaryStandard)) { TempData["info"] = "保存成功"; return(RedirectToAction("DetailSalaryStandard", new { id = salaryStandard.Id })); } else { TempData["error"] = "保存失败"; return(Redirect(Request.UrlReferrer.AbsoluteUri)); } }
/// <summary> /// 薪酬标准详情 /// </summary> /// <param name="id">薪酬标准的id</param> /// <returns>薪酬标准详情页</returns> public ActionResult DetailSalaryStandard(string id) { ISalaryBLL salaryBLL = new SalaryBLL(); ISalaryItemBLL salaryItemBLL = new SalaryItemBLL(); IOccupationBLL occupationBLL = new OccupationBLL(); //通过id查找到薪酬标准 SalaryStandard salaryStandard = salaryBLL.GetSalaryStandardById(Convert.ToInt32(id)); //视图模型薪酬标准 Models.SalaryStandard salaryStandardView = new Models.SalaryStandard { Id = salaryStandard.Id, StandardName = salaryStandard.StandardName, StandardFileNumber = salaryStandard.StandardFileNumber, Registrant = salaryStandard.Registrant, RegistTime = salaryStandard.RegistTime, DesignBy = salaryStandard.DesignBy, Total = salaryStandard.Total, StandardState = salaryStandard.StandardState, CheckDesc = salaryStandard.CheckDesc, CheckBy = salaryStandard.CheckBy }; //通过薪酬标准的id找到所有的项目映射关系 List <StandardMapItem> tempMapList = salaryBLL.GetAllStandardMapItemByStandardId(salaryStandard.Id); //遍历映射关系,并把薪酬项目和薪酬项目的金额装载到视图模型薪酬标准的字典中 foreach (var m in tempMapList) { SalaryItem tempSalaryItem = salaryItemBLL.GetSalaryItemById(m.ItemId); Models.SalaryItem salaryItemView = new Models.SalaryItem { Id = tempSalaryItem.Id, Name = tempSalaryItem.Name }; salaryStandardView.ItemAmout.Add(salaryItemView, m.Amout); } //通过薪酬标准的id找到所有的职位映射关系 List <StandardMapOccupationName> occList = salaryBLL.GetAllStandardMapOccByStandardId(salaryStandard.Id); if (occList != null) { foreach (var o in occList) { OccupationName tempOccName = occupationBLL.GetOccupationNameById(o.OccupationNameId); Models.OccupationName occupationNameView = new Models.OccupationName { Id = tempOccName.Id, Name = tempOccName.Name }; OccupationClass tempOccClass = occupationBLL.GetOccupationClassById(tempOccName.ClassId); occupationNameView.OccupationClass = new Models.OccupationClass { Id = tempOccClass.Id, Name = tempOccClass.Name }; salaryStandardView.OccList.Add(occupationNameView); } } ViewData["salaryStandardView"] = salaryStandardView; return(View()); }
/// <summary> /// 控制器内部方法,通过id获取薪酬标准的详细信息 /// </summary> /// <param name="id">薪酬标准的id</param> private void GetStandardById(string id) { ISalaryBLL salaryBLL = new SalaryBLL(); ISalaryItemBLL salaryItemBLL = new SalaryItemBLL(); IOccupationBLL occupationBLL = new OccupationBLL(); //通过id查找到薪酬标准 SalaryStandard salaryStandard = salaryBLL.GetSalaryStandardById(Convert.ToInt32(id)); //视图模型薪酬标准 Models.SalaryStandard salaryStandardView = new Models.SalaryStandard { Id = salaryStandard.Id, StandardName = salaryStandard.StandardName, StandardFileNumber = salaryStandard.StandardFileNumber, Registrant = salaryStandard.Registrant, RegistTime = salaryStandard.RegistTime, DesignBy = salaryStandard.DesignBy, Total = salaryStandard.Total, StandardState = salaryStandard.StandardState, CheckDesc = salaryStandard.CheckDesc, CheckBy = salaryStandard.CheckBy }; //通过薪酬标准的id找到所有的项目映射关系 List <StandardMapItem> tempMapList = salaryBLL.GetAllStandardMapItemByStandardId(salaryStandard.Id); //遍历映射关系,并把薪酬项目和薪酬项目的金额装载到视图模型薪酬标准的字典中 foreach (var m in tempMapList) { SalaryItem tempSalaryItem = salaryItemBLL.GetSalaryItemById(m.ItemId); Models.SalaryItem salaryItemView = new Models.SalaryItem { Id = tempSalaryItem.Id, Name = tempSalaryItem.Name }; salaryStandardView.ItemAmout.Add(salaryItemView, m.Amout); } //通过薪酬标准的id找到所有的职位映射关系 List <StandardMapOccupationName> occList = salaryBLL.GetAllStandardMapOccByStandardId(salaryStandard.Id); if (occList != null) { foreach (var o in occList) { OccupationName tempOccName = occupationBLL.GetOccupationNameById(o.OccupationNameId); Models.OccupationName occupationNameView = new Models.OccupationName { Id = tempOccName.Id, Name = tempOccName.Name }; OccupationClass tempOccClass = occupationBLL.GetOccupationClassById(tempOccName.ClassId); occupationNameView.OccupationClass = new Models.OccupationClass { Id = tempOccClass.Id, Name = tempOccClass.Name }; salaryStandardView.OccList.Add(occupationNameView); } } ViewData["salaryStandardView"] = salaryStandardView; //装载所有薪酬项目 List <SalaryItem> salaryList = salaryItemBLL.GetAllSalaryItem(); List <Models.SalaryItem> itemList = new List <Models.SalaryItem>(); foreach (var item in salaryList) { Models.SalaryItem tempItem = new Models.SalaryItem { Id = item.Id, Name = item.Name }; itemList.Add(tempItem); } ViewData["itemList"] = itemList; //装载所有职位类型 List <OccupationClass> occClassList = occupationBLL.GetAllOccupationClass(); List <Models.OccupationClass> occClassListView = new List <Models.OccupationClass>(); if (occClassList != null) { foreach (var oc in occClassList) { Models.OccupationClass tempClass = new Models.OccupationClass() { Id = oc.Id, Name = oc.Name }; occClassListView.Add(tempClass); } } ViewData["occClassListView"] = occClassListView; //装载所有该薪酬标准的职位类型下的所有职位 List <Models.OccupationName> occNameList = new List <Models.OccupationName>(); for (int i = 0; i < salaryStandardView.OccList.Count; i++) { List <OccupationName> tempList = occupationBLL.GetAllOccNameByClassId(salaryStandardView.OccList[i].OccupationClass.Id); foreach (var on in tempList) { Models.OccupationName tempOccupationName = new Models.OccupationName { Id = on.Id, Name = on.Name, OccupationClass = salaryStandardView.OccList[i].OccupationClass }; occNameList.Add(tempOccupationName); } } ViewData["occNameList"] = occNameList; }
private void btnSave_Click(object sender, EventArgs e) { if (txtYear.Text.Trim() == "") { MessageBox.Show("year is empty"); } else if (txtSalary.Text.Trim() == "") { MessageBox.Show("Salary is empty"); } else if (cmbMonth.SelectedIndex == -1) { MessageBox.Show("Select a month"); } else { bool control = false; if (!isUpdate) { if (salary.EmployeeID == 0) { MessageBox.Show("please select an employee from table"); } else { salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > oldsalary) { control = true; } SalaryBLL.AddSalary(salary, control); MessageBox.Show("Salary was added"); cmbMonth.SelectedIndex = -1; salary = new SALARY(); } } else { DialogResult result = MessageBox.Show("Are you sure?", "title", MessageBoxButtons.YesNo); if (DialogResult.Yes == result) { SALARY salary = new SALARY(); salary.ID = detail.SalaryID; salary.EmployeeID = detail.EmployeeID; salary.Year = Convert.ToInt32(txtYear.Text); salary.MonthID = Convert.ToInt32(cmbMonth.SelectedValue); salary.Amount = Convert.ToInt32(txtSalary.Text); if (salary.Amount > detail.oldSalary) { control = true; } SalaryBLL.UpdateSalary(salary, control); MessageBox.Show("Salary was Uptaded"); this.Close(); } } } }
/// <summary> /// 控制器内部方法 /// </summary> /// <param name="id">通过id装载视图模型Staff</param> private void GetStaffById(string id) { IStaffBLL staffBLL = new StaffBLL(); IOrgBLL orgBLL = new OrgBLL(); IOccupationBLL occupationBLL = new OccupationBLL(); ISalaryBLL salaryBLL = new SalaryBLL(); Staff staff = staffBLL.GetStaffById(Convert.ToInt32(id)); Models.Staff staffView = new Models.Staff(); Type type = typeof(Models.Staff); Type modelType = typeof(Staff); var props = type.GetProperties(); foreach (var p in props) { if (modelType.GetProperty(p.Name) != null) { p.SetValue(staffView, modelType.GetProperty(p.Name).GetValue(staff)); } } ThirdOrg thirdOrg = orgBLL.GetThirdOrgById(staff.ThirdOrgId); SecondOrg secondOrg = orgBLL.GetSecondOrgById(thirdOrg.ParentOrgId); FirstOrg firstOrg = orgBLL.GetFirstOrgById(secondOrg.ParentOrgId); OccupationName occupationName = occupationBLL.GetOccupationNameById(staff.OccId); OccupationClass occupationClass = occupationBLL.GetOccupationClassById(occupationName.ClassId); SalaryStandard salaryStandard = salaryBLL.GetSalaryStandardById(staff.StandardId); TechnicalTitle technicalTitle = occupationBLL.GetTechnicalTitleById(staff.TechnicalTitleId); staffView.FirstOrg = new Models.FirstOrg { Id = firstOrg.Id, OrgLevel = firstOrg.OrgLevel, OrgName = firstOrg.OrgName }; staffView.SecondeOrg = new Models.SecondeOrg { Id = secondOrg.Id, OrgName = secondOrg.OrgName, OrgLevel = secondOrg.OrgLevel, ParentOrg = staffView.FirstOrg }; staffView.ThirdOrg = new Models.ThirdOrg { Id = thirdOrg.Id, ParentOrg = staffView.SecondeOrg, OrgLevel = thirdOrg.OrgLevel, OrgName = thirdOrg.OrgName }; staffView.OccupationClass = new Models.OccupationClass { Id = occupationClass.Id, Name = occupationClass.Name }; staffView.OccupationName = new Models.OccupationName { Id = occupationName.Id, Name = occupationName.Name, OccupationClass = staffView.OccupationClass }; staffView.SalaryStandard = new Models.SalaryStandard { Id = salaryStandard.Id, StandardName = salaryStandard.StandardName, Total = salaryStandard.Total }; staffView.TechnicalTitle = new Models.TechnicalTitle { Id = technicalTitle.Id, Name = technicalTitle.Name }; ViewData["staffView"] = staffView; //装载所有职称 List <Models.TechnicalTitle> list = new List <Models.TechnicalTitle>(); List <TechnicalTitle> tempList = occupationBLL.GetAllTechnicalTitle(); foreach (var tt in tempList) { Models.TechnicalTitle tempTechnicalTitle = new Models.TechnicalTitle { Id = tt.Id, Name = tt.Name }; list.Add(tempTechnicalTitle); } ViewData["tTitleList"] = list; //装载该职位的所有薪酬标准 List <SalaryStandard> standardList = salaryBLL.GetAllStandardByOccId(staff.OccId); List <Models.SalaryStandard> standardListView = new List <Models.SalaryStandard>(); foreach (var s in standardList) { Models.SalaryStandard tempStandard = new Models.SalaryStandard { Id = s.Id, StandardName = s.StandardName, Total = s.Total }; standardListView.Add(tempStandard); } ViewData["standardListView"] = standardListView; }