public static T_COM_Master_EntityCollection Search(SearchFilter value)
        {
            T_COM_Master_EntityCollection items = new T_COM_Master_EntityCollection();
            string key = string.Format(SETTINGS_Search_KEY, value.Keyword, value.Page, value.PageSize, value.OrderBy, value.OrderDirection);

            if (SystemConfig.AllowSearchCache)
            {
                object obj2 = HttpCache.Get(key);

                if ((obj2 != null))
                {
                    return((T_COM_Master_EntityCollection)obj2);
                }
            }

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.PostAsJsonAsync(Resource + "?method=search", value).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <T_COM_Master_EntityCollection>().GetAwaiter().GetResult();
                }
            }

            if (SystemConfig.AllowSearchCache)
            {
                HttpCache.Max(key, items);
            }
            return(items);
        }
        public static T_COM_Master_EntityCollection GetAll()
        {
            T_COM_Master_EntityCollection items = new T_COM_Master_EntityCollection();

            string key  = String.Format(SETTINGS_ALL_KEY, CustomerAuthorize.CurrentUser.EmployeeCode);
            object obj2 = HttpCache.Get(key);

            if ((obj2 != null))
            {
                return((T_COM_Master_EntityCollection)obj2);
            }
            T_COM_Master_EntityCollection filter = new T_COM_Master_EntityCollection();

            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.GetAsync(Resource).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <T_COM_Master_EntityCollection>().GetAwaiter().GetResult();
                }
            }
            if (items.Count > 0 && CustomerAuthorize.CurrentUser != null)
            {
                foreach (T_COM_Master_Entity b in items)
                {
                    if (CustomerAuthorize.CurrentUser.EntityID == b.EntityId)
                    {
                        filter.Add(b);
                    }
                }
            }
            HttpCache.Max(key, filter);
            return(items);
        }
        public ContentResult Search(SearchFilter SearchKey)
        {
            SearchKey.OrderBy = string.IsNullOrEmpty(SearchKey.OrderBy) ? "EntityId" : SearchKey.OrderBy;
            T_COM_Master_EntityCollection collection = T_COM_Master_EntityManager.Search(SearchKey);

            return(Content(JsonConvert.SerializeObject(collection), "application/json"));
        }
        public JsonResult GetGata([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            SearchFilter SearchKey = SearchFilter.SearchData(CurrentUser.CompanyID, requestModel, "ID", "ID");
            T_COM_Master_EntityCollection EntityAllows = T_COM_Master_EntityManager.GetAllByEmployeeCode(CurrentUser.EmployeeCode);

            T_COM_Master_Entity entity;

            if (EntityAllows.Count > 0)
            {
                SearchKey.Condition += " (Entity_Id in ( ";
                for (int i = 0; i < EntityAllows.Count; i++)
                {
                    entity = EntityAllows[i];
                    SearchKey.Condition += " '" + entity.EntityId + "'  ";
                    if (i != EntityAllows.Count - 1)
                    {
                        SearchKey.Condition += " , ";
                    }
                }
                SearchKey.Condition += ") ) ";
            }

            T_CMS_Master_InternshipCollection collection = T_CMS_Master_InternshipManager.Search(SearchKey);
            int TotalRecord = 0;

            if (collection.Count > 0)
            {
                TotalRecord = collection[0].TotalRecord;
            }
            return(Json(new DataTablesResponse(requestModel.Draw, collection, TotalRecord, TotalRecord), JsonRequestBehavior.AllowGet));
        }
        /// <summary>
        /// use for scrolling page
        /// </summary>
        /// <returns></returns>
        public ContentResult GetPg(int page, int pagesize)
        {
            string       condition = "";
            SearchFilter SearchKey = SearchFilter.SearchPG(1, page, pagesize, "EntityId", "EntityId", "Desc", condition);
            T_COM_Master_EntityCollection objItem = T_COM_Master_EntityManager.Search(SearchKey);

            return(Content(JsonConvert.SerializeObject(objItem), "application/json"));
        }
        public JsonResult GetGata([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            SearchFilter SearchKey = SearchFilter.SearchData(1, requestModel, "EntityId", "EntityId");
            T_COM_Master_EntityCollection collection = T_COM_Master_EntityManager.Search(SearchKey);
            int TotalRecord = 0;

            if (collection.Count > 0)
            {
                TotalRecord = collection[0].TotalRecord;
            }
            return(Json(new DataTablesResponse(requestModel.Draw, collection, TotalRecord, TotalRecord), JsonRequestBehavior.AllowGet));
        }
Exemple #7
0
        public static T_COM_Master_EntityCollection GetbyEmployeeCode(int EmployeeCode)
        {
            T_COM_Master_EntityCollection collection = new T_COM_Master_EntityCollection();
            T_COM_Master_Entity           obj;

            using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, "T_COM_Master_Entity_GetAll_byEmployeeCode", new SqlParameter("@EmployeeCode", EmployeeCode)))
            {
                while (reader.Read())
                {
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Exemple #8
0
        public static T_COM_Master_EntityCollection Search(SearchFilter SearchKey)
        {
            T_COM_Master_EntityCollection collection = new T_COM_Master_EntityCollection();

            using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, "T_COM_Master_Entity_Search", SearchFilterManager.SqlSearchParamNoCompany(SearchKey)))
            {
                while (reader.Read())
                {
                    T_COM_Master_Entity obj = new T_COM_Master_Entity();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
Exemple #9
0
        public static T_COM_Master_EntityCollection GetAllItem()
        {
            T_COM_Master_EntityCollection collection = new T_COM_Master_EntityCollection();

            using (var reader = SqlHelper.ExecuteReaderService(ModuleConfig.MyConnection, "T_COM_Master_Entity_GetAll", null))
            {
                while (reader.Read())
                {
                    T_COM_Master_Entity obj = new T_COM_Master_Entity();
                    obj = GetItemFromReader(reader);
                    collection.Add(obj);
                }
            }
            return(collection);
        }
        /// <summary>
        /// ExportExcel File
        /// </summary>
        /// <returns></returns>
        public string ExportExcel()
        {
            T_COM_Master_EntityCollection collection = T_COM_Master_EntityManager.GetAll();
            DataTable dt       = collection.ToDataTable <T_COM_Master_Entity>();
            string    fileName = "T_COM_Master_Entity_" + SystemConfig.CurrentDate.ToString("MM-dd-yyyy");

            string[] RemoveColumn = { "CompanyID", "TargetDisplayID", "ReturnDisplay", "TotalRecord", "CreatedUser", "CreatedDate" };
            for (int i = 0; i < RemoveColumn.Length; i++)
            {
                if (dt.Columns.Contains(RemoveColumn[i]))
                {
                    dt.Columns.Remove(RemoveColumn[i]);
                }
            }
            FileInputHelper.ExportExcel(dt, fileName, "T_COM_Master_Entity List", false);
            return(fileName);
        }
        public static T_COM_Master_EntityCollection GetAllByEmployeeCode(int EmployeeCode)
        {
            T_COM_Master_EntityCollection items = new T_COM_Master_EntityCollection();

            string key  = String.Format(SETTINGS_User_KEY, EmployeeCode.ToString());
            object obj2 = HttpCache.Get(key);

            if ((obj2 != null))
            {
                return((T_COM_Master_EntityCollection)obj2);
            }
            using (var client = WebApiHelper.myclient(HouseEndpoint, SystemConst.APIJosonReturnValue))
            {
                HttpResponseMessage response = client.GetAsync(string.Format(Resource + "/GetbyEmployeeCode?EmployeeCode={0}", EmployeeCode)).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    items = response.Content.ReadAsAsync <T_COM_Master_EntityCollection>().GetAwaiter().GetResult();
                }
            }
            HttpCache.Max(key, items);
            return(items);
        }
Exemple #12
0
        public static T_CMS_Master_InternshipCollection ImportData(IEnumerable <T_CMS_Master_Internship> objItemList, int EmployeeCode)
        {
            T_COm_Master_Org            objOrg;
            T_CMS_Master_WorkHours      objWH;
            T_COM_Master_University     objUni;
            T_CMS_Master_EmploymentType objEmpType;
            //T_CMS_Master_EmploymentTypeCollection objEmpTypes;
            T_CMS_Master_EmploymentSubType    objEmpSubType;
            T_CMS_Master_InternshipCollection ErrorList = new T_CMS_Master_InternshipCollection();
            int    SaluationID = 1;
            bool   isError     = false;
            string strError    = "";
            string EntityList  = "";
            T_COM_Master_EntityCollection EntityAllows = T_COM_Master_EntityManager.GetAllByEmployeeCode(EmployeeCode);

            foreach (T_COM_Master_Entity entity in EntityAllows)
            {
                EntityList += entity.EntityId + ";";
            }
            foreach (T_CMS_Master_Internship objitem in objItemList)
            {
                isError  = false;
                strError = "";
                try
                {
                    objOrg = T_COm_Master_OrgManager.GetByOrgName(objitem.DepartCD);
                    objWH  = T_CMS_Master_WorkHoursManager.GetByWorkHours(objitem.WorkHoursCD);

                    if (objWH.WorkHoursID == 0)
                    {
                        strError += "<div>Invalid  Work Hours Name: <span class='impval'>" + objitem.WorkHoursCD + "</span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Work Hours Name:" + objitem.WorkHoursCD));
                        isError = true;
                    }
                    if (objOrg.OrgId == 0)
                    {
                        strError += "<div>Invalid  Depart Name: <span class='impval'>" + objitem.DepartCD + "</span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Work Hours Name:" + objitem.WorkHoursCD));
                        isError = true;
                    }
                    if (!string.IsNullOrEmpty(objitem.UniversityCD))
                    {
                        objUni = T_COM_Master_UniversityManager.GetByName(objitem.UniversityCD);
                        if (objUni.UniversityID == 0)
                        {
                            strError += "<div>Invalid  University Name: <span class='impval'>" + objitem.UniversityCD + "</span></div>";
                            //ErrorList.Add(AddErrorMessage(objitem, "Invalid Work Hours Name:" + objitem.WorkHoursCD));
                            isError = true;
                        }
                        else
                        {
                            objitem.UniversityID = objUni.UniversityID;
                        }
                    }

                    if (EntityList.IndexOf(objOrg.Entity_Id.ToString()) == -1)
                    {
                        strError += "<div>You don't have Permission to Import to this Group: <span class='impval'>" + objitem.DepartCD + " </span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Grade Name:" + objitem.GradeName));
                        isError = true;
                    }
                    if (isError)
                    {
                        objitem.ErrorMesssage += "<div>" + strError + "</div>";
                        ErrorList.Add(objitem);
                        continue;
                    }


                    if (objitem.SalutationCD.IndexOf("Ms") != -1)
                    {
                        objitem.StatusID = 2;
                    }
                    else if (objitem.SalutationCD.IndexOf("Mrs") != -1)
                    {
                        objitem.StatusID = 3;
                    }
                    else
                    {
                        objitem.StatusID = 1;
                    }
                    //get emp subtype by entity and internship
                    objEmpType = T_CMS_Master_EmploymentTypeManager.GetAllByEntityID(objOrg.Entity_Id, "I");


                    if (objEmpType != null)
                    {
                        objitem.EmpTypeID = objEmpType.EmpTypeID;
                        objEmpSubType     = T_CMS_Master_EmploymentSubTypeManager.GetEmpTypeID(objEmpType.EmpTypeID, "Intern");
                        if (objEmpSubType != null)
                        {
                            objitem.EmpSubTypeID = objEmpSubType.EmpSubTypeID;
                        }
                    }
                    DateTime enddate = objitem.Joiningdate.AddMonths(objitem.PeriodofInternship);
                    enddate             = enddate.AddDays(-1);
                    objitem.Enddate     = enddate;
                    objitem.DeptID      = objOrg.OrgId;
                    objitem.WorkHours   = objWH.WorkHoursID;
                    objitem.CreatedBy   = EmployeeCode;
                    objitem.CreatedDate = SystemConfig.CurrentDate;
                    Add(objitem);
                }
                catch (Exception ObjEx)
                {
                    objitem.ErrorMesssage += "<div>" + ObjEx.Message + "</div>";
                    ErrorList.Add(objitem);
                }
            }
            return(ErrorList);
        }
Exemple #13
0
        /// <summary>
        /// import data from excel file
        /// </summary>
        /// <param name="objItem"></param>
        /// <returns>return the error Import List</returns>
        public static T_CMS_Master_ContractCollection ImportData(IEnumerable <T_CMS_Master_Contract> objItemList, int EmployeeCode)
        {
            T_COm_Master_Org               objOrg;
            T_COM_Master_Grade             objGrade;
            T_COM_Master_Position          objPosition;
            T_CMS_Master_WorkHours         objWH;
            T_COM_Master_PlaceOfIssue      objPOI;
            T_CMS_Master_EmploymentSubType objEmpSubType;
            int SaluationID = 1;
            T_CMS_Master_ContractCollection ErrorList = new T_CMS_Master_ContractCollection();
            bool   isError  = false;
            string strError = "";
            T_CMS_Master_EmploymentType   objEmpType;
            T_COM_Master_EntityCollection EntityAllows = T_COM_Master_EntityManager.GetAllByEmployeeCode(EmployeeCode);
            string EntityList = "";

            foreach (T_COM_Master_Entity entity in EntityAllows)
            {
                EntityList += entity.EntityId + ";";
            }
            foreach (T_CMS_Master_Contract objitem in objItemList)
            {
                isError  = false;
                strError = "";
                try
                {
                    objPosition = T_COM_Master_PositionManager.GetByName(objitem.PostionName);
                    string[] strPosition = objitem.PostionName.Split('-');
                    if (objPosition.PositionID == 0)
                    {
                        if (strPosition.Length > 0)
                        {
                            objitem.PostionName = strPosition[0];
                        }
                    }
                    string[] strPOI = objitem.IDPOICD.Split('-');
                    if (strPOI.Length > 0)
                    {
                        objitem.IDPOICD = strPOI[0];
                    }
                    objOrg = T_COm_Master_OrgManager.GetByOrgName(objitem.DepartCD);

                    //check permission that you can add to this Entity or not
                    if (EntityList.IndexOf(objOrg.Entity_Id.ToString()) == -1)
                    {
                        strError += "<div>You don't have Permission to Import to this Group: <span class='impval'>" + objitem.DepartCD + " </span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Grade Name:" + objitem.GradeName));
                        isError = true;
                    }

                    objGrade    = T_COM_Master_GradeManager.GetByName(objitem.GradeName);
                    objPosition = T_COM_Master_PositionManager.GetByName(objitem.PostionName);
                    objWH       = T_CMS_Master_WorkHoursManager.GetByWorkHours(objitem.WorkHoursCD);

                    objPOI = T_COM_Master_PlaceOfIssueManager.GetByPOI_Name_VN(objitem.IDPOICD.Trim());

                    if (objGrade.GradeID == 0)
                    {
                        strError += "<div>Invalid Grade Name: <span class='impval'>" + objitem.GradeName + " </span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Grade Name:" + objitem.GradeName));
                        isError = true;
                    }
                    if (objPosition.PositionID == 0)
                    {
                        strError += "<div>Invalid Postion Name: <span class='impval'>" + objitem.PostionName + " </span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Postion Name:" + objitem.PostionName));
                        isError = true;
                    }
                    if (objWH.WorkHoursID == 0)
                    {
                        strError += "<div>Invalid  Work Hours Name: <span class='impval'>" + objitem.WorkHoursCD + "</span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Work Hours Name:" + objitem.WorkHoursCD));
                        isError = true;
                    }
                    if (objPOI.POI_ID == 0)
                    {
                        strError += "<div>Invalid  Place of Issues Name: <span class='impval'>" + objitem.IDPOICD + "</span></div>";
                        //ErrorList.Add(AddErrorMessage(objitem, "Invalid Place of Issues Name:" + objitem.IDPOICD));
                        isError = true;
                    }

                    if (isError)
                    {
                        ErrorList.Add(AddErrorMessage(objitem, strError));
                        continue;
                    }
                    //if we dont have the org get the default value for Org/Department ID
                    if (objOrg.OrgId == 0)
                    {
                        //objOrg.OrgId = 1003; //Default RBVH  1003	RBVH/ETI
                        ErrorList.Add(AddErrorMessage(objitem, "Invalid Department Name:" + objitem.DepartCD));
                        continue;
                    }

                    //get emp subtype by entity and Contract

                    objEmpType = T_CMS_Master_EmploymentTypeManager.GetAllByEntityID(objOrg.Entity_Id, "C");


                    if (objEmpType != null)
                    {
                        objitem.EmpTypeID = objEmpType.EmpTypeID;

                        if (objOrg.Entity_Id != 10001)
                        {
                            objEmpSubType = T_CMS_Master_EmploymentSubTypeManager.GetEmpTypeID(objEmpType.EmpTypeID, objitem.EmpTypeCD);
                            if (objEmpSubType != null)
                            {
                                objitem.EmpSubTypeID = objEmpSubType.EmpSubTypeID;
                            }
                            else
                            {
                                ErrorList.Add(AddErrorMessage(objitem, "Invalid EmployeeSubType Name:" + objitem.EmpTypeCD));
                                continue;
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(objitem.POB))
                    {
                        objitem.POB = "";
                    }
                    if (string.IsNullOrEmpty(objitem.HighestDegree))
                    {
                        objitem.HighestDegree = "";
                    }
                    if (string.IsNullOrEmpty(objitem.PerAddress))
                    {
                        objitem.PerAddress = "";
                    }
                    //Location = 6;// objitem.LocationCD.Split('-')[0].Trim();
                    objitem.ID   = 0; //Add new
                    objitem.Mode = "SAVE";
                    //default value
                    objitem.CreatedBy = EmployeeCode;

                    //Grade = int.Parse(objitem.GradeName.Split('-')[1].Trim());

                    objitem.GradeID = objGrade.GradeID;
                    //add annual leave
                    T_LMS_Master_AnnualLeave objAL = T_LMS_Master_AnnualLeaveManager.GetById(objitem.GradeID);
                    if (objAL.Grade_Id != 0)
                    {
                        objitem.AnnualLeave = objAL.NoOfDays;
                    }


                    objitem.PositionID = objPosition.PositionID;
                    if (objitem.SalutationCD.IndexOf("Ms") != -1)
                    {
                        SaluationID = 2;
                    }
                    else if (objitem.SalutationCD.IndexOf("Mrs") != -1)
                    {
                        SaluationID = 3;
                    }
                    else
                    {
                        SaluationID = 1;
                    }



                    objitem.WorkHoursID  = objWH.WorkHoursID;
                    objitem.SalutationID = SaluationID; //DNH fix later
                    objitem.LocationID   = 6;           // int.Parse(Location);
                    objitem.IDPOI        = objPOI.POI_ID;
                    //objitem.HighestDegree
                    objitem.CreatedDate         = SystemConfig.CurrentDate;
                    objitem.PassportDOI         = null;
                    objitem.ModifiedDate        = SystemConfig.CurrentDate;
                    objitem.HostCountryCurrency = "VND";
                    string period      = objitem.ProbationsPeriodCD.Replace("Days", "");
                    int    monthPeriod = 0;
                    if (period == "60")
                    {
                        objitem.ProbationsPeriod = 2;
                        monthPeriod = 2;
                    }
                    else if (period == "30")
                    {
                        objitem.ProbationsPeriod = 1;
                        monthPeriod = 1;
                    }
                    else
                    {
                        objitem.ProbationsPeriod = 0;
                    }
                    objitem.DeptID         = objOrg.OrgId;
                    objitem.LabourDOI      = null;
                    objitem.ModifiedDate   = SystemConfig.CurrentDate;
                    objitem.OriginalDate   = SystemConfig.CurrentDate;
                    objitem.WorkPermitFrom = SystemConfig.CurrentDate;
                    objitem.EmpTypeID      = objEmpType.EmpTypeID; //DNH
                    if (objitem.ContractTermCD.IndexOf("Indefinite") != -1)
                    {
                        if (objOrg.Entity_Id == 10001)
                        {
                            objitem.EmpSubTypeID = 101;//Indefinite Sub-Type
                        }
                        objitem.WorkPermitTo = SystemConfig.EndDate;
                        objitem.Enddate      = SystemConfig.EndDate;
                        objitem.ContractTerm = 0;
                        //check if the the contract have the probation term it will calcuation about enddate --> use for report information
                    }
                    else
                    {
                        if (objOrg.Entity_Id == 10001)
                        {
                            objitem.EmpSubTypeID = 100;  //definite Sub-Type
                        }


                        string[] strContractTerm = objitem.ContractTermCD.Split(' ');


                        if (strContractTerm.Length > 0)
                        {
                            int intTerm = int.Parse(strContractTerm[0]);
                            if (intTerm < 12)
                            {
                                if (objOrg.Entity_Id == 10001)
                                {
                                    objitem.EmpSubTypeID = 103; //seasonable Sub-Type
                                }
                            }

                            objitem.ContractTerm = intTerm;
                            DateTime enddate = objitem.Joiningdate.AddMonths(intTerm);
                            enddate = enddate.AddDays(-1);
                            objitem.WorkPermitTo = enddate;
                            objitem.Enddate      = enddate;
                        }
                    }

                    if (objitem.ProbationsPeriod > 0)
                    {
                        if (monthPeriod == (int)eMonthProbation.ONE_MONTH_PROBATION_PERIOD)
                        {
                            objitem.Enddate = objitem.Joiningdate.AddDays(Constant.ONE_MONTH_PROBATION_PERIOD);
                        }
                        if (monthPeriod == (int)eMonthProbation.TWO_MONTH_PROBATION_PERIOD)
                        {
                            objitem.Enddate = objitem.Joiningdate.AddDays(Constant.TWO_MONTH_PROBATION_PERIOD);
                        }
                    }

                    objitem.HomeGrossOfferEffectiveFrom = SystemConfig.CurrentDate;
                    objitem.HostGrossOfferEffectiveFrom = SystemConfig.CurrentDate;
                    objitem.HomeGrossOfferEffectiveTo   = SystemConfig.CurrentDate;
                    objitem.HostGrossOfferEffectiveTo   = SystemConfig.CurrentDate;


                    objitem.FirstName_EN  = objitem.FirstName_EN.ToUpper();
                    objitem.MiddleName_EN = objitem.MiddleName_EN.ToUpper();
                    objitem.LastName_EN   = objitem.LastName_EN.ToUpper();

                    objitem.FirstName_VN  = objitem.FirstName_VN.ToUpper();
                    objitem.MiddleName_VN = objitem.MiddleName_VN.ToUpper();
                    objitem.LastName_VN   = objitem.LastName_VN.ToUpper();

                    Add(objitem);
                }
                catch (Exception ObjEx)
                {
                    ErrorList.Add(AddErrorMessage(objitem, ObjEx.Message));
                }
            }
            return(ErrorList);
        }
        public ActionResult list()
        {
            T_COM_Master_EntityCollection collection = T_COM_Master_EntityManager.GetAll();

            return(View(ViewFolder + "list.cshtml", collection));
        }