public ResponseData AddRoleByEntity(RoleViewModel data) { using (SATEntities db = new SATEntities()) { ResponseData result = new Models.ResponseData(); try { tb_Role model = new tb_Role(); model.RoleID = data.RoleID; model.RoleName = data.RoleName; data.RoleDesc = data.RoleDesc; model.RoleStatus = (data.Status == "1") ? true : false; model.CreateBy = data.ModifyBy; model.CreateDate = DateTime.Now; model.ModifyBy = data.ModifyBy; model.ModifyDate = DateTime.Now; db.tb_Role.Add(model); db.SaveChanges(); } catch (Exception) { } return(result); } }
public string getCM(int ma) { List <string> LstDSmaTL = new List <string>(); NewsEntities db = new NewsEntities(); string CM = ""; List <tb_Role> lstCM = db.tb_Role.Where(x => x.ID_User == ma).ToList(); int sl = lstCM.Count(); for (int i = 0; i < sl; i++) { tb_Role obj = lstCM.ElementAt(i); CM += obj.tb_ChuyenMuc.TenChuyenMuc.ToString() + " || "; LstDSmaTL.Add(obj.tb_ChuyenMuc.ID_ChuyenMuc.ToString()); } return(CM); }
public string getCM(int ma) { List <string> LstDSmaTL = new List <string>(); NewsEntities db = new NewsEntities(); string CM = ""; List <tb_Role> lstCM = db.tb_Role.Where(x => x.ID_User == ma).ToList(); int sl = lstCM.Count(); for (int i = 0; i < sl; i++) { tb_Role obj = lstCM.ElementAt(i); CM += obj.tb_ChuyenMuc.TenChuyenMuc.ToString() + "; "; LstDSmaTL.Add(obj.tb_ChuyenMuc.ID_ChuyenMuc.ToString()); foreach (ListItem item in cbbChuyenMuc.Items) { if (item.Value == obj.tb_ChuyenMuc.ID_ChuyenMuc.ToString()) { item.Selected = true; } } } return(CM); }
public static RoleDetails Find_RoleDetails(tb_Role next_role, tb_Request_Hdr data, tb_WF_Employee employee) { RoleDetails role = new RoleDetails(); role.role_id = next_role.Role_ID; role.role_name = next_role.Role_Desc; if (next_role.Organization_Flag == false) { if (next_role.Assigned_ID != null) { #region Normal role.assigned_person_id = next_role.Assigned_ID; #endregion Normal } else { if (next_role.GroupRole == true) { #region Having Multiple var universal = _Entities.tb_UniversalLookupTable.Where(x => x.Table_Name == next_role.Role_ID && x.IsActive == true).FirstOrDefault(); if (universal != null) { role.assigned_person_id = universal.Table_Name; } #endregion Having Multiple } else { #region Having Single var universal = _Entities.tb_UniversalLookupTable.Where(x => x.Table_Name == next_role.Role_ID && x.IsActive == true && (x.Code == null || x.Code == data.tb_WFType.WF_ID)).FirstOrDefault(); if (universal != null) { role.assigned_person_id = universal.Description; } #endregion Having Single } } } else { #region if (next_role.org_type == null || next_role.org_type == string.Empty) { role.assigned_person_id = employee.Line_Manager; } else if (next_role.org_type.Trim() == "DT")// Check the department table { #region Department var department = _Entities.tb_Department.Where(x => x.IsActive == true && x.Department_Id == employee.Department_Id).FirstOrDefault(); if (department != null) { if (next_role.role_type == "MN" && department.Dept_Manager != null) { role.assigned_person_id = department.Dept_Manager; } else if (next_role.role_type == "CR" && department.Dept_Controller != null) { role.assigned_person_id = department.Dept_Controller; } else if (next_role.role_type == "OA" && department.Dep_Office_Admin != null) { role.assigned_person_id = department.Dep_Office_Admin; } } #endregion Department } else if (next_role.org_type.Trim() == "BL")// Check the business line table { #region Business Line var business = _Entities.tb_BusinessLine.Where(x => x.IsActive == true && x.BL_Id == employee.tb_Department.tb_ProductGroup.BusinessLine_Id).FirstOrDefault(); if (business != null) { if (next_role.role_type == "MN" && business.BL_Manager != null) { role.assigned_person_id = business.BL_Manager; } else if (next_role.role_type == "CR" && business.BL_Controller != null) { role.assigned_person_id = business.BL_Controller; } else if (next_role.role_type == "OA" && business.BL_Office_Admin != null) { role.assigned_person_id = business.BL_Office_Admin; } } #endregion Business Line } else if (next_role.org_type.Trim() == "B")// Check the business { #region Business var business = _Entities.tb_Business.Where(x => x.IsActive == true && x.Bus_Id == employee.tb_Department.tb_ProductGroup.tb_BusinessLine.Business_Id).FirstOrDefault(); if (business != null) { if (next_role.role_type == "MN" && business.Bus_Manager != null) { role.assigned_person_id = business.Bus_Manager; } else if (next_role.role_type == "CR" && business.Bus_Controller != null) { role.assigned_person_id = business.Bus_Controller; } else if (next_role.role_type == "OA" && business.Bus_Office_Admin != null) { role.assigned_person_id = business.Bus_Office_Admin; } } #endregion Business } else if (next_role.org_type == "PG")// Check the Product group table { #region Product Group var product = _Entities.tb_ProductGroup.Where(x => x.IsActive == true && x.PG_Id == employee.tb_Department.PG_Id).FirstOrDefault(); if (product != null) { if (next_role.role_type == "MN" && product.PG_Manager != null) { role.assigned_person_id = product.PG_Manager; } else if (next_role.role_type == "CR" && product.PG_Controller != null) { role.assigned_person_id = product.PG_Controller; } else if (next_role.role_type == "OA" && product.PG_Office_Admin != null) { role.assigned_person_id = product.PG_Office_Admin; } } #endregion Product Group } #endregion } var next_emp = _Entities.tb_WF_Employee.Where(x => x.LocalEmplyee_ID == role.assigned_person_id && x.IsActive == true).FirstOrDefault(); #region if (next_emp != null) { role.assigned_person_id = next_emp.LocalEmplyee_ID; if (next_emp.DelegationFlag == true) { role.deligated_personId = next_emp.Delegate_Emp_Code == null ? next_emp.LocalEmplyee_ID : next_emp.Delegate_Emp_Code; } else { role.deligated_personId = next_emp.LocalEmplyee_ID; } if (role.deligated_personId == data.Employee_ID) { //var bus_line = _entity.tb_BusinessLine.Where(x => x.BL_Id == employee.BusinessLine_Id && x.Country_Id == country.Id && x.IsActive == true).FirstOrDefault(); //var line_manager = _entity.tb_WF_Employee.Where(x => x.LocalEmplyee_ID == bus_line.BL_Manager && x.IsActive == true).FirstOrDefault(); var line_manager = _Entities.tb_WF_Employee.Where(x => x.LocalEmplyee_ID == employee.Line_Manager && x.IsActive == true).FirstOrDefault(); if (line_manager != null) { if (line_manager.DelegationFlag == true) { role.assigned_person_id = line_manager.Delegate_Emp_Code == null ? line_manager.LocalEmplyee_ID : line_manager.Delegate_Emp_Code; } else { role.assigned_person_id = line_manager.LocalEmplyee_ID; } } } } else { role.deligated_personId = role.assigned_person_id; } #endregion return(role); }