public object Clone() { EmpFormEntity empForm = new EmpFormEntity(); // copy Employee empForm.Employee = this.Employee.Clone() as Employee; // empType empForm.EmpType = this.EmpType; //List<Department> List<EmpDept> depts = new List<EmpDept>(); foreach (EmpDept dept in this.EmpDept) { depts.Add(dept.Clone() as EmpDept); } empForm.EmpDept = depts.ToArray(); //List<FixedAmountItem> List<FixedAmountItem> mitems = new List<FixedAmountItem>(); foreach (FixedAmountItem mf in this.monFixs) { mitems.Add(mf.Clone() as FixedAmountItem); } empForm.MonthFixItem = mitems.ToArray(); //List<FixedAmountItem> List<FixedAmountItem> bitems = new List<FixedAmountItem>(); foreach (FixedAmountItem mf in this.bonusFixs) { bitems.Add(mf.Clone() as FixedAmountItem); } empForm.BonusFixItem = bitems.ToArray(); return empForm; }
public void Save(EmpFormEntity empf) { SqlConnection conn = new SqlConnection(DBAccess.SQLConnectionString); conn.Open(); SqlTransaction trans = conn.BeginTransaction(); try { Save(empf.Employee, trans); SaveEmpDept(empf.Employee.EmpID, empf.EmpDept, trans); SaveFixAmount(empf.Employee.EmpID, empf.MonthFixItem, empf.BonusFixItem, trans); } catch (DAOException) { trans.Rollback(); throw; } trans.Commit(); conn.Close(); }
public List<EmpFormEntity> getFormEmpEntityList(EmpSearchTerm filter, EmpFormEntityMask mask) { try { List<Employee> empList = this.getEmpByMultiFilter(filter); List<EmpFormEntity> formEmpEntityList = new List<EmpFormEntity>(); foreach(Employee emp in empList) { // employee EmpFormEntity formEmpEntity = new EmpFormEntity(); formEmpEntity.Employee = emp; // emptype if ((mask & EmpFormEntityMask.EmpType) == EmpFormEntityMask.EmpType) { EmpType empType = this.getEmpTypeByEmpTypeID(emp.EmpTypeID); formEmpEntity.EmpType = empType; } // empdept if ((mask & EmpFormEntityMask.EmpDept) == EmpFormEntityMask.EmpDept) { List<EmpDept> deptList = empDAO.searchDeptByEmpID(emp.EmpID); formEmpEntity.EmpDept = (EmpDept[])deptList.ToArray(); } // monthfix if ((mask & EmpFormEntityMask.MonFix) == EmpFormEntityMask.MonFix) { List<FixedAmountItem> mfs = empDAO.getEmpFixedAmountItem(emp.EmpID, false); formEmpEntity.MonthFixItem = (FixedAmountItem[])mfs.ToArray(); } // bonusfix if ((mask & EmpFormEntityMask.BonusFix) == EmpFormEntityMask.BonusFix) { List<FixedAmountItem> bfs = empDAO.getEmpFixedAmountItem(emp.EmpID, true); formEmpEntity.BonusFixItem = (FixedAmountItem[])bfs.ToArray(); } formEmpEntityList.Add(formEmpEntity); } return formEmpEntityList; } catch (DAOException) { throw; } }
public EmpFormEntity getFormEmpEntity(string empId, EmpFormEntityMask mask) { EmpFormEntity formEmpEntity = new EmpFormEntity(); Employee emp = this.getEmployee(empId); if (null == emp) { return null; } formEmpEntity.Employee = emp; try { if ((mask & EmpFormEntityMask.EmpType) == EmpFormEntityMask.EmpType) { EmpType empType = this.getEmpTypeByEmpTypeID(emp.EmpTypeID); formEmpEntity.EmpType = empType; } if ((mask & EmpFormEntityMask.EmpDept) == EmpFormEntityMask.EmpDept) { List<EmpDept> deptList = empDAO.searchDeptByEmpID(empId); formEmpEntity.EmpDept = (EmpDept[])deptList.ToArray(); } if ((mask & EmpFormEntityMask.MonFix) == EmpFormEntityMask.MonFix) { List<FixedAmountItem> mfs = empDAO.getEmpFixedAmountItem(empId, false); formEmpEntity.MonthFixItem = (FixedAmountItem[])mfs.ToArray(); } if ((mask & EmpFormEntityMask.BonusFix) == EmpFormEntityMask.BonusFix) { List<FixedAmountItem> bfs = empDAO.getEmpFixedAmountItem(empId, true); formEmpEntity.BonusFixItem = (FixedAmountItem[])bfs.ToArray(); } } catch (DAOException) { throw; } return formEmpEntity; }
private void ReloadData() { try { curEmpFormEntity = iemployee.getFormEmpEntity(GetCurSelEmpId(), EmpFormEntityMask.EmpType | EmpFormEntityMask.EmpDept | EmpFormEntityMask.MonFix | EmpFormEntityMask.BonusFix); if (null != curEmpFormEntity) { empFormBack = curEmpFormEntity.Clone() as EmpFormEntity; } else { empFormBack = null; ShowErrorInfo("无有效数据。"); } } catch (BIZException be) { curEmpFormEntity = null; empFormBack = null; ShowErrorInfo("读取业务员信息失败: " + be.Message); } catch (DAOException de) { curEmpFormEntity = null; empFormBack = null; ShowErrorInfo("读取业务员信息失败: " + de.Message); } }
protected override bool SavePageData() { if (curEmpFormEntity == null) { return false; } if (!DataChanged) { return true; } try { iemployee.Save(curEmpFormEntity); empFormBack = curEmpFormEntity.Clone() as EmpFormEntity; return true; } catch (BIZException be) { ShowErrorInfo("数据保存失败: " + be.Message); return false; } catch (DAOException de) { ShowErrorInfo("数据保存失败: " + de.Message); return false; } }
protected override void RecoverData() { curEmpFormEntity = empFormBack.Clone() as EmpFormEntity; }