public static EEmpPersonalInfo GetObject(DatabaseConnection dbConn, int EmpID)
        {
            EEmpPersonalInfo m_obj = new EEmpPersonalInfo();

            m_obj.EmpID = EmpID;

            if (EEmpPersonalInfo.db.select(dbConn, m_obj))
            {
                return(m_obj);
            }
            else
            {
                return(null);
            }
        }
        public double GetAge(DatabaseConnection dbConn, DateTime AsOfDate)
        {
            if (string.IsNullOrEmpty(m_EmpNo))
            {
                EEmpPersonalInfo dummyEmpInfo = new EEmpPersonalInfo();
                if (dummyEmpInfo.LoadDBObject(dbConn, EmpID))
                {
                    return(dummyEmpInfo.GetAge(dbConn, AsOfDate));
                }
                else
                {
                    return(0);
                }
            }
            if (this.EmpDateOfBirth.Ticks.Equals(0))
            {
                return(0);
            }
            DateTime tmpDateOfBirth = this.EmpDateOfBirth;

            return(HROne.CommonLib.Utility.YearDifference(tmpDateOfBirth, AsOfDate.AddDays(-1)));
        }
Beispiel #3
0
        public static EEmpBankAccount GetDefaultBankAccount(DatabaseConnection dbConn, int EmpID)
        {
            DBFilter filter = new DBFilter();

            filter.add(new Match("EmpID", EmpID));
            filter.add(new Match("EmpAccDefault", "<>", 0));
            ArrayList bankAccountList = EEmpBankAccount.db.select(dbConn, filter);

            if (bankAccountList.Count > 0)
            {
                return((EEmpBankAccount)bankAccountList[0]);
            }
            else
            {
                EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                empInfo.EmpID = EmpID;
                if (EEmpPersonalInfo.db.select(dbConn, empInfo) && empInfo.MasterEmpID > 0)
                {
                    return(GetDefaultBankAccount(dbConn, empInfo.MasterEmpID));
                }
            }
            return(null);
        }
        public double GetYearOfServer(DatabaseConnection dbConn, DateTime AsOfDate)
        {
            if (string.IsNullOrEmpty(m_EmpNo))
            {
                EEmpPersonalInfo dummyEmpInfo = new EEmpPersonalInfo();
                if (dummyEmpInfo.LoadDBObject(dbConn, EmpID))
                {
                    return(dummyEmpInfo.GetYearOfServer(dbConn, AsOfDate));
                }
                else
                {
                    return(0);
                }
            }
            if (this.EmpServiceDate.Ticks.Equals(0))
            {
                return(0);
            }
            DateTime tmpYearOfService = this.EmpServiceDate;

            if (tmpYearOfService > AsOfDate)
            {
                return(0);
            }

            EEmpTermination empTerm = EEmpTermination.GetObjectByEmpID(dbConn, m_EmpID);

            if (empTerm != null)
            {
                if (empTerm.EmpTermLastDate < AsOfDate)
                {
                    AsOfDate = empTerm.EmpTermLastDate;
                }
            }
            return(HROne.CommonLib.Utility.YearDifference(tmpYearOfService, AsOfDate));
        }
Beispiel #5
0
        public string GetLogText(DatabaseConnection dbConn, string EmpNoFilter, bool ShowHeaderOnly, bool ShowKeyIDOnly, bool DoNotConvertID)
        {
            StringBuilder logTextBuilder  = new StringBuilder();
            bool          skipGenerateLog = false;

            DBFilter auditTrailDetailFilter = new DBFilter();

            auditTrailDetailFilter.add(new Match("AuditTrailID", this.AuditTrailID));
            ArrayList auditTrailDetailList = EAuditTrailDetail.db.select(dbConn, auditTrailDetailFilter);

            int empID = this.EmpID;

            if (!string.IsNullOrEmpty(EmpNoFilter.Trim()))
            {
                if (empID.Equals(0))
                {
                    foreach (EAuditTrailDetail auditTrailDetail in auditTrailDetailList)
                    {
                        string tmpRemark = auditTrailDetail.Remark.Replace(" ", "");
                        int    pos       = tmpRemark.IndexOf("\nEmpID=", StringComparison.CurrentCultureIgnoreCase);
                        if (pos >= 0)
                        {
                            string empIDString = tmpRemark.Substring(pos + 1, tmpRemark.IndexOf("\n", pos + 1) - pos);
                            empID = int.Parse(empIDString.Substring(empIDString.IndexOf("=") + 1));
                        }
                    }
                }
                EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                empInfo.EmpID = empID;
                if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                {
                    if (empInfo.EmpNo.IndexOf(EmpNoFilter.Trim(), StringComparison.CurrentCultureIgnoreCase) < 0)
                    {
                        skipGenerateLog = true;
                    }
                }
                else
                {
                    skipGenerateLog = true;
                }
            }
            if (!skipGenerateLog)
            {
                ESystemFunction function = new ESystemFunction();
                function.FunctionID = this.FunctionID;
                if (ESystemFunction.db.select(dbConn, function))
                {
                    logTextBuilder.AppendLine(string.Empty.PadLeft(78, '-'));
                    EUser user = new EUser();
                    user.UserID = this.UserID;
                    if (EUser.db.select(dbConn, user))
                    {
                        logTextBuilder.AppendLine("User     : \t" + user.LoginID + " - " + user.UserName);
                    }
                    else if (this.UserID.Equals(0))
                    {
                        logTextBuilder.AppendLine("User     : \t" + "System");
                    }
                    else
                    {
                        logTextBuilder.AppendLine("User     : \t" + this.UserID + " (Unknown)");
                    }

                    logTextBuilder.AppendLine("Function : \t" + function.FunctionCode + " - " + function.Description);
                    logTextBuilder.AppendLine("Date/Time: \t" + this.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"));

                    if (!this.EmpID.Equals(0))
                    {
                        EEmpPersonalInfo empInfo = new EEmpPersonalInfo();
                        empInfo.EmpID = this.EmpID;
                        if (EEmpPersonalInfo.db.select(dbConn, empInfo))
                        {
                            logTextBuilder.AppendLine("Employee : \t" + empInfo.EmpNo + " - " + empInfo.EmpEngFullName);
                        }
                    }

                    logTextBuilder.AppendLine(string.Empty.PadLeft(78, '-'));

                    if (!ShowHeaderOnly)
                    {
                        foreach (EAuditTrailDetail auditTrailDetail in auditTrailDetailList)
                        {
                            if ((auditTrailDetail.Remark.Replace(" ", "").IndexOf("EmpID=" + empID, StringComparison.CurrentCultureIgnoreCase) >= 0 || this.EmpID.Equals(empID)) && !string.IsNullOrEmpty(EmpNoFilter.Trim()) || string.IsNullOrEmpty(EmpNoFilter.Trim()))
                            {
                                logTextBuilder.Append(auditTrailDetail.GetLogText(dbConn, ShowKeyIDOnly, DoNotConvertID));
                            }
                        }
                    }
                }
                //logTextBuilder.AppendLine(string.Empty);
            }
            return(logTextBuilder.ToString());
        }