protected DataTable loadExtraData(DataTable sourceTable) { DataTable destTable = sourceTable.Copy(); destTable.Columns.Add("CompanyCode", typeof(string)); destTable.Columns.Add("BusinessHierarchy", typeof(string)); destTable.Columns.Add("PositionCode", typeof(string)); destTable.Columns.Add("RankCode", typeof(string)); destTable.Columns.Add("StaffTypeCode", typeof(string)); destTable.Columns.Add("LeavePlanCode", typeof(string)); destTable.Columns.Add("PayGroupCode", typeof(string)); foreach (DataRow row in destTable.Rows) { EEmpPositionInfo empPos = EEmpPositionInfo.GetObject(dbConn, row["EmpPosID"]); if (empPos != null) { ECompany company = ECompany.GetObject(dbConn, row["CompanyID"]); if (company != null) { row["CompanyCode"] = company.CompanyCode; } row["BusinessHierarchy"] = empPos.GetBusinessHierarchyString(dbConn); EPosition position = EPosition.GetObject(dbConn, row["PositionID"]); if (position != null) { row["PositionCode"] = position.PositionCode; } ERank rank = ERank.GetObject(dbConn, row["RankID"]); if (rank != null) { row["RankCode"] = rank.RankCode; } EStaffType staffType = EStaffType.GetObject(dbConn, row["StaffTypeID"]); if (staffType != null) { row["StaffTypeCode"] = staffType.StaffTypeCode; } ELeavePlan leavePlan = ELeavePlan.GetObject(dbConn, row["LeavePlanID"]); if (leavePlan != null) { row["LeavePlanCode"] = leavePlan.LeavePlanCode; } EPayrollGroup payGroup = EPayrollGroup.GetObject(dbConn, (int)row["PayGroupID"]); if (payGroup != null) { row["PayGroupCode"] = payGroup.PayGroupCode; } } } return(destTable); }
protected void Save_Click(object sender, EventArgs e) { EPayrollGroup c = new EPayrollGroup(); Hashtable values = new Hashtable(); binding.toValues(values); PageErrors errors = PageErrors.getErrors(db, Page.Master); errors.clear(); db.validate(errors, values); if (!errors.isEmpty()) { return; } db.parse(values, c); //c.PayGroupID = CurID; ArrayList newUserList = WebUtils.SelectedRepeaterItemToBaseObjectList(EUser.db, Users, "UserSelect"); bool m_isPublic = (newUserList.Count <= 0); DBFilter notUser = new DBFilter(); notUser.add(new Match("PayGroupID", CurID)); foreach (EUser user in newUserList) { DBFilter filter = new DBFilter(); filter.add(new Match("UserID", user.UserID)); filter.add(new Match("PayGroupID", CurID)); if (EPayrollGroupUsers.db.count(dbConn, filter) <= 0) { EPayrollGroupUsers o = new EPayrollGroupUsers(); o.UserID = user.UserID; o.PayGroupID = CurID; EPayrollGroupUsers.db.insert(dbConn, o); } notUser.add(new Match("UserID", "<>", user.UserID)); } ArrayList unselectedUserList = EPayrollGroupUsers.db.select(dbConn, notUser); foreach (EPayrollGroupUsers payrollGroupUsers in unselectedUserList) { EPayrollGroupUsers.db.delete(dbConn, payrollGroupUsers); } // update payroll group IsPublic flag EPayrollGroup m_group = EPayrollGroup.GetObject(dbConn, CurID); if (m_group != null) { m_group.PayGroupIsPublic = m_isPublic; EPayrollGroup.db.update(dbConn, m_group); } HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Payroll_Group_View.aspx?PayGroupID=" + CurID); }