Exemple #1
0
    protected void Repeater_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        e.Item.FindControl("DeleteItem").Visible = IsAllowEdit;
        if (e.Item.ItemIndex == Repeater.EditItemIndex)
        {
            ebinding = new Binding(dbConn, db);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("CountryID"));
            ebinding.add((TextBox)e.Item.FindControl("CountryCode"));
            ebinding.add((TextBox)e.Item.FindControl("CountryDesc"));
            ebinding.init(Request, Session);

            EIssueCountry obj = new EIssueCountry();
            db.toObject(((DataRowView)e.Item.DataItem).Row, obj);
            Hashtable values = new Hashtable();
            db.populate(obj, values);
            ebinding.toControl(values);
        }
        else
        {
            e.Item.FindControl("Edit").Visible = IsAllowEdit;
            HtmlInputHidden h = (HtmlInputHidden)e.Item.FindControl("CountryID");
            h.Value = ((DataRowView)e.Item.DataItem)["CountryID"].ToString();
        }
        HROne.Common.WebUtility.WebControlsLocalization(Session, e.Item.Controls);
    }
Exemple #2
0
    protected void Add_Click(object sender, EventArgs e)
    {
        Repeater.EditItemIndex = -1;
        EIssueCountry c = new EIssueCountry();

        Hashtable values = new Hashtable();

        binding.toValues(values);

        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }

        db.parse(values, c);
        if (!AppUtils.checkDuplicate(dbConn, db, c, errors, "CountryCode"))
        {
            return;
        }

        WebUtils.StartFunction(Session, FUNCTION_CODE);
        db.insert(dbConn, c);
        WebUtils.EndFunction(dbConn);

        CountryCode.Text = string.Empty;
        CountryDesc.Text = string.Empty;

        view = loadData(info, db, Repeater);
    }
Exemple #3
0
    protected void Repeater_ItemCommand(object source, DataListCommandEventArgs e)
    {
        Button b = (Button)e.CommandSource;

        if (b.ID.Equals("Edit"))
        {
            Repeater.EditItemIndex = e.Item.ItemIndex;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, false);
        }
        else if (b.ID.Equals("Cancel"))
        {
            Repeater.EditItemIndex = -1;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
        else if (b.ID.Equals("Save"))
        {
            ebinding = new Binding(dbConn, db);
            ebinding.add((HtmlInputHidden)e.Item.FindControl("CountryID"));
            ebinding.add((TextBox)e.Item.FindControl("CountryCode"));
            ebinding.add((TextBox)e.Item.FindControl("CountryDesc"));
            ebinding.init(Request, Session);

            EIssueCountry obj    = new EIssueCountry();
            Hashtable     values = new Hashtable();

            PageErrors errors = PageErrors.getErrors(db, Page.Master);
            errors.clear();

            ebinding.toValues(values);
            db.validate(errors, values);

            if (!errors.isEmpty())
            {
                return;
            }

            db.parse(values, obj);
            if (!AppUtils.checkDuplicate(dbConn, db, obj, errors, "CountryCode"))
            {
                return;
            }

            WebUtils.StartFunction(Session, FUNCTION_CODE);
            db.update(dbConn, obj);
            WebUtils.EndFunction(dbConn);

            Repeater.EditItemIndex = -1;
            view = loadData(info, db, Repeater);
            WebUtils.SetEnabledControlSection(AddPanel, true);
        }
    }
Exemple #4
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();

        ArrayList list = new ArrayList();

        foreach (DataListItem item in Repeater.Items)
        {
            CheckBox        c = (CheckBox)item.FindControl("DeleteItem");
            HtmlInputHidden h = (HtmlInputHidden)item.FindControl("CountryID");
            if (c.Checked)
            {
                EIssueCountry obj = new EIssueCountry();
                obj.CountryID = Int32.Parse(h.Value);
                list.Add(obj);
            }
        }
        // Start 000150, Ricky So, 2015/01/02
        foreach (EIssueCountry obj in list)
        {
            EIssueCountry.db.select(dbConn, obj);
            DBFilter empPersonalInfoFilter = new DBFilter();
            empPersonalInfoFilter.add(new Match("EmpPassportIssuedCountryID", obj.CountryID));
            empPersonalInfoFilter.add("empid", true);
            ArrayList empList = EEmpPersonalInfo.db.select(dbConn, empPersonalInfoFilter);
            if (empList.Count > 0)
            {
                errors.addError(string.Format(HROne.Translation.PageErrorMessage.ERROR_CODE_USED_BY_EMPLOYEE, new string[] { HROne.Common.WebUtility.GetLocalizedString("Country of Issue"), obj.CountryCode }));
                foreach (EEmpPersonalInfo empInfo in empList)
                {
                    errors.addError("- " + empInfo.EmpNo + ", " + empInfo.EmpEngFullName);
                }
                errors.addError(HROne.Translation.PageErrorMessage.ERROR_ACTION_ABORT);
            }
            else
            {
                WebUtils.StartFunction(Session, FUNCTION_CODE);
                db.delete(dbConn, obj);
                WebUtils.EndFunction(dbConn);
            }
        }
        // End 000150, Ricky So, 2015/01/02
        view = loadData(info, db, Repeater);
    }
Exemple #5
0
        public void DataPatchProgram(string versionNo)
        {
            if (versionNo == "1.0.20")  // patch Nationality, Country, Place Of Birth
            {
                // Patch Nationality
                DBFilter m_empPersonalInfoFilter = new DBFilter();
                m_empPersonalInfoFilter.add(new NullTerm("NOT EmpNationality"));
                DataTable m_table = m_empPersonalInfoFilter.loadData(dbConn, "SELECT DISTINCT EmpNationality FROM EmpPersonalInfo");
                string    m_decodedString;

                foreach (DataRow m_row in m_table.Rows)
                {
                    m_decodedString = AppUtils.Decode(EEmpPersonalInfo.db.getField("EmpNationality"), m_row[0].ToString().Trim());

                    if (m_decodedString != "")
                    {
                        ENationality m_nationality = new ENationality();

                        if (m_decodedString.Length > 20)
                        {
                            m_nationality.NationalityCode = m_decodedString.Substring(0, 20);
                        }
                        else
                        {
                            m_nationality.NationalityCode = m_decodedString;
                        }

                        if (m_decodedString.Length > 100)
                        {
                            m_nationality.NationalityDesc = m_decodedString.Substring(0, 100);
                        }
                        else
                        {
                            m_nationality.NationalityDesc = m_decodedString;
                        }

                        ENationality.db.insert(dbConn, m_nationality);
                    }
                }

                // patch Country Code
                m_empPersonalInfoFilter.add(new NullTerm("NOT EmpPassportIssuedCountry"));
                m_table = m_empPersonalInfoFilter.loadData(dbConn, "SELECT DISTINCT EmpPassportIssuedCountry FROM EmpPersonalInfo");

                foreach (DataRow m_row in m_table.Rows)
                {
                    m_decodedString = AppUtils.Decode(EEmpPersonalInfo.db.getField("EmpPassportIssuedCountry"), m_row[0].ToString().Trim());

                    if (m_decodedString != "")
                    {
                        EIssueCountry m_country = new EIssueCountry();

                        if (m_decodedString.Length > 20)
                        {
                            m_country.CountryCode = m_decodedString.Substring(0, 20);
                        }
                        else
                        {
                            m_country.CountryCode = m_decodedString;
                        }

                        if (m_decodedString.Length > 100)
                        {
                            m_country.CountryDesc = m_decodedString.Substring(0, 100);
                        }
                        else
                        {
                            m_country.CountryDesc = m_decodedString;
                        }

                        EIssueCountry.db.insert(dbConn, m_country);
                    }
                }

                // patch Place of Birth
                m_empPersonalInfoFilter.add(new NullTerm("NOT EmpPlaceOfBirth"));
                m_table = m_empPersonalInfoFilter.loadData(dbConn, "SELECT DISTINCT EmpPlaceOfBirth FROM EmpPersonalInfo");

                foreach (DataRow m_row in m_table.Rows)
                {
                    m_decodedString = AppUtils.Decode(EEmpPersonalInfo.db.getField("EmpPlaceOfBirth"), m_row[0].ToString().Trim());

                    if (m_decodedString != "")
                    {
                        EPlaceOfBirth m_placeOfBirth = new EPlaceOfBirth();

                        if (m_decodedString.Length > 20)
                        {
                            m_placeOfBirth.PlaceOfBirthCode = m_decodedString.Substring(0, 20);
                        }
                        else
                        {
                            m_placeOfBirth.PlaceOfBirthCode = m_decodedString;
                        }

                        if (m_decodedString.Length > 100)
                        {
                            m_placeOfBirth.PlaceOfBirthDesc = m_decodedString.Substring(0, 100);
                        }
                        else
                        {
                            m_placeOfBirth.PlaceOfBirthDesc = m_decodedString;
                        }

                        EPlaceOfBirth.db.insert(dbConn, m_placeOfBirth);
                    }
                }

                // patch EmpPersonalInfo
                foreach (EEmpPersonalInfo m_info in EEmpPersonalInfo.db.select(dbConn, new DBFilter()))
                {
                    bool m_update = false;
                    if (!string.IsNullOrEmpty(m_info.EmpPlaceOfBirth))
                    {
                        DBFilter m_filter = new DBFilter();
                        m_filter.add(new Match("PlaceOfBirthCode", m_info.EmpPlaceOfBirth));
                        ArrayList m_list = EPlaceOfBirth.db.select(dbConn, m_filter);
                        if (m_list.Count > 0)
                        {
                            m_info.EmpPlaceOfBirthID = ((EPlaceOfBirth)m_list[0]).PlaceOfBirthID;
                        }
                        m_update = true;
                    }

                    if (!string.IsNullOrEmpty(m_info.EmpPassportIssuedCountry))
                    {
                        DBFilter m_filter = new DBFilter();
                        m_filter.add(new Match("CountryCode", m_info.EmpPassportIssuedCountry));
                        ArrayList m_list = EIssueCountry.db.select(dbConn, m_filter);
                        if (m_list.Count > 0)
                        {
                            m_info.EmpPassportIssuedCountryID = ((EIssueCountry)m_list[0]).CountryID;
                        }
                    }

                    if (!string.IsNullOrEmpty(m_info.EmpNationality))
                    {
                        DBFilter m_filter = new DBFilter();
                        m_filter.add(new Match("NationalityCode", m_info.EmpNationality));
                        ArrayList m_list = ENationality.db.select(dbConn, m_filter);
                        if (m_list.Count > 0)
                        {
                            m_info.EmpNationalityID = ((ENationality)m_list[0]).NationalityID;
                        }
                    }

                    if (m_update == true)
                    {
                        EEmpPersonalInfo.db.update(dbConn, m_info);
                    }
                }
            }
        }
Exemple #6
0
    protected void Save_Click(object sender, EventArgs e)
    {
        DateTime         createDate = DateTime.Now;
        EEmpPersonalInfo c          = new EEmpPersonalInfo();
        EEmpRequest      EmpRequest = new EEmpRequest();


        Hashtable values = new Hashtable();

        binding.toValues(values);

        PageErrors errors = PageErrors.getErrors(db, Page);

        errors.clear();


        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return;
        }


        db.parse(values, c);

        if (!errors.isEmpty())
        {
            return;
        }

        ERequestEmpPersonalInfo RequestEmpProfile = new ERequestEmpPersonalInfo();

        // Start 0000092, KuangWei, 2014-10-17
        if (c.EmpNationalityID > 0)
        {
            ENationality m_nationality = new ENationality();
            m_nationality.NationalityID = c.EmpNationalityID;
            if (ENationality.db.select(dbConn, m_nationality))
            {
                c.EmpNationality = m_nationality.NationalityDesc;
            }
        }
        else
        {
            c.EmpNationality = "";
        }

        if (c.EmpPlaceOfBirthID > 0)
        {
            EPlaceOfBirth m_placeOfBirth = new EPlaceOfBirth();
            m_placeOfBirth.PlaceOfBirthID = c.EmpPlaceOfBirthID;
            if (EPlaceOfBirth.db.select(dbConn, m_placeOfBirth))
            {
                c.EmpPlaceOfBirth = m_placeOfBirth.PlaceOfBirthDesc;
            }
        }
        else
        {
            c.EmpPlaceOfBirth = "";
        }

        if (c.EmpPassportIssuedCountryID > 0)
        {
            EIssueCountry m_issueCountry = new EIssueCountry();
            m_issueCountry.CountryID = c.EmpPassportIssuedCountryID;
            if (EIssueCountry.db.select(dbConn, m_issueCountry))
            {
                c.EmpPassportIssuedCountry = m_issueCountry.CountryDesc;
            }
        }
        else
        {
            c.EmpPassportIssuedCountry = "";
        }


        RequestEmpProfile.RequestEmpPlaceOfBirth            = c.EmpPlaceOfBirth;
        RequestEmpProfile.RequestEmpPlaceOfBirthID          = c.EmpPlaceOfBirthID;
        RequestEmpProfile.RequestEmpPassportIssuedCountryID = c.EmpPassportIssuedCountryID;
        RequestEmpProfile.RequestEmpNationalityID           = c.EmpNationalityID;
        // End 0000092, KuangWei, 2014-10-17
        RequestEmpProfile.EmpID                           = c.EmpID;
        RequestEmpProfile.RequestEmpAlias                 = c.EmpAlias;
        RequestEmpProfile.RequestEmpMaritalStatus         = c.EmpMaritalStatus;
        RequestEmpProfile.RequestEmpPassportNo            = c.EmpPassportNo;
        RequestEmpProfile.RequestEmpPassportIssuedCountry = c.EmpPassportIssuedCountry;
        RequestEmpProfile.RequestEmpPassportExpiryDate    = c.EmpPassportExpiryDate;
        RequestEmpProfile.RequestEmpNationality           = c.EmpNationality;
        RequestEmpProfile.RequestEmpHomePhoneNo           = c.EmpHomePhoneNo;
        RequestEmpProfile.RequestEmpMobileNo              = c.EmpMobileNo;
        RequestEmpProfile.RequestEmpOfficePhoneNo         = c.EmpOfficePhoneNo;
        RequestEmpProfile.RequestEmpEmail                 = c.EmpEmail;
        RequestEmpProfile.RequestEmpResAddr               = c.EmpResAddr;
        RequestEmpProfile.RequestEmpResAddrAreaCode       = c.EmpResAddrAreaCode;
        RequestEmpProfile.RequestEmpCorAdd                = c.EmpCorAddr;

        try
        {
            ESSAuthorizationProcess authorization = new ESSAuthorizationProcess(dbConn);
            authorization.SubmitEmployeeInfoChange(RequestEmpProfile);
        }
        catch (Exception ex)
        {
            errors.addError(ex.Message);
        }

        if (!errors.isEmpty())
        {
            return;
        }
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/ESS_EmpRequestStatus.aspx");
    }
    public bool Save()
    {
        if (!FullResAddrPanel.Visible)
        {
            EmpResAddr.Text = EmpResAddr1.Text + "\r\n" + EmpResAddr2.Text + "\r\n" + EmpResAddr3.Text;
        }


        EEmpPersonalInfo c = new EEmpPersonalInfo();

        Hashtable values = new Hashtable();

        binding.toValues(values);

        PageErrors errors = PageErrors.getErrors(db, Page.Master);

        errors.clear();


        db.validate(errors, values);

        if (!errors.isEmpty())
        {
            return(false);
        }


        db.parse(values, c);

        if (this.IsResetESSPassword.Checked)
        {
            c.EmpPW = string.Empty;
        }

        if (PrevEmpID > 0)
        {
            if (IsCreateNewRoleEmployee)
            {
                c.EmpNo       = NewRoleEmpNo.Text.Trim();
                c.MasterEmpID = PrevEmpID;
                if (string.IsNullOrEmpty(c.EmpNo))
                {
                    errors.addError(lblNewRoleEmpNo.Text, "validate.required.prompt");
                    return(false);
                }
            }
        }
        c.EmpNo = c.EmpNo.ToUpper();
        // Start 0000044, Miranda, 2014-05-09
        string oldEmpNo = "";

        if (!AppUtils.checkDuplicate(dbConn, db, c, errors, "EmpNo"))
        {
            if (isAutoGenerateEmpNo && empNoFormat != null && EmpID < 0)
            {
                // Check if EmpNo format is same as EmpNoFormat setting of System Parameter
                bool alignToFormat = isAlignToDefinedFormat(c.EmpNo, empNoFormat);
                if (alignToFormat)
                {
                    errors.clear();
                    oldEmpNo   = c.EmpNo;
                    c.EmpNo    = getNextEmpNo(empNoFormat).ToUpper();
                    EmpNo.Text = c.EmpNo;
                    if (!AppUtils.checkDuplicate(dbConn, db, c, errors, "EmpNo"))
                    {
                        return(false);
                    }
                    else
                    {
                        errors.addError(string.Format(HROne.Translation.PageErrorMessage.ALERT_NEW_STAFF_NO_BEEN_USED, new string[] { oldEmpNo, c.EmpNo }));
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
        // End 0000044, Miranda, 2014-05-09
        // Start 0000066, Miranda, 2014-08-08
        if (SuppressHKIDWarning.Text == "false" && !AppUtils.checkDuplicate(dbConn, db, c, errors, "EmpHKID"))
        {
            SuppressHKIDWarning.Text = "true";

            errors.clear();
            errors.addError("HKID is already input in system, click SAVE button again to bypass this warning and save to database.");
        }
        // End 0000066, Miranda, 2014-08-08

        if (c.EmpDateOfBirth > AppUtils.ServerDateTime().Date)
        {
            errors.addError("EmpDateOfBirth", HROne.Translation.PageErrorMessage.ERROR_INVALID_DOB);
        }

        if (c.EmpEngSurname.Contains(" "))
        {
            errors.addError("EmpEngSurname", HROne.Translation.PageErrorMessage.ERROR_SURNAME_CONTAIN_SPACE);
        }

        if (!errors.isEmpty())
        {
            return(false);
        }

        //if (c.EmpProbaLastDate.Ticks.Equals(0))
        //{
        //    if (c.EmpProbaPeriod > 0)
        //    {
        //        c.EmpProbaLastDate = c.EmpDateOfJoin;
        //        if (c.EmpProbaUnit.Equals("D"))
        //            c.EmpProbaLastDate = c.EmpProbaLastDate.AddDays(c.EmpProbaPeriod);
        //        else if (c.EmpProbaUnit.Equals("M"))
        //            c.EmpProbaLastDate = c.EmpProbaLastDate.AddMonths(c.EmpProbaPeriod);
        //        c.EmpProbaLastDate = c.EmpProbaLastDate.AddDays(-1);
        //    }
        //}
        if (string.IsNullOrEmpty(c.EmpStatus) || c.EmpStatus.Equals("A"))
        {
            if (WebUtils.TotalActiveEmployee(dbConn, c.EmpID) >= WebUtils.productLicense(Session).NumOfEmployees)
            {
                errors.addError(string.Format(PageErrorMessage.ERROR_MAX_LICENSE_LIMITCH_REACH, new string[] { WebUtils.productLicense(Session).NumOfEmployees + " " + HROne.Common.WebUtility.GetLocalizedString("Employee") }));
                return(false);
            }
        }

        // Start 0000092, Ricky So, 2014-09-09
        if (c.EmpNationalityID > 0)
        {
            ENationality m_nationality = new ENationality();
            m_nationality.NationalityID = c.EmpNationalityID;
            if (ENationality.db.select(dbConn, m_nationality))
            {
                c.EmpNationality = m_nationality.NationalityDesc;
            }
        }

        if (c.EmpPlaceOfBirthID > 0)
        {
            EPlaceOfBirth m_placeOfBirth = new EPlaceOfBirth();
            m_placeOfBirth.PlaceOfBirthID = c.EmpPlaceOfBirthID;
            if (EPlaceOfBirth.db.select(dbConn, m_placeOfBirth))
            {
                c.EmpPlaceOfBirth = m_placeOfBirth.PlaceOfBirthDesc;
            }
        }

        if (c.EmpPassportIssuedCountryID > 0)
        {
            EIssueCountry m_issueCountry = new EIssueCountry();
            m_issueCountry.CountryID = c.EmpPassportIssuedCountryID;
            if (EIssueCountry.db.select(dbConn, m_issueCountry))
            {
                c.EmpPassportIssuedCountry = m_issueCountry.CountryDesc;
            }
        }

        // End 0000092, Ricky So, 2014-09-09


        WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID);
        if (EmpID < 0)
        {
            //            Utils.MarkCreate(Session, c);
            c.EmpStatus = "A";
            db.insert(dbConn, c);
            EmpID = c.EmpID;
            if (PrevEmpID > 0)
            {
                if (!IsCreateNewRoleEmployee)
                {
                    EmpUtils.CopyEmpDetail(dbConn, PrevEmpID, EmpID);
                }
            }

            //            url = Utils.BuildURL(-1, CurID);
        }
        else
        {
            //            Utils.Mark(Session, c);
            db.update(dbConn, c);
        }

        //DBFilter empUniformFilter = new DBFilter();
        //empUniformFilter.add(new Match("EmpID", c.EmpID));
        //ArrayList empUniformList = EEmpUniform.db.select(dbConn, empUniformFilter);
        //EEmpUniform empUniform = null;
        //if (empUniformList.Count > 0)
        //    empUniform = (EEmpUniform)empUniformList[0];
        //else
        //{
        //    empUniform = new EEmpUniform();
        //    empUniform.EmpID = c.EmpID;
        //}
        //empUniform.EmpUniformB = EmpUniformB.Text;
        //empUniform.EmpUniformW = EmpUniformW.Text;
        //empUniform.EmpUniformH = EmpUniformH.Text;

        //if (empUniform.EmpUniformID > 0)
        //    EEmpUniform.db.update(dbConn, empUniform);
        //else
        //    EEmpUniform.db.insert(dbConn, empUniform);


        ArrayList list = new ArrayList();

        foreach (RepeaterItem groupItem in EmpExtraFieldGroupRepeater.Items)
        {
            Repeater EmpExtraField = (Repeater)groupItem.FindControl("EmpExtraField");
            foreach (RepeaterItem item in EmpExtraField.Items)
            {
                TextBox       textBox    = (TextBox)item.FindControl("EmpExtraFieldValue");
                WebDatePicker datePicker = (WebDatePicker)item.FindControl("EmpExtraFieldValueDateControl");

                int      EmpExtraFieldID = Int32.Parse(textBox.Attributes["EmpExtraFieldID"]);
                DBFilter filter          = new DBFilter();
                filter.add(new Match("EmpID", c.EmpID));
                filter.add(new Match("EmpExtraFieldID", EmpExtraFieldID));
                ArrayList existingExtraFieldValueList = EEmpExtraFieldValue.db.select(dbConn, filter);

                EEmpExtraFieldValue h = null;
                if (existingExtraFieldValueList.Count > 0)
                {
                    h = (EEmpExtraFieldValue)existingExtraFieldValueList[0];
                }
                else
                {
                    h                 = new EEmpExtraFieldValue();
                    h.EmpID           = c.EmpID;
                    h.EmpExtraFieldID = EmpExtraFieldID;
                }
                if (textBox.Visible)
                {
                    h.EmpExtraFieldValue = textBox.Text.Trim();
                }
                else if (datePicker.Visible)
                {
                    h.EmpExtraFieldValue = datePicker.Value.Trim();
                }

                list.Add(h);
            }
        }
        //filter = new DBFilter();
        //filter.add(new Match("EmpID", CurEmpID));
        //filter.add(new Match("EmpPosID", CurID));
        //EEmpHierarchy.db.delete(dbConn, filter);
        foreach (EEmpExtraFieldValue h in list)
        {
            if (h.EmpExtraFieldValueID == 0)
            {
                EEmpExtraFieldValue.db.insert(dbConn, h);
            }
            else
            {
                EEmpExtraFieldValue.db.update(dbConn, h);
            }
        }

        WebUtils.EndFunction(dbConn);
        return(true);
    }