protected void btnSaveDelegate_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        string[] strDelegateEmpNoList = txtDelegateEmpNoList.Text.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
        ESSAuthorizationProcess authorizationProcess = new ESSAuthorizationProcess(dbConn);
        List <EEmpPersonalInfo> delegateEmpInfoList  = new List <EEmpPersonalInfo>();

        foreach (string delegateEmpNo in strDelegateEmpNoList)
        {
            EEmpPersonalInfo delegateEmpInfo = authorizationProcess.GetEmpInfo(delegateEmpNo);
            if (delegateEmpInfo == null)
            {
                errors.addError("Invalid Employee No: " + delegateEmpNo);
            }
            else
            {
                delegateEmpInfoList.Add(delegateEmpInfo);
                EEmpTermination empTerm = EEmpTermination.GetObjectByEmpID(dbConn, delegateEmpInfo.EmpID);
                if (empTerm != null)
                {
                    if (empTerm.EmpTermLastDate < AppUtils.ServerDateTime().Date)
                    {
                        errors.addError("Employee " + delegateEmpNo + " is Terminated");
                    }
                }
            }
        }
        if (!errors.isEmpty())
        {
            return;
        }

        DBFilter authorizerDBFilter = new DBFilter();

        authorizerDBFilter.add(new Match("EmpID", CurID));
        EAuthorizerDelegate.db.delete(dbConn, authorizerDBFilter);

        foreach (EEmpPersonalInfo delegateEmpInfo in delegateEmpInfoList)
        {
            EAuthorizerDelegate authorDelegate = new EAuthorizerDelegate();
            authorDelegate.EmpID = CurID;
            authorDelegate.AuthorizerDelegateEmpID = delegateEmpInfo.EmpID;
            EAuthorizerDelegate.db.insert(dbConn, authorDelegate);
        }

        errors.addError("Delegate employee is submitted");
    }
    protected string generateToolTipMessage(EEmpRequest empRequest)
    {
        string message = "Employee No:\t%EMP_NO%\r\n" +
                         "Employee:\t%EMP_NAME%\r\n" +
                         "Leave Date:\t%LEAVEAPP_PERIOD%\r\n" +
                         "Leave Type:\t%LEAVE_CODE%\r\n" +
                         "Taken     :\t%LEAVEAPP_DAYS% %LEAVEAPP_UNIT%\r\n" +
                         "Hours Claims:\t%LEAVEAPP_HOURSCLAIM%\r\n" +
                         "Reason:\t%LEAVEAPPCANCEL_REMARK%\r\n";

        ESSAuthorizationProcess process = new ESSAuthorizationProcess(dbConn);

        EEmpPersonalInfo ApplicantEmpInfo = process.GetEmpInfo(empRequest.EmpID);

        Hashtable mailContentParameterTable = new Hashtable();

        mailContentParameterTable = process.GenerateEmpInfoHashTable(ApplicantEmpInfo, mailContentParameterTable);

        if (empRequest.EmpRequestType == EEmpRequest.TYPE_EELEAVEAPP)
        {
            DBFilter RequestEmpFilter = new DBFilter();
            RequestEmpFilter.add(new Match("RequestLeaveAppID", empRequest.EmpRequestRecordID));
            ArrayList empRequestList = ERequestLeaveApplication.db.select(dbConn, RequestEmpFilter);
            if (empRequestList.Count > 0)
            {
                ERequestLeaveApplication empLeaveRequest = (ERequestLeaveApplication)empRequestList[0];

                mailContentParameterTable = process.GenerateRequestLeaveApplicationHashTable(empLeaveRequest, mailContentParameterTable);
            }
        }
        else if (empRequest.EmpRequestType == EEmpRequest.TYPE_EELEAVECANCEL)
        {
            DBFilter RequestEmpFilter = new DBFilter();
            RequestEmpFilter.add(new Match("RequestLeaveAppCancelID", empRequest.EmpRequestRecordID));
            ArrayList empRequestList = ERequestLeaveApplicationCancel.db.select(dbConn, RequestEmpFilter);
            if (empRequestList.Count > 0)
            {
                ERequestLeaveApplicationCancel requestLeaveAppCancel = (ERequestLeaveApplicationCancel)empRequestList[0];
                mailContentParameterTable.Add("%LEAVEAPPCANCEL_REMARK%", requestLeaveAppCancel.RequestLeaveAppCancelReason);
                ELeaveApplication leaveApp = new ELeaveApplication();
                leaveApp.LeaveAppID = requestLeaveAppCancel.LeaveAppID;
                if (ELeaveApplication.db.select(dbConn, leaveApp))
                {
                    ERequestLeaveApplication dummyRequestLeave = ERequestLeaveApplication.CreateDummyRequestLeaveAppliction(leaveApp);
                    mailContentParameterTable = process.GenerateRequestLeaveApplicationHashTable(dummyRequestLeave, mailContentParameterTable);
                }
            }
        }
        string MessageBodyTemplate = message;

        foreach (string key in mailContentParameterTable.Keys)
        {
            MessageBodyTemplate = MessageBodyTemplate.Replace(key, mailContentParameterTable[key].ToString());
        }
        string[] messageBodyLineArray = MessageBodyTemplate.Split(new string[] { "\r\n", "\r", "\n" }, StringSplitOptions.None);
        string   newMessageBody       = string.Empty;

        foreach (string messageLine in messageBodyLineArray)
        {
            if (string.IsNullOrEmpty(messageLine) || messageLine.IndexOf("%") == messageLine.LastIndexOf("%"))
            {
                if (string.IsNullOrEmpty(newMessageBody))
                {
                    newMessageBody = messageLine;
                }
                else
                {
                    newMessageBody += "\r\n" + messageLine;
                }
            }
        }
        return(newMessageBody);
    }