public static List <FunctViewModel> getFunctions() { List <FunctViewModel> dtFunct = new List <FunctViewModel>(); FunctAccess access = new FunctAccess(); DataTable dtResult = access.GetFunctions(); foreach (DataRow dtr in dtResult.Rows) { FunctViewModel item = new FunctViewModel { FUNCCODE = dtr["FUNCCODE"].ToString(), FUNCNAME = dtr["FUNCNAME"].ToString(), FUNCPARENT = dtr["FUNCPARENT"].ToString(), FUNCLEVEL = dtr["FUNCLEVEL"].ToString(), ORDERINDEX = dtr["ORDERINDEX"].ToString(), ISACTIVE = dtr["ISACTIVE"].ToString(), REMARK = dtr["REMARK"].ToString(), CREATE_UID = dtr["CREATE_UID"].ToString(), CREATE_DT = dtr["CREATE_DT"].ToString(), UPDATE_UID = dtr["UPDATE_UID"].ToString(), UPDATE_DT = dtr["UPDATE_DT"].ToString() }; dtFunct.Add(item); } return(dtFunct); }
public static FunctViewModel Recursive(FunctViewModel funct, List <FunctViewModel> functList) { if (functList.Where(c => c.FUNCPARENT == funct.FUNCCODE).Count() < 1) { return(funct); } else { List <FunctViewModel> newList = new List <FunctViewModel>(); foreach (FunctViewModel ca in functList.Where(c => c.FUNCPARENT == funct.FUNCCODE)) { newList.Add(Recursive(ca, functList)); } funct.FunctViewModels = newList; return(funct); } }
public DataTable UpdateFunctions(FunctViewModel functViewModel) { OracleParameter[] param = new OracleParameter[9]; param[0] = new OracleParameter("pFUNCCODE", functViewModel.FUNCCODE) { Direction = ParameterDirection.Input }; param[1] = new OracleParameter("pFUNCNAME", (object)functViewModel.FUNCNAME ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[2] = new OracleParameter("pFUNCPARENT", (object)functViewModel.FUNCPARENT ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[3] = new OracleParameter("pFUNCLEVEL", (object)functViewModel.FUNCLEVEL ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[4] = new OracleParameter("pORDERINDEX", (object)functViewModel.ORDERINDEX) { Direction = ParameterDirection.Input }; param[5] = new OracleParameter("pISACTIVE", (object)functViewModel.ISACTIVE ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[6] = new OracleParameter("pREMARK", (object)functViewModel.REMARK ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[7] = new OracleParameter("pUPDATE_UID", (object)functViewModel.UPDATE_UID ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[8] = new OracleParameter("T_TABLE", OracleDbType.RefCursor) { Direction = ParameterDirection.Output }; return(DBHelper.getDataTable_SP("HR_DEPTFUNCT.SP_UPDATE_T_HR_DEPTFUNCT", param)); }
public DataTable InsertFunctions(FunctViewModel functViewModel) { OracleParameter[] param = new OracleParameter[9]; param[0] = new OracleParameter("pFUNCCODE", functViewModel.FUNCCODE) { Direction = ParameterDirection.Input }; param[1] = new OracleParameter("pFUNCNAME", (object)functViewModel.FUNCNAME ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[2] = new OracleParameter("pFUNCPARENT", (object)functViewModel.FUNCPARENT ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[3] = new OracleParameter("pFUNCLEVEL", (object)functViewModel.FUNCLEVEL ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[4] = new OracleParameter("pORDERINDEX", (object)functViewModel.ORDERINDEX) { Direction = ParameterDirection.Input }; param[5] = new OracleParameter("pISACTIVE", (object)functViewModel.ISACTIVE ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[6] = new OracleParameter("pREMARK", (object)functViewModel.REMARK ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[7] = new OracleParameter("pCREATE_UID", (object)functViewModel.CREATE_UID ?? DBNull.Value) { Direction = ParameterDirection.Input }; param[8] = new OracleParameter("pUPDATE_UID", (object)functViewModel.CREATE_UID ?? DBNull.Value) { Direction = ParameterDirection.Input }; return(DBHelper.getDataTable_SP("HR_DEPTFUNCT.SP_INSERT_NEW_T_HR_DEPTFUNCT", param)); }
public ActionResult UpdateFunction(string functCode, string functParent, string functName, bool active, string orderIndex) { FunctViewModel functViewModel = new FunctViewModel(); functViewModel.FUNCCODE = functCode; functViewModel.FUNCPARENT = functParent; functViewModel.FUNCNAME = functName; functViewModel.FUNCLEVEL = functCode.Substring(0, 1); if (active) { functViewModel.ISACTIVE = "1"; } else { functViewModel.ISACTIVE = "0"; } functViewModel.ORDERINDEX = orderIndex; bFunction.UpdateFunction(functViewModel); Session["function_tree"] = bFunction.getFuncts(); Session["functreport_tree"] = bFunctionReport.getTreeFunctionDepts(); return(PartialView("FunctionInforPartial")); }
public ActionResult AddNewFunction(string functParent, string functName, bool active, string orderIndex) { FunctViewModel functViewModel = new FunctViewModel(); string functCode = bFunction.getNewFunctCode(functParent); if (functParent == null || string.Empty == functParent) { functParent = "000000"; } if (functCode == "-1") { functViewModel.FUNCCODE = functParent; functViewModel.FUNCPARENT = null; functViewModel.FUNCLEVEL = "0"; } else { functViewModel.FUNCPARENT = functParent; functViewModel.FUNCCODE = functCode; functViewModel.FUNCLEVEL = functCode.Substring(0, 1); } functViewModel.FUNCNAME = functName; if (active) { functViewModel.ISACTIVE = "1"; } else { functViewModel.ISACTIVE = "0"; } functViewModel.ORDERINDEX = orderIndex; bFunction.insertFunction(functViewModel); Session["function_tree"] = bFunction.getFuncts(); Session["functreport_tree"] = bFunctionReport.getTreeFunctionDepts(); return(PartialView("FunctionInforPartial")); }
public static KeyValuePair <JObject, List <JObject> > getDataForFuncChart(string funccode) { List <FunctViewModel> functs = new List <FunctViewModel>(); //DUNG DE DUYET LUA CHON NODE HIEN THI. List <ElementViewModel> result = new List <ElementViewModel>(); #region "TAO TAT CA CAC GROUPS" JObject groupElements = new JObject(); FunctAccess access = new FunctAccess(); DataTable dtResult = access.GetChildsByFunccodeIsActive(funccode); foreach (DataRow dtr in dtResult.Rows) { JObject group = new JObject(); group["group"] = true; group["groupName"] = dtr["FUNCNAME"].ToString(); group["groupState"] = ""; group["template"] = "group_grey"; string key = "A" + dtr["FUNCCODE"].ToString(); FunctViewModel item = new FunctViewModel { FUNCCODE = dtr["FUNCCODE"].ToString(), FUNCNAME = dtr["FUNCNAME"].ToString(), FUNCPARENT = dtr["FUNCPARENT"].ToString(), FUNCLEVEL = dtr["FUNCLEVEL"].ToString(), ORDERINDEX = dtr["ORDERINDEX"].ToString(), ISACTIVE = dtr["ISACTIVE"].ToString() }; functs.Add(item); ElementViewModel g = new ElementViewModel { display = true, id = dtr["FUNCCODE"].ToString(), pid = dtr["FUNCPARENT"].ToString() }; result.Add(g); groupElements[key] = group; } //LAY VE NODE TUONG UNG DEPTCODE TUYEN VAO. if (funccode != "-1") { #region "NODE ROOT NEU FUNCCODE !=-1 (LAY TAT CA)" dtResult = access.GetByFuncCodeIsActive(funccode); foreach (DataRow dtr in dtResult.Rows) { int oLevel; int.TryParse(dtr["FUNCLEVEL"].ToString(), out oLevel); JObject group = new JObject(); group["group"] = true; group["groupName"] = dtr["FUNCNAME"].ToString(); group["groupState"] = ""; group["template"] = "group_grey"; string key = "A" + dtr["FUNCCODE"].ToString(); FunctViewModel item = new FunctViewModel { FUNCCODE = dtr["FUNCCODE"].ToString(), FUNCNAME = dtr["FUNCNAME"].ToString(), FUNCPARENT = dtr["FUNCPARENT"].ToString(), FUNCLEVEL = dtr["FUNCLEVEL"].ToString(), ORDERINDEX = dtr["ORDERINDEX"].ToString(), ISACTIVE = dtr["ISACTIVE"].ToString() }; functs.Add(item); ElementViewModel g = new ElementViewModel { display = true, id = dtr["FUNCCODE"].ToString(), pid = dtr["FUNCPARENT"].ToString() }; result.Add(g); groupElements[key] = group; } #endregion } #region "TAO GROUP EMPTY" JObject egroup = new JObject(); egroup["group"] = false; egroup["groupName"] = ""; egroup["groupState"] = ""; egroup["template"] = "empty"; groupElements["empty"] = egroup; #endregion #endregion #region "TAO CAC NODES EMPTY" List <JObject> nodeElements = new List <JObject>(); #region "TAO CAC FUNCTIONER" var empReporter = bEmployeeMasterReport.GeFunctioners(); Dictionary <string, string> funcCodeDeptParents = new Dictionary <string, string>(); //LAY CAC GEO SUPERVISOR foreach (var geo in empReporter) { var dept = result.Where(d => d.id == geo.DEPTCODEFUN).FirstOrDefault(); if (dept == null) { continue; } //DANH DAU KO HIEN THI dept.display = false; var list = result.Where(d => d.pid == dept.id); //TAO MOT NODE SUPERVISOR. JObject group = new JObject(); //CAP NHAT LAI PID TRO VAO GEO SUPERVISOR foreach (var g in list) { g.pid = geo.SYS_EMPID; } group["id"] = geo.SYS_EMPID; var efunc = result.Where(d => d.pid == dept.pid && d.display == false).FirstOrDefault(); if (efunc != null) { var el = empReporter.Where(em => em.DEPTCODEFUN == dept.pid).FirstOrDefault(); if (el != null) { group["pid"] = el.SYS_EMPID; } else { group["pid"] = dept.pid; } } group["tags"] = "[" + "'A" + geo.DEPTCODEFUN + "']"; group["EMPNAME"] = geo.EMPNAME; group["EMPID"] = geo.EMPID; group["EMAIL"] = geo.EMAIL; group["POSITION"] = geo.POSITION; group["IMAGE"] = geo.IMAGE; nodeElements.Add(group); } #endregion //KIEM TRA ROOT CO GEO FUNCTIONER. if (funccode != "-1") { ElementViewModel e = result.Where(d => d.id == funccode && d.display == true).FirstOrDefault(); if (e != null) { JObject rgroup = new JObject(); rgroup["id"] = e.id; rgroup["pid"] = e.pid; rgroup["tags"] = "[" + "'empty','A" + funccode + "']"; rgroup["EMPNAME"] = ""; rgroup["EMPID"] = ""; rgroup["EMAIL"] = ""; rgroup["POSITION"] = ""; rgroup["IMAGE"] = ""; nodeElements.Add(rgroup); } } foreach (var d in functs) { ElementViewModel node = result.Where(dp => dp.id == d.FUNCCODE && dp.display == true).FirstOrDefault(); if (node != null) { JObject group = new JObject(); group["id"] = node.id; group["pid"] = node.pid; group["tags"] = "[" + "'empty','A" + d.FUNCCODE + "']"; group["EMPNAME"] = ""; group["EMPID"] = ""; group["EMAIL"] = ""; group["POSITION"] = ""; group["IMAGE"] = ""; nodeElements.Add(group); } } #endregion KeyValuePair <JObject, List <JObject> > data = new KeyValuePair <JObject, List <JObject> >(groupElements, nodeElements); return(data); }
public static EmployeeMaster getEmployeeByEmpId(string empId) { List <EmployeeMaster> dtEmployees = new List <EmployeeMaster>(); EmployeeMasterAccess access = new EmployeeMasterAccess(); DataTable dtResult = access.GetEmployeeByEmpID(empId); foreach (DataRow dtr in dtResult.Rows) { string a = dtr["BIRTHDATE"].ToString().Trim(); //a = "20191003"; string b = dtr["DATEJOIN"].ToString().Trim(); //b = "20150201"; DateTime aa; DateTime bb; if (a == "00000000" || string.IsNullOrEmpty(a)) { aa = DateTime.Now; } else { if (a.Substring(0, 4) == "0000" || a.Substring(4, 2) == "00" || a.Substring(6, 2) == "00") { aa = DateTime.Now; } else { try { aa = DateTime.ParseExact(a, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture); } catch { aa = DateTime.Now; } } } if (b == "00000000" || string.IsNullOrEmpty(b)) { bb = DateTime.Now; } else { if (b.Substring(0, 4) == "0000" || b.Substring(4, 2) == "00" || b.Substring(6, 2) == "00") { bb = DateTime.Now; } else { try { bb = DateTime.ParseExact(b, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture); } catch { bb = DateTime.Now; } } } string imgPath = dtr["IMAGE"].ToString(); if (string.IsNullOrEmpty(imgPath)) { imgPath = "/FileServer/Photos/default.jpg"; } else if (!IsFileExists(imgPath)) { imgPath = "/FileServer/Photos/default.jpg"; } EmployeeMaster item = new EmployeeMaster { SYS_EMPID = dtr["SYS_EMPID"].ToString(), EMPID = dtr["EMPID"].ToString(), EMPNAME = dtr["EMPNAME"].ToString(), COMPCODE = dtr["COMPCODE"].ToString(), DEPTCODE = dtr["DEPTCODE"].ToString(), FUNCDEPT = dtr["FUNCDEPT"].ToString(), JOBCODE = dtr["JOBCODE"].ToString(), JOBFIELD = dtr["JOBFIELD"].ToString(), DUTY = dtr["DUTY"].ToString(), BIRTHDATE = aa,//DateTime.ParseExact(dtr["BIRTHDATE"].ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), BIRTHPLACE = dtr["BIRTHPLACE"].ToString(), GENDER = dtr["GENDER"].ToString(), STATUS = dtr["STATUS"].ToString(), EMAIL = dtr["EMAIL"].ToString(), PHONE = dtr["PHONE"].ToString(), NATIONALITY = dtr["NATIONALITY"].ToString(), DATEJOIN = bb,//DateTime.ParseExact(dtr["DATEJOIN"].ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture), IDENTITYCARD = dtr["UID_FOR_MES"].ToString(), IDISSUEDPLACE = dtr["IDISSUEDPLACE"].ToString(), IDISSUEDDATE = dtr["IDISSUEDDATE"].ToString(), ACADEMIC = dtr["ACADEMIC"].ToString(), DATERESIGNED = dtr["DATERESIGNED"].ToString(), FINGERPRINT = dtr["FINGERPRINT"].ToString(), FINGERINDEX = dtr["FINGERINDEX"].ToString(), IMAGE = imgPath, POSITION = dtr["POSITION"].ToString(), SKILL = dtr["SKILL"].ToString(), SYS_EMPIDOLD = dtr["SYS_EMPIDOLD"].ToString(), CREATE_UID = dtr["CREATE_UID"].ToString(), CREATE_DT = dtr["CREATE_DT"].ToString(), UPDATE_UID = dtr["UPDATE_UID"].ToString(), UPDATE_DT = dtr["UPDATE_DT"].ToString(), }; dtEmployees.Add(item); } if (dtEmployees.Count() > 0) { List <DeptViewModel> depts = bDept.getActivedDepts(); //Process display depcode in employee. DeptViewModel deptOfEmployee = depts.Where(d => d.DEPTCODE == dtEmployees[0].DEPTCODE).FirstOrDefault(); if (deptOfEmployee != null) { DeptViewModel iter = deptOfEmployee; List <string> list = new List <string>(); while (iter != null) { list.Add(iter.DEPTNAME); iter = depts.Where(d => d.DEPTCODE == iter.DEPTPARENT).FirstOrDefault(); } list.Reverse(); dtEmployees[0].DISPLAYDEPTCODE = string.Join(" > ", list.ToArray()); if (string.IsNullOrEmpty(dtEmployees[0].IMAGE)) { dtEmployees[0].IMAGE = "default.jpg"; } } //Process informations involve this employee. List <EmployeeMasterReport> employeeMasterReport = bEmployeeMasterReport.getEmployeeReportBySysEmpID(dtEmployees[0].SYS_EMPID); if (employeeMasterReport.Count > 0) { string SYS_EMPIDGEO = employeeMasterReport[0].SYS_EMPIDGEO; string SYS_EMPIDFUN = employeeMasterReport[0].SYS_EMPIDFUN; string DEPTCODEGEO = employeeMasterReport[0].DEPTCODEGEO; string DEPTCODEFUN = employeeMasterReport[0].DEPTCODEFUN; dtEmployees[0].GEODIRECTREPORT = SYS_EMPIDGEO; dtEmployees[0].GEOGRAPHICALORG = DEPTCODEGEO; dtEmployees[0].FUNCTIONALORG = DEPTCODEFUN; dtEmployees[0].FUNCDIRECTREPORT = SYS_EMPIDFUN; DeptViewModel dept = depts.Where(d => d.DEPTCODE == DEPTCODEGEO).FirstOrDefault(); if (dept != null) { DeptViewModel iter = dept; List <string> list = new List <string>(); while (iter != null) { list.Add(iter.DEPTNAME); iter = depts.Where(d => d.DEPTCODE == iter.DEPTPARENT).FirstOrDefault(); } list.Reverse(); dtEmployees[0].DISPLAYGEOGRAPHICALORG = string.Join(" > ", list.ToArray()); } List <FunctViewModel> functs = bFunction.getFunctions(); FunctViewModel funct = functs.Where(f => f.FUNCCODE == DEPTCODEFUN).FirstOrDefault(); if (funct != null) { FunctViewModel iterf = funct; List <string> list = new List <string>(); while (iterf != null) { list.Add(iterf.FUNCNAME); iterf = functs.Where(f => f.FUNCCODE == iterf.FUNCPARENT).FirstOrDefault(); } list.Reverse(); dtEmployees[0].DISPLAYFUNCTIONALORG = string.Join(" > ", list.ToArray()); } //Display geo user, funct user. //List<EmployeeMaster> es = getAllEmployees(); EmployeeMaster eg = getEmployeeBySysEmpid(SYS_EMPIDGEO); //EmployeeMaster eg = es.Where(ep => ep.SYS_EMPID == SYS_EMPIDGEO).FirstOrDefault(); if (eg != null) { dtEmployees[0].DISPLAYGEODIRECTREPORT = eg.EMPNAME; dtEmployees[0].GEOEMPIDREPORT = eg.EMPID; } //EmployeeMaster ef = es.Where(ep => ep.SYS_EMPID == SYS_EMPIDFUN).FirstOrDefault(); EmployeeMaster ef = getEmployeeBySysEmpid(SYS_EMPIDFUN); if (ef != null) { dtEmployees[0].DISPLAYFUNCDIRECTREPORT = ef.EMPNAME; dtEmployees[0].FUNEMPIDREPORT = ef.EMPID; } } return(dtEmployees[0]); } return(null); }
public ActionResult AddNewFunction() { FunctViewModel functViewModel = new FunctViewModel(); return(View(functViewModel)); }
public static void UpdateFunction(FunctViewModel functViewModel) { FunctAccess access = new FunctAccess(); access.UpdateFunctions(functViewModel); }
public static void insertFunction(FunctViewModel functViewModel) { FunctAccess access = new FunctAccess(); access.InsertFunctions(functViewModel); }