コード例 #1
0
        public override bool Load(int id)
        {
            //Get the entity object from the DAL.
            PTORequest pTORequest = new PTORequestData().Select(id);

            MapEntityToProperties(pTORequest);

            //Chapter 12
            StorePropertyValues();
            return(true);
        }
コード例 #2
0
        public static void GetUsed(ref double usedPersonalDays, ref double usedVacationDays, ref double unpaid,
                                   int ptoRequestId, int userAccountId, short year)
        {
            var result = new PTORequestData().SelectByENTUserAccountIdYear(ptoRequestId, userAccountId, year);

            if (result != null)
            {
                usedVacationDays = Convert.ToDouble(result.CountOfFullVacation + result.CountOfHalfVacation);
                usedPersonalDays = Convert.ToDouble(result.CountOfFullPersonal + result.CountOfHalfPersonal);
                unpaid           = Convert.ToDouble(result.CountOfFullUnpaid + result.CountOfHalfUnPaid);
            }
            else
            {
                usedPersonalDays = 0;
                usedVacationDays = 0;
                unpaid           = 0;
            }
        }
コード例 #3
0
        public override bool Save(HRPaidTimeOffDataContext db, ref ENTValidationErrors validationErrors, int userAccountId)
        {
            if (DBAction == DBActionEnum.Save)
            {
                //Validate the object
                Validate(db, ref validationErrors);

                //Check if there were any validation errors
                if (validationErrors.Count == 0)
                {
                    bool isNewRecord = IsNewRecord();
                    if (isNewRecord)
                    {
                        //Add
                        ID = new PTORequestData().Insert(db, ENTUserAccountId, RequestDate, Convert.ToInt32(PTODayTypeId), Convert.ToInt32(PTORequestTypeId), userAccountId);

                        AuditAdd(db, ref validationErrors, userAccountId);
                    }
                    else
                    {
                        //Update
                        if (!new PTORequestData().Update(db, ID, ENTUserAccountId, RequestDate, Convert.ToInt32(PTODayTypeId), Convert.ToInt32(PTORequestTypeId), userAccountId, Version))
                        {
                            UpdateFailed(ref validationErrors);
                            if (isNewRecord)
                            {
                                ID = 0;
                            }
                            return(false);
                        }
                        else
                        {
                            AuditUpdate(db, ref validationErrors, userAccountId);
                        }
                    }

                    if (base.SaveWorkflow(db, ref validationErrors, this, userAccountId))
                    {
                        return(true);
                    }
                    else
                    {
                        if (isNewRecord)
                        {
                            ID = 0;
                        }
                        return(false);
                    }
                }
                else
                {
                    //Didn't pass validation.
                    ID = 0;
                    return(false);
                }
            }
            else
            {
                throw new Exception("DBAction not Save.");
            }
        }