Exemple #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)
            {
                EEmpPlaceOfResidence o = new EEmpPlaceOfResidence();
                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);
    }
    protected void Delete_Click(object sender, EventArgs e)
    {
        EEmpPlaceOfResidence c = new EEmpPlaceOfResidence();

        c.EmpPoRID = 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_Residence_View.aspx?EmpID=" + EmpID.Value);
    }
    protected bool loadObject()
    {
        obj = new EEmpPlaceOfResidence();
        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);
    }
Exemple #4
0
    private void ValidateData(EEmpPlaceOfResidence obj, PageErrors errors)
    {
        DBFilter overlapCheckingFilter = new DBFilter();

        overlapCheckingFilter.add(new Match("EmpID", obj.EmpID));
        if (obj.EmpPoRID > 0)
        {
            overlapCheckingFilter.add(new Match("EmpPoRID", "<>", obj.EmpPoRID));
        }
        overlapCheckingFilter.add(new Match("EmpPoRTo", ">=", obj.EmpPoRFrom));
        overlapCheckingFilter.add(new Match("EmpPoRFrom", "<=", obj.EmpPoRTo.Ticks.Equals(0) ? DateTime.MaxValue : obj.EmpPoRTo));

        if (EEmpPlaceOfResidence.db.count(dbConn, overlapCheckingFilter) > 0)
        {
            errors.addError(HROne.Translation.PageErrorMessage.ERROR_INCORRECT_DATE_RANGE);
        }
    }
Exemple #5
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 uploadEmpPoRList = tempDB.select(dbConn, sessionFilter);

            foreach (EUploadEmpPlaceOfResidence obj in uploadEmpPoRList)
            {
                EEmpPlaceOfResidence empPoR = new EEmpPlaceOfResidence();

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

                obj.ExportToObject(empPoR);

                if (obj.ImportActionStatus == ImportDBObject.ImportActionEnum.INSERT)
                {
                    DBFilter             emplastPosFilter = new DBFilter();
                    EEmpPlaceOfResidence lastObj          = (EEmpPlaceOfResidence)AppUtils.GetLastObj(dbConn, uploadDB, "EmpPoRFrom", empPoR.EmpID, new Match("EmpPoRFrom", "<", empPoR.EmpPoRFrom));
                    if (lastObj != null)
                    {
                        if (lastObj.EmpPoRTo.Ticks == 0)
                        {
                            lastObj.EmpPoRTo = empPoR.EmpPoRFrom.AddDays(-1);
                            uploadDB.update(dbConn, lastObj);
                        }
                    }
                    empPoR.EmpID = ParseTemp.GetEmpIDFromUploadEmpID(dbConn, obj.UploadEmpID);
                    uploadDB.insert(dbConn, empPoR);
                }
                else if (obj.ImportActionStatus == ImportDBObject.ImportActionEnum.UPDATE)
                {
                    uploadDB.update(dbConn, empPoR);
                }
                tempDB.delete(dbConn, obj);
            }
        }
Exemple #6
0
        public DataTable UploadToTempDatabase(DataTable rawDataTable, int UserID)
        {
            if (rawDataTable == null)
            {
                return(GetImportDataFromTempDatabase(null));
            }

            int rowCount = 1;

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

                EUploadEmpPlaceOfResidence uploadEmpPoR = new EUploadEmpPlaceOfResidence();
                EEmpPlaceOfResidence       lastEmpPoR   = null;

                string EmpNo = row[FIELD_EMP_NO].ToString().Trim();
                uploadEmpPoR.EmpID = Parse.GetEmpID(dbConn, EmpNo, UserID);
                if (uploadEmpPoR.EmpID < 0)
                {
                    errors.addError(ImportErrorMessage.ERROR_ACCESS_DENIED_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                }
                try
                {
                    uploadEmpPoR.EmpPoRFrom = Parse.toDateTimeObject(row[FIELD_FROM]);
                }
                catch
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_FROM + "=" + row[FIELD_FROM].ToString(), EmpNo, rowCount.ToString() });
                }
                try
                {
                    uploadEmpPoR.EmpPoRTo = Parse.toDateTimeObject(row[FIELD_TO]);
                }
                catch
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_TO + "=" + row[FIELD_TO].ToString(), EmpNo, rowCount.ToString() });
                }
                uploadEmpPoR.EmpPoRNature       = row[FIELD_NATURE].ToString();
                uploadEmpPoR.EmpPoRLandLord     = row[FIELD_LANDLORD].ToString();
                uploadEmpPoR.EmpPoRPropertyAddr = row[FIELD_ADDRESS].ToString();
                uploadEmpPoR.EmpPoRLandLordAddr = row[FIELD_LANDLORD_ADDRESS].ToString();

                double amount = 0;
                if (double.TryParse(row[FIELD_ER_RENT_PAID].ToString(), out amount))
                {
                    uploadEmpPoR.EmpPoRPayToLandER = amount;
                }
                else
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_ER_RENT_PAID + "=" + row[FIELD_ER_RENT_PAID].ToString(), EmpNo, rowCount.ToString() });
                }

                if (double.TryParse(row[FIELD_EE_RENT_PAID].ToString(), out amount))
                {
                    uploadEmpPoR.EmpPoRPayToLandEE = amount;
                }
                else
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EE_RENT_PAID + "=" + row[FIELD_EE_RENT_PAID].ToString(), EmpNo, rowCount.ToString() });
                }

                if (double.TryParse(row[FIELD_EE_RENT_REFUND].ToString(), out amount))
                {
                    uploadEmpPoR.EmpPoRRefundToEE = amount;
                }
                else
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EE_RENT_REFUND + "=" + row[FIELD_EE_RENT_REFUND].ToString(), EmpNo, rowCount.ToString() });
                }

                if (double.TryParse(row[FIELD_EE_RENT_PAID_TO_ER].ToString(), out amount))
                {
                    uploadEmpPoR.EmpPoRPayToERByEE = amount;
                }
                else
                {
                    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EE_RENT_PAID_TO_ER + "=" + row[FIELD_EE_RENT_PAID_TO_ER].ToString(), EmpNo, rowCount.ToString() });
                }

                //uploadEmpPoR.EmpPoRPayToLandER = double.Parse(row[FIELD_ER_RENT_PAID].ToString());
                //uploadEmpPoR.EmpPoRPayToLandEE = double.Parse(row[FIELD_EE_RENT_PAID].ToString());
                //uploadEmpPoR.EmpPoRRefundToEE  = double.Parse(row[FIELD_EE_RENT_REFUND].ToString());
                //uploadEmpPoR.EmpPoRPayToERByEE = double.Parse(row[FIELD_EE_RENT_PAID_TO_ER].ToString());


                uploadEmpPoR.SessionID       = m_SessionID;
                uploadEmpPoR.TransactionDate = UploadDateTime;


                if (uploadEmpPoR.EmpID != 0)
                {
                    AND andTerms = new AND();
                    andTerms.add(new Match("EmpPoRFrom", "<=", uploadEmpPoR.EmpPoRFrom));

                    lastEmpPoR = (EEmpPlaceOfResidence)AppUtils.GetLastObj(dbConn, uploadDB, "EmpPoRFrom", uploadEmpPoR.EmpID, andTerms);
                    if (lastEmpPoR != null)
                    {
                        if (uploadEmpPoR.EmpPoRNature == lastEmpPoR.EmpPoRNature &&
                            uploadEmpPoR.EmpPoRLandLord == lastEmpPoR.EmpPoRLandLord &&
                            uploadEmpPoR.EmpPoRPropertyAddr == lastEmpPoR.EmpPoRPropertyAddr &&
                            uploadEmpPoR.EmpPoRLandLordAddr == lastEmpPoR.EmpPoRLandLordAddr &&
                            uploadEmpPoR.EmpPoRTo == lastEmpPoR.EmpPoRTo
                            )
                        {
                            continue;
                        }
                        else
                        {
                            // add postion terms with new ID
                            if (lastEmpPoR.EmpPoRFrom.Equals(uploadEmpPoR.EmpPoRFrom))
                            {
                                uploadEmpPoR.EmpPoRID = lastEmpPoR.EmpPoRID;
                                if (uploadEmpPoR.EmpPoRTo.Ticks == 0 && lastEmpPoR.EmpPoRTo.Ticks != 0)
                                {
                                    EEmpPlaceOfResidence afterEmPoR = (EEmpPlaceOfResidence)AppUtils.GetLastObj(dbConn, uploadDB, "EmpPoRFrom", uploadEmpPoR.EmpID, new Match("EmpPoRFrom", ">", lastEmpPoR.EmpPoRTo));
                                    if (afterEmPoR != null)
                                    {
                                        uploadEmpPoR.EmpPoRTo = afterEmPoR.EmpPoRFrom.AddDays(-1);
                                    }
                                }
                            }
                            else
                            {
                                EEmpPlaceOfResidence lastObj = (EEmpPlaceOfResidence)AppUtils.GetLastObj(dbConn, uploadDB, "EmpPoRFrom", uploadEmpPoR.EmpID);
                                if (lastObj != null && uploadEmpPoR.EmpPoRFrom <= lastObj.EmpPoRFrom)
                                {
                                    errors.addError(ImportErrorMessage.ERROR_DATE_FROM_OVERLAP, new string[] { uploadEmpPoR.EmpPoRFrom.ToString("yyyy-MM-dd"), rowCount.ToString() });
                                    continue;
                                }
                            }
                        }
                    }
                }

                //if (rawDataTable.Columns.Contains(FIELD_INTERNAL_ID))
                //{
                //    try
                //    {
                //        if (!row.IsNull(FIELD_INTERNAL_ID))
                //        {
                //            int tmpID = FromHexDecWithCheckDigit((string)row[FIELD_INTERNAL_ID]);
                //            EEmpPlaceOfResidence tmpObj = new EEmpPlaceOfResidence();
                //            tmpObj.EmpPoRID = tmpID;
                //            if (EEmpPlaceOfResidence.db.select(dbConn, tmpObj))
                //                uploadEmpPoR.EmpPoRID = 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();
                        uploadEmpPoR.SynID = strSynID;
                        if (!string.IsNullOrEmpty(strSynID))
                        {
                            DBFilter synIDFilter = new DBFilter();
                            synIDFilter.add(new Match("SynID", strSynID));
                            ArrayList objSameSynIDList = EEmpPlaceOfResidence.db.select(dbConn, synIDFilter);
                            if (objSameSynIDList.Count > 0)
                            {
                                uploadEmpPoR.EmpPoRID = ((EEmpPlaceOfResidence)objSameSynIDList[0]).EmpPoRID;
                            }
                        }
                    }
                }

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

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

                Hashtable values = new Hashtable();
                tempDB.populate(uploadEmpPoR, values);
                PageErrors pageErrors = new PageErrors(EUploadEmpPersonalInfo.db);
                tempDB.validate(pageErrors, values);
                if (pageErrors.errors.Count == 0)
                {
                    tempDB.insert(dbConn, uploadEmpPoR);
                }
                else
                {
                    pageErrors.addError(rawDataTable.TableName);
                    throw new HRImportException(pageErrors.getPrompt() + "(line " + rowCount.ToString() + ")");

                    //if (EmpID == 0)
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_EMP_NO, new string[] { EmpNo, rowCount.ToString() });
                    //else if (PayCodeID == 0)
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_PAYMENT_CODE + "=" + PaymentCode, EmpNo, rowCount.ToString() });
                    //else if (PayCodeID == 0)
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_PAYMENT_CODE + "=" + PaymentCode, EmpNo, rowCount.ToString() });
                    //else if (EffDate.Ticks == 0)
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_EFFECTIVE_DATE + "=" + EffDateString, EmpNo, rowCount.ToString() });
                    //else if (double.TryParse(amountString, out amount))
                    //    errors.addError(ImportErrorMessage.ERROR_INVALID_FIELD_VALUE, new string[] { FIELD_AMOUNT + "=" + amountString, EmpNo, rowCount.ToString() });
                }
            }
            if (errors.List.Count > 0)
            {
                ClearTempTable();
                throw (new HRImportException(rawDataTable.TableName + "\r\n" + errors.Message()));
            }
            return(GetImportDataFromTempDatabase(null));
        }
Exemple #7
0
    protected void Save_Click(object sender, EventArgs e)
    {
        EEmpPlaceOfResidence c = new EEmpPlaceOfResidence();

        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);

        ValidateData(c, errors);

        if (c.EmpPoRTo != DateTime.MinValue && c.EmpPoRFrom > c.EmpPoRTo)
        {
            errors.addError("EmpPoRFrom", HROne.Translation.PageErrorMessage.ERROR_DATE_TO_TOO_EARLY);
        }

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

        EEmpPlaceOfResidence prev = (EEmpPlaceOfResidence)AppUtils.GetLastObj(dbConn, EEmpPlaceOfResidence.db, "EmpPoRFrom", CurEmpID);

        if (prev != null && prev.EmpPoRID != CurID)
        {
            if (prev.EmpPoRTo.Ticks.Equals(0))
            {
                if (prev.EmpPoRFrom <= c.EmpPoRFrom.AddDays(-1))
                {
                    prev.EmpPoRTo = c.EmpPoRFrom.AddDays(-1);
                    db.update(dbConn, prev);
                }
                else
                if (c.EmpPoRTo.Ticks.Equals(0))
                {
                    errors.addError(HROne.Translation.PageErrorMessage.ERROR_DATE_FROM_OVERLAP);
                }
            }
        }

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

        WebUtils.StartFunction(Session, FUNCTION_CODE, c.EmpID);
        if (CurID < 0)
        {
//            Utils.MarkCreate(Session, c);

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


        HROne.Common.WebUtility.RedirectURLwithEncryptedQueryString(Response, Session, "Emp_Residence_View.aspx?EmpPoRID=" + CurID + "&EmpID=" + c.EmpID);
    }