Ejemplo n.º 1
0
        public static List <GeoReport> getAllGeoReports()
        {
            List <GeoReport> geoReports = new List <GeoReport>();
            GeoReportAccess  access     = new GeoReportAccess();
            DataTable        dtResult   = access.GetGeoReports();

            foreach (DataRow dtr in dtResult.Rows)
            {
                GeoReport item = new GeoReport
                {
                    GEOREPORTCD    = dtr["GEOREPORTCD"].ToString(),
                    DEPTCODE       = dtr["DEPTCODE"].ToString(),
                    SYS_EMPID      = dtr["SYS_EMPID"].ToString(),
                    APPLYDATE      = DateTime.Parse(string.IsNullOrEmpty(dtr["APPLYDATE"].ToString()) ? "1-1-1999" : dtr["APPLYDATE"].ToString()),
                    ISACTIVE       = dtr["ISACTIVE"].ToString(),
                    POSITION       = dtr["POSITION"].ToString(),
                    SKILL          = dtr["SKILL"].ToString(),
                    REMARK         = dtr["REMARK"].ToString(),
                    GEOREPORTLEVEL = dtr["GEOREPORTLEVEL"].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(),
                };
                geoReports.Add(item);
            }
            return(geoReports);
        }
Ejemplo n.º 2
0
        //public ActionResult getGeoReportByDept([DataSourceRequest]DataSourceRequest request, string deptcode)
        //{
        //    List<eGeoReportItem> result = new List<eGeoReportItem>();
        //    result = bGeoReport.getGeoReportByDepartment(deptcode);
        //    return Json(result.ToDataSourceResult(request));
        //}

        public ActionResult getGeoReportByDept([DataSourceRequest] DataSourceRequest request, string deptcode)
        {
            List <eGeoReportItem> result = new List <eGeoReportItem>();

            result = bGeoReport.getGeoReportByDepartment(deptcode);

            DataTable  dtResult   = GeoReportAccess.getReportByDepartment(deptcode);
            string     jsonString = JsonConvert.SerializeObject(dtResult);
            JsonResult jsResult   = new JsonResult();

            jsResult = Json(dtResult.ToDataSourceResult(request));
            DataTable dtTest = (DataTable)JsonConvert.DeserializeObject(jsonString, (typeof(DataTable)));

            //return jsResult;
            //return jsonResult;

            /*
             * DataRow dtr = dtResult.Rows[0];
             * eGeoReportItem item = new eGeoReportItem();
             * foreach(DataColumn cl in dtr.Table.Columns)
             * {
             *  PropertyInfo prop = item.GetType().GetProperty(cl.ColumnName);
             *  FieldInfo fld = item.GetType().GetField(cl.ColumnName);
             * }
             */

            return(Json(dtTest.ToDataSourceResult(request)));
        }
Ejemplo n.º 3
0
        public ActionResult createGeoReporter([DataSourceRequest] DataSourceRequest request, eGeoReportItem _reporter, string deptcode)
        {
            //FormEntity formEntity = new FormEntity();
            //formEntity.FormID = _form.FORM_CODE;
            //formEntity.FormName = _form.FORM_NAME;
            //formEntity.DictionaryID = "";
            //formEntity.CREATE_UID = "hieuht";
            //formEntity.FilePath = _form.FILE_PATH;
            //formEntity.ModuleID = "";
            //bool result = FormAccess.InsertForm(formEntity);
            _reporter.DEPTCODE = deptcode;
            string    userId   = Session["UserId"].ToString();
            DataTable dtResult = GeoReportAccess.insertNewGeoReport(_reporter, userId);

            Session["geoorganizationreport_tree"] = bGeoReport.getTreeGeoDepts();
            dynamic res = string.Empty;

            res = new
            {
                result  = dtResult.Rows[0][0].ToString(),
                message = dtResult.Rows[0][1].ToString()
            };
            return(Json(new[] { _reporter, res }.ToDataSourceResult(request, ModelState)));
            //return Json("ok", JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 4
0
        public static List <JObject> getSupervisorDataForChart(string deptCode)
        {
            List <JObject> elements     = new List <JObject>();
            DataTable      dtResult     = GeoReportAccess.GetSupervisorByDeptCode(deptCode);
            string         sys_empidgeo = string.Empty;

            foreach (DataRow dtr in dtResult.Rows)
            {
                sys_empidgeo = dtr["SYS_EMPIDGEO"].ToString();
            }
            if (!string.IsNullOrEmpty(sys_empidgeo))
            {
                DataTable geos = GeoReportAccess.GetSupervisorsBySysGeo(sys_empidgeo);
                foreach (DataRow dtr in geos.Rows)
                {
                    JObject subSupervisor = new JObject();
                    subSupervisor["id"]       = dtr["SYS_EMPID"].ToString();
                    subSupervisor["pid"]      = dtr["SYS_EMPIDGEO"].ToString();
                    subSupervisor["EMPID"]    = dtr["EMPID"].ToString();
                    subSupervisor["EMPNAME"]  = dtr["EMPNAME"].ToString();
                    subSupervisor["DEPTNAME"] = dtr["DEPTNAME"].ToString();
                    subSupervisor["POSITION"] = dtr["POSITION"].ToString();
                    subSupervisor["EMAIL"]    = dtr["EMAIL"].ToString();
                    string imggPath = dtr["IMAGE"].ToString();
                    if (string.IsNullOrEmpty(imggPath))
                    {
                        imggPath = "/FileServer/Photos/default.jpg";
                    }
                    else if (!IsFileExists(imggPath))
                    {
                        imggPath = "/FileServer/Photos/default.jpg";
                    }
                    subSupervisor["IMAGE"] = imggPath;// dtr["IMAGE"].ToString();
                    elements.Add(subSupervisor);
                }
                //Get root.
                EmployeeMaster root           = bEmployeeMaster.getEmployeeBySysEmpid(sys_empidgeo);
                JObject        rootSupervisor = new JObject();
                rootSupervisor["id"]       = sys_empidgeo;
                rootSupervisor["pid"]      = "null";
                rootSupervisor["EMPID"]    = root.EMPID;
                rootSupervisor["EMPNAME"]  = root.EMPNAME;
                rootSupervisor["DEPTNAME"] = root.DEPTNAME;
                rootSupervisor["POSITION"] = root.POSITION;
                rootSupervisor["EMAIL"]    = root.EMAIL;
                string imgPath = root.IMAGE;
                if (string.IsNullOrEmpty(imgPath))
                {
                    imgPath = "/FileServer/Photos/default.jpg";
                }
                else if (!IsFileExists(imgPath))
                {
                    imgPath = "/FileServer/Photos/default.jpg";
                }
                rootSupervisor["IMAGE"] = imgPath;
                elements.Add(rootSupervisor);
            }
            return(elements);
        }
Ejemplo n.º 5
0
        //Version 2.0 for improving performance.
        public static List <GeoDeptViewModel> getGeoDeptReportsRegistered()
        {
            List <GeoDeptViewModel> geoReports = new List <GeoDeptViewModel>();
            GeoReportAccess         access     = new GeoReportAccess();
            DataTable dtResult = access.GetTreeGeoReportsRegistered();

            foreach (DataRow dtr in dtResult.Rows)
            {
                GeoDeptViewModel item = new GeoDeptViewModel
                {
                    GEOREPORTCD = dtr["GEOREPORTCD"].ToString(),
                    DEPTNAME    = dtr["DEPTNAME"].ToString(),
                    DEPTCODE    = dtr["DEPTCODE"].ToString(),
                    DEPTPARENT  = dtr["DEPTPARENT"].ToString()
                };
                geoReports.Add(item);
            }
            return(geoReports);
        }
Ejemplo n.º 6
0
        public static List <EmployeeMaster> getUserInGeoReportByDeptCode(string deptCode, string empid)
        {
            List <EmployeeMaster> userList = new List <EmployeeMaster>();
            GeoReportAccess       access   = new GeoReportAccess();
            DataTable             dtResult = access.GetUserGeoReports(deptCode, empid);

            foreach (DataRow dtr in dtResult.Rows)
            {
                EmployeeMaster item = new EmployeeMaster
                {
                    SYS_EMPID = dtr["SYS_EMPID"].ToString(),
                    EMPNAME   = dtr["EMPNAME"].ToString(), //+ "," + dtr["SYS_EMPID"].ToString(),
                    DEPTCODE  = dtr["DEPTCODE"].ToString(),
                    EMPID     = dtr["EMPID"].ToString()
                };
                userList.Add(item);
            }
            return(userList);
        }
Ejemplo n.º 7
0
        public static List <OriganizationUsersViewModel> getUsersGeoDeptReports()
        {
            List <OriganizationUsersViewModel> geoReports = new List <OriganizationUsersViewModel>();
            GeoReportAccess access   = new GeoReportAccess();
            DataTable       dtResult = access.GetTreeGeoReports();

            foreach (DataRow dtr in dtResult.Rows)
            {
                OriganizationUsersViewModel item = new OriganizationUsersViewModel
                {
                    Display     = dtr["DEPTNAME"].ToString(),
                    Key         = dtr["REPORTCD"].ToString(),
                    Flag        = 0,
                    GEOREPORTCD = dtr["REPORTCD"].ToString(),
                    SYS_EMPID   = dtr["SYS_EMPID"].ToString(),
                    DEPTNAME    = dtr["DEPTNAME"].ToString(),
                    DEPTCODE    = dtr["DEPTCODE"].ToString(),
                    DEPTPARENT  = dtr["DEPTPARENT"].ToString()
                };
                geoReports.Add(item);
            }
            return(geoReports);
        }
Ejemplo n.º 8
0
        public static List <eGeoReportItem> getGeoReportByDepartment(string deptcode)
        {
            List <eGeoReportItem> lstResult = new List <eGeoReportItem>();
            DataTable             dtResult  = GeoReportAccess.getReportByDepartment(deptcode);

            /*
             * foreach (DataRow dtr in dtResult.Rows)
             * {
             *  eGeoReportItem item = new eGeoReportItem();
             *  item.GEOREPORTCD = dtr["GEOREPORTCD"].ToString();
             *  item.DEPTCODE = dtr["DEPTCODE"].ToString();
             *  item.SYS_EMPID = dtr["SYS_EMPID"].ToString();
             *  string strDate = dtr["APPLYDATE"].ToString();
             *  item.APPLYDATE = DateTime.ParseExact(strDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
             *  item.ISACTIVE = dtr["ISACTIVE"].ToString();
             *  item.EMPNAME = dtr["EMPNAME"].ToString();
             *  lstResult.Add(item);
             * }
             */

            foreach (DataRow dtr in dtResult.Rows)
            {
                eGeoReportItem item = new eGeoReportItem();
                item.GEOREPORTCD = dtr["GEOREPORTCD"].ToString();
                item.DEPTCODE    = dtr["DEPTCODE"].ToString();
                item.SYS_EMPID   = dtr["SYS_EMPID"].ToString();
                string strDate = dtr["APPLYDATE"].ToString();
                item.APPLYDATE = DateTime.ParseExact(strDate, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);
                int nActive = 0;
                int.TryParse(dtr["ISACTIVE"].ToString(), out nActive);
                item.ISACTIVE = Convert.ToBoolean(nActive);
                item.EMPNAME  = dtr["EMPNAME"].ToString();
                lstResult.Add(item);
            }

            return(lstResult);
        }
Ejemplo n.º 9
0
        public static List <JObject> getSupervisorDataForChartV2(string deptCode)
        {
            List <JObject> elements     = new List <JObject>();
            DataTable      dtResult     = GeoReportAccess.GetSupervisorByDeptCode(deptCode);
            List <string>  sys_empidgeo = new List <string>();
            string         sys_parent   = string.Empty;

            if (dtResult.Rows.Count > 1)
            {
                DeptAccess deptAccess = new DeptAccess();
                DataTable  depResult  = deptAccess.GetByDeptCodeIsActive(deptCode);
                foreach (DataRow dtr in depResult.Rows)
                {
                    JObject rootSupervisor = new JObject();
                    rootSupervisor["id"]       = dtr["DEPTCODE"].ToString();
                    rootSupervisor["pid"]      = "null";
                    rootSupervisor["EMPID"]    = "";
                    rootSupervisor["EMPNAME"]  = "";
                    rootSupervisor["DEPTNAME"] = dtr["DEPTNAME"].ToString();
                    rootSupervisor["POSITION"] = "";
                    rootSupervisor["EMAIL"]    = "";
                    rootSupervisor["IMAGE"]    = "/FileServer/Photos/default.jpg";
                    elements.Add(rootSupervisor);
                    sys_parent = dtr["DEPTCODE"].ToString();
                    break;
                }
            }
            foreach (DataRow dtr in dtResult.Rows)
            {
                if (!sys_empidgeo.Contains(dtr["SYS_EMPIDGEO"].ToString()))
                {
                    sys_empidgeo.Add(dtr["SYS_EMPIDGEO"].ToString());
                }
            }
            if (sys_empidgeo != null && sys_empidgeo.Count() > 0)
            {
                foreach (var sys_geo in sys_empidgeo)
                {
                    DataTable geos = GeoReportAccess.GetSupervisorsBySysGeo(sys_geo);
                    foreach (DataRow dtr in geos.Rows)
                    {
                        JObject subSupervisor = new JObject();
                        subSupervisor["id"]       = dtr["SYS_EMPID"].ToString();
                        subSupervisor["pid"]      = dtr["SYS_EMPIDGEO"].ToString();
                        subSupervisor["EMPID"]    = dtr["EMPID"].ToString();
                        subSupervisor["EMPNAME"]  = dtr["EMPNAME"].ToString();
                        subSupervisor["DEPTNAME"] = dtr["DEPTNAME"].ToString();
                        subSupervisor["POSITION"] = dtr["POSITION"].ToString();
                        subSupervisor["EMAIL"]    = dtr["EMAIL"].ToString();
                        string imgsPath = dtr["IMAGE"].ToString();
                        if (string.IsNullOrEmpty(imgsPath))
                        {
                            imgsPath = "/FileServer/Photos/default.jpg";
                        }
                        else if (!IsFileExists(imgsPath))
                        {
                            imgsPath = "/FileServer/Photos/default.jpg";
                        }
                        subSupervisor["IMAGE"] = imgsPath;// dtr["IMAGE"].ToString();
                        elements.Add(subSupervisor);
                    }
                    //Get root.
                    EmployeeMaster root           = bEmployeeMaster.getEmployeeBySysEmpid(sys_geo);
                    JObject        rootSupervisor = new JObject();
                    rootSupervisor["id"]       = sys_geo;
                    rootSupervisor["pid"]      = sys_parent;
                    rootSupervisor["EMPID"]    = root.EMPID;
                    rootSupervisor["EMPNAME"]  = root.EMPNAME;
                    rootSupervisor["DEPTNAME"] = root.DEPTNAME;
                    rootSupervisor["POSITION"] = root.POSITION;
                    rootSupervisor["EMAIL"]    = root.EMAIL;
                    string imgPath = root.IMAGE;
                    if (string.IsNullOrEmpty(imgPath))
                    {
                        imgPath = "/FileServer/Photos/default.jpg";
                    }
                    else if (!IsFileExists(imgPath))
                    {
                        imgPath = "/FileServer/Photos/default.jpg";
                    }
                    rootSupervisor["IMAGE"] = imgPath;
                    elements.Add(rootSupervisor);
                }
            }
            if (elements.Count() == 0)
            {
                DeptAccess deptAccess = new DeptAccess();
                DataTable  depResult  = deptAccess.GetByDeptCodeIsActive(deptCode);
                foreach (DataRow dtr in depResult.Rows)
                {
                    JObject rootSupervisor = new JObject();
                    rootSupervisor["id"]       = dtr["DEPTCODE"].ToString();
                    rootSupervisor["pid"]      = "null";
                    rootSupervisor["EMPID"]    = "";
                    rootSupervisor["EMPNAME"]  = "Doesn't have SUPERVISOR";
                    rootSupervisor["DEPTNAME"] = dtr["DEPTNAME"].ToString();
                    rootSupervisor["POSITION"] = "";
                    rootSupervisor["EMAIL"]    = "";
                    rootSupervisor["IMAGE"]    = "/FileServer/Photos/default.jpg";
                    elements.Add(rootSupervisor);
                    sys_parent = dtr["DEPTCODE"].ToString();
                    break;
                }
            }
            return(elements);
        }