Ejemplo n.º 1
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        ArrayList list = new ArrayList();

        foreach (RepeaterItem i in Repeater.Items)
        {
            CheckBox cb = (CheckBox)i.FindControl("ItemSelect");
            if (cb.Checked)
            {
                EEmpSpouse o = new EEmpSpouse();
                WebFormUtils.GetKeys(sdb, o, cb);
                list.Add(o);
            }
        }
        if (list.Count > 0)
        {
            WebUtils.StartFunction(Session, FUNCTION_CODE, CurID);
            foreach (BaseObject o in list)
            {
                if (sdb.select(dbConn, o))
                {
                    sdb.delete(dbConn, o);
                }
            }
            WebUtils.EndFunction(dbConn);
        }
        loadData(info, sdb, Repeater);
    }
Ejemplo n.º 2
0
        public void ImportToDatabase(int UploadEmpID)
        {
            DBFilter sessionFilter = new DBFilter();

            sessionFilter.add(new Match("SessionID", m_SessionID));
            if (UploadEmpID > 0)
            {
                sessionFilter.add(new Match("UploadEmpID", UploadEmpID));
            }
            ArrayList uploadEmpSpouseList = tempDB.select(dbConn, sessionFilter);

            foreach (EUploadEmpSpouse obj in uploadEmpSpouseList)
            {
                EEmpSpouse empSpouse = new EEmpSpouse();

                if (obj.ImportActionStatus != ImportDBObject.ImportActionEnum.INSERT)
                {
                    empSpouse.EmpSpouseID = obj.EmpSpouseID;
                    uploadDB.select(dbConn, empSpouse);
                }

                obj.ExportToObject(empSpouse);

                if (obj.ImportActionStatus == ImportDBObject.ImportActionEnum.INSERT)
                {
                    empSpouse.EmpID = ParseTemp.GetEmpIDFromUploadEmpID(dbConn, obj.UploadEmpID);
                    uploadDB.insert(dbConn, empSpouse);
                }
                else if (obj.ImportActionStatus == ImportDBObject.ImportActionEnum.UPDATE)
                {
                    uploadDB.update(dbConn, empSpouse);
                }
                tempDB.delete(dbConn, obj);
            }
        }
Ejemplo n.º 3
0
    protected void Delete_Click(object sender, EventArgs e)
    {
        EEmpSpouse c = new EEmpSpouse();

        c.EmpSpouseID = CurID;
        db.select(dbConn, c);
        WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID);
        db.delete(dbConn, c);
        WebUtils.EndFunction(dbConn);
        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "EmpTab_Family_View.aspx?EmpID=" + EmpID.Value);
    }
Ejemplo n.º 4
0
    protected bool loadObject()
    {
        obj = new EEmpSpouse();
        bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpID", CurEmpID));
        filter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        if (EEmpPersonalInfo.db.count(dbConn, filter) == 0)
        {
            if (CurEmpID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        if (!db.select(dbConn, obj))
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        if (obj.EmpID != CurEmpID)
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);


        return(true);
    }
Ejemplo n.º 5
0
    protected bool loadObject()
    {
        obj = new EEmpSpouse();
        bool isNew = WebFormWorkers.loadKeys(db, obj, DecryptedRequest);

        DBFilter filter = new DBFilter();

        filter.add(new Match("EmpID", CurEmpID));
        filter.add(WebUtils.AddRankFilter(Session, "EmpID", true));
        if (EEmpPersonalInfo.db.count(dbConn, filter) == 0)
        {
            if (CurEmpID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        if (!db.select(dbConn, obj))
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        if (obj.EmpID != CurEmpID)
        {
            if (CurID <= 0)
            {
                return(false);
            }
            else
            {
                HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "~/AccessDeny.aspx");
            }
        }

        Hashtable values = new Hashtable();

        db.populate(obj, values);
        binding.toControl(values);

        // Start 0000142, KuangWei, 2014-12-20
        double age = AppUtils.GetAge(obj.EmpSpouseDateOfBirth);

        if (!double.IsNaN(age))
        {
            lblAge.Text = HROne.CommonLib.GenericRoundingFunctions.RoundingDown(age, 0, 3).ToString("0");
        }
        else
        {
            lblAge.Text = string.Empty;
        }
        // End 0000142, KuangWei, 2014-12-20

        return(true);
    }
Ejemplo n.º 6
0
    protected void Save_Click(object sender, EventArgs e)
    {
        EEmpSpouse c = new EEmpSpouse();

        Hashtable values = new Hashtable();

        binding.toValues(values);

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

        errors.clear();

        db.validate(errors, values);

        if (EmpIsMedicalSchemaInsured.Checked)
        {
            if (string.IsNullOrEmpty(EmpMedicalEffectiveDate.TextBox.Text))
            {
                errors.addError("Please input Medical Effective Date");
            }
            if (string.IsNullOrEmpty(EmpMedicalExpiryDate.TextBox.Text))
            {
                errors.addError("Please input Expiry Date");
            }
        }


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


        db.parse(values, c);


        WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID);
        if (CurID < 0)
        {
            DBFilter filter = new DBFilter();
            filter.add(new Match("EmpID", c.EmpID));
            ArrayList list = db.select(dbConn, filter);
            if (list.Count > 0)
            {
                c.EmpSpouseID = ((EEmpSpouse)list[0]).EmpSpouseID;
                db.update(dbConn, c);
            }
            else
            {
                db.insert(dbConn, c);
            }
            CurID = c.EmpSpouseID;
        }
        else
        {
//            Utils.Mark(Session, c);
            db.update(dbConn, c);
        }
        WebUtils.EndFunction(dbConn);


        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Emp_Spouse_View.aspx?EmpSpouseID=" + CurID + "&EmpID=" + c.EmpID);
    }
Ejemplo n.º 7
0
        public DataTable UploadToTempDatabase(DataTable rawDataTable, int UserID)
        {
            if (rawDataTable == null)
            {
                return(GetImportDataFromTempDatabase(null));
            }

            int rowCount = 1;

            foreach (DataRow row in rawDataTable.Rows)
            {
                rowCount++;

                EUploadEmpSpouse uploadEmpSpouse = new EUploadEmpSpouse();
                EEmpSpouse       lastEmpSpouse   = null;

                string EmpNo = row[FIELD_EMP_NO].ToString().Trim();
                uploadEmpSpouse.EmpID = Parse.GetEmpID(dbConn, EmpNo, UserID);
                if (uploadEmpSpouse.EmpID < 0)
                {
                    errors.addError(ImportErrorMessage.ERROR_ACCESS_DENIED_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                }
                uploadEmpSpouse.EmpSpouseSurname     = row[FIELD_SURNAME].ToString();
                uploadEmpSpouse.EmpSpouseOtherName   = row[FIELD_OTHER_NAME].ToString();
                uploadEmpSpouse.EmpSpouseChineseName = row[FIELD_CHINESE_NAME].ToString();
                try
                {
                    //  support old version template
                    if (rawDataTable.Columns.Contains(FIELD_DATE_OF_BIRTH))
                    {
                        uploadEmpSpouse.EmpSpouseDateOfBirth = Import.Parse.toDateTimeObject(row[FIELD_DATE_OF_BIRTH]);
                    }
                }
                catch
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_DATE_OF_BIRTH + "=" + row[FIELD_DATE_OF_BIRTH].ToString(), EmpNo, rowCount.ToString() });
                }
                uploadEmpSpouse.EmpSpouseHKID                  = row[FIELD_HKID].ToString().Trim();
                uploadEmpSpouse.EmpSpousePassportNo            = row[FIELD_PASSPORT_NUMBER].ToString();
                uploadEmpSpouse.EmpSpousePassportIssuedCountry = row[FIELD_PASSPORT_ISSUE_COUNTRY].ToString();

                // Start 0000142, KuangWei, 2014-12-21
                uploadEmpSpouse.EmpGender = row[FIELD_SEX].ToString();

                // Start 000142, Ricky So, 2015-01-08
                //int tempInt = 0;
                //if (int.TryParse(row[FIELD_MEDICAL_SCHEME_INSURED].ToString(), out tempInt))
                //    //uploadEmpSpouse.EmpIsMedicalSchemaInsured = tempInt;
                //    uploadEmpSpouse.EmpIsMedicalSchemaInsured = true;
                //else
                //    uploadEmpSpouse.EmpIsMedicalSchemaInsured = false;
                uploadEmpSpouse.EmpIsMedicalSchemaInsured = Parse.toBoolean(row[FIELD_MEDICAL_SCHEME_INSURED].ToString());

                DateTime m_EffectiveDate = new DateTime();
                DateTime m_ExpiryDate    = new DateTime();
                // End 000142, Ricky So, 2015-01-08
                try
                {
                    //  support old version template
                    // Start 000142, Ricky So, 2015-01-08
                    //if (rawDataTable.Columns.Contains(FIELD_MEDICAL_EFFECTIVE_DATE))
                    //    uploadEmpSpouse.EmpMedicalEffectiveDate = Import.Parse.toDateTimeObject(row[FIELD_MEDICAL_EFFECTIVE_DATE]);
                    if (rawDataTable.Columns.Contains(FIELD_MEDICAL_EFFECTIVE_DATE))
                    {
                        m_EffectiveDate = Import.Parse.toDateTimeObject(row[FIELD_MEDICAL_EFFECTIVE_DATE]);
                    }
                    // End 000142, Ricky So, 2015-01-08
                }
                catch
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_MEDICAL_EFFECTIVE_DATE + "=" + row[FIELD_MEDICAL_EFFECTIVE_DATE].ToString(), EmpNo, rowCount.ToString() });
                }

                try
                {
                    //  support old version template
                    // Start 000142, Ricky So, 2015-01-08
                    //if (rawDataTable.Columns.Contains(FIELD_EXPIRY_DATE))
                    //    uploadEmpSpouse.EmpMedicalExpiryDate = Import.Parse.toDateTimeObject(row[FIELD_EXPIRY_DATE]);
                    if (rawDataTable.Columns.Contains(FIELD_EXPIRY_DATE))
                    {
                        m_ExpiryDate = Import.Parse.toDateTimeObject(row[FIELD_EXPIRY_DATE]);
                    }
                    // End 000142, Ricky So, 2015-01-08
                }
                catch
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EXPIRY_DATE + "=" + row[FIELD_EXPIRY_DATE].ToString(), EmpNo, rowCount.ToString() });
                }
                // End 0000142, KuangWei, 2014-12-21

                // Start 000142, Ricky So, 2015-01-08
                if (uploadEmpSpouse.EmpIsMedicalSchemaInsured)
                {
                    if (m_EffectiveDate.Ticks == 0)
                    {
                        errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_MEDICAL_EFFECTIVE_DATE + "=" + row[FIELD_MEDICAL_EFFECTIVE_DATE].ToString(), EmpNo, rowCount.ToString() });
                    }

                    if (m_ExpiryDate.Ticks == 0)
                    {
                        errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EXPIRY_DATE + "=" + row[FIELD_EXPIRY_DATE].ToString(), EmpNo, rowCount.ToString() });
                    }
                }
                else
                {
                    if (m_EffectiveDate.Ticks > 0)
                    {
                        errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_MEDICAL_EFFECTIVE_DATE + "=" + row[FIELD_MEDICAL_EFFECTIVE_DATE].ToString(), EmpNo, rowCount.ToString() });
                    }

                    if (m_ExpiryDate.Ticks > 0)
                    {
                        errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EXPIRY_DATE + "=" + row[FIELD_EXPIRY_DATE].ToString(), EmpNo, rowCount.ToString() });
                    }
                }
                uploadEmpSpouse.EmpMedicalEffectiveDate = m_EffectiveDate;
                uploadEmpSpouse.EmpMedicalExpiryDate    = m_ExpiryDate;
                // End 000142, Ricky So, 2015-01-08

                uploadEmpSpouse.SessionID       = m_SessionID;
                uploadEmpSpouse.TransactionDate = UploadDateTime;

                if (uploadEmpSpouse.EmpID != 0)
                {
                    //if (rawDataTable.Columns.Contains(FIELD_INTERNAL_ID))
                    //{
                    //    try
                    //    {
                    //        if (!row.IsNull(FIELD_INTERNAL_ID))
                    //        {
                    //            int tmpID = FromHexDecWithCheckDigit((string)row[FIELD_INTERNAL_ID]);
                    //            EEmpSpouse tmpObj = new EEmpSpouse();
                    //            tmpObj.EmpSpouseID = tmpID;
                    //            if (EEmpSpouse.db.select(dbConn, tmpObj))
                    //                uploadEmpSpouse.EmpSpouseID = tmpID;
                    //            else
                    //            {
                    //                errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_INTERNAL_ID + "=" + row[FIELD_INTERNAL_ID].ToString(), EmpNo, rowCount.ToString() });
                    //                continue;
                    //            }
                    //        }
                    //    }
                    //    catch (Exception ex)
                    //    {
                    //        errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_INTERNAL_ID + "=" + row[FIELD_INTERNAL_ID].ToString(), EmpNo, rowCount.ToString() });
                    //        continue;
                    //    }
                    //}
                    if (rawDataTable.Columns.Contains(FIELD_SYNC_ID))
                    {
                        if (!row.IsNull(FIELD_SYNC_ID))
                        {
                            string strSynID = row[FIELD_SYNC_ID].ToString();
                            uploadEmpSpouse.SynID = strSynID;
                            if (!string.IsNullOrEmpty(strSynID))
                            {
                                DBFilter synIDFilter = new DBFilter();
                                synIDFilter.add(new Match("SynID", strSynID));
                                ArrayList objSameSynIDList = EEmpSpouse.db.select(dbConn, synIDFilter);
                                if (objSameSynIDList.Count > 0)
                                {
                                    uploadEmpSpouse.EmpSpouseID = ((EEmpSpouse)objSameSynIDList[0]).EmpSpouseID;
                                }
                            }
                        }
                    }

                    if (uploadEmpSpouse.EmpSpouseID == 0)
                    {
                        lastEmpSpouse = (EEmpSpouse)AppUtils.GetLastObj(dbConn, uploadDB, "EmpSpouseID", uploadEmpSpouse.EmpID);
                        if (lastEmpSpouse != null)
                        {
                            if (uploadEmpSpouse.EmpSpouseHKID == lastEmpSpouse.EmpSpouseHKID &&
                                uploadEmpSpouse.EmpSpouseSurname == lastEmpSpouse.EmpSpouseSurname &&
                                uploadEmpSpouse.EmpSpouseOtherName == lastEmpSpouse.EmpSpouseOtherName &&
                                uploadEmpSpouse.EmpSpouseChineseName == lastEmpSpouse.EmpSpouseChineseName &&
                                uploadEmpSpouse.EmpSpousePassportNo == lastEmpSpouse.EmpSpousePassportNo &&
                                uploadEmpSpouse.EmpSpousePassportIssuedCountry == lastEmpSpouse.EmpSpousePassportIssuedCountry &&
                                uploadEmpSpouse.EmpSpouseDateOfBirth == lastEmpSpouse.EmpSpouseDateOfBirth
                                // Start 0000142, KuangWei, 2014-12-21
                                && uploadEmpSpouse.EmpGender == lastEmpSpouse.EmpGender &&
                                uploadEmpSpouse.EmpIsMedicalSchemaInsured == lastEmpSpouse.EmpIsMedicalSchemaInsured &&
                                uploadEmpSpouse.EmpMedicalEffectiveDate == lastEmpSpouse.EmpMedicalEffectiveDate &&
                                uploadEmpSpouse.EmpMedicalExpiryDate == lastEmpSpouse.EmpMedicalExpiryDate
                                // End 0000142, KuangWei, 2014-12-21
                                )
                            {
                                continue;
                            }
                            else
                            {
                                uploadEmpSpouse.EmpSpouseID = lastEmpSpouse.EmpSpouseID;
                            }
                        }
                    }
                }

                if (uploadEmpSpouse.EmpSpouseID <= 0)
                {
                    uploadEmpSpouse.ImportActionStatus = ImportDBObject.ImportActionEnum.INSERT;
                }
                else
                {
                    uploadEmpSpouse.ImportActionStatus = ImportDBObject.ImportActionEnum.UPDATE;
                }

                uploadEmpSpouse.UploadEmpID = ParseTemp.GetUploadEmpID(dbConn, EmpNo, m_SessionID);
                if (uploadEmpSpouse.UploadEmpID == 0)
                {
                    if (uploadEmpSpouse.EmpID == 0)
                    {
                        errors.addError(ImportErrorMessage.ERROR_INVALID_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                    }
                    else
                    {
                        uploadEmpSpouse.UploadEmpID = ImportEmpPersonalInfoProcess.CreateDummyUploadEmployeeInfo(dbConn, uploadEmpSpouse.EmpID, m_SessionID, UploadDateTime);
                    }
                }

                Hashtable values = new Hashtable();
                tempDB.populate(uploadEmpSpouse, values);
                PageErrors pageErrors = new PageErrors(EUploadEmpPersonalInfo.db);
                tempDB.validate(pageErrors, values);
                if (pageErrors.errors.Count == 0)
                {
                    tempDB.insert(dbConn, uploadEmpSpouse);
                }
                else
                {
                    pageErrors.addError(rawDataTable.TableName);
                    throw new HRImportException(pageErrors.getPrompt() + "(line " + rowCount.ToString() + ")");
                }
            }
            if (errors.List.Count > 0)
            {
                ClearTempTable();
                throw (new HRImportException(rawDataTable.TableName + "\r\n" + errors.Message()));
            }
            return(GetImportDataFromTempDatabase(null));
        }