public ActionResult Edit(ScholarshipsViewModel ScholarshipVM) { BaseScholarshipsBLL Scholarship = null; if (ScholarshipVM.ScholarshipType.ScholarshipTypeID == (int)ScholarshipsTypesEnum.Internal) { Scholarship = GenericFactoryPattern <BaseScholarshipsBLL, InternalScholarshipsBLL> .CreateInstance(); ((InternalScholarshipsBLL)Scholarship).Location = ScholarshipVM.Location; } else if (ScholarshipVM.ScholarshipType.ScholarshipTypeID == (int)ScholarshipsTypesEnum.External) { Scholarship = GenericFactoryPattern <BaseScholarshipsBLL, ExternalScholarshipsBLL> .CreateInstance(); } Scholarship.ScholarshipID = ScholarshipVM.ScholarshipID; Scholarship.ScholarshipStartDate = ScholarshipVM.ScholarshipStartDate.Value.Date; Scholarship.ScholarshipEndDate = ScholarshipVM.ScholarshipEndDate.Value.Date; Scholarship.ScholarshipReason = ScholarshipVM.ScholarshipReason; Scholarship.LoginIdentity = this.UserIdentity; Result result = Scholarship.Edit(); if (result.EnumMember == ScholarshipsValidationEnum.RejectedBecauseOfAlreadyCanceled.ToString()) { throw new CustomException(Resources.Globalization.ValidationScholarshipsAlreadyCanceledText); } else if (result.EnumMember == ScholarshipsValidationEnum.RejectedBecauseOfAlreadyPassed.ToString()) { throw new CustomException(Resources.Globalization.ValidationScholarshipsAlreadyPassedText); } Classes.Helpers.CommonHelper.ConflictValidationMessage(result); return(Json(new { ScholarshipID = Scholarship.ScholarshipID }, JsonRequestBehavior.AllowGet)); }
public void GetVacationBalances(string EndOfServiceID, out string TotalDeservedBalance, out string TotalConsumedBalance, out string TotalRemainingBalance, out string TotalDeservedRemainingBalance) { int endOfServiceID = int.Parse(EndOfServiceID); EndOfServicesBLL EndOfServices = new EndOfServicesBLL().GetByEndOfServiceID(endOfServiceID); //--======== Culculate Noraml vacation . var Vacation = GenericFactoryPattern <BaseVacationsBLL, NormalVacationsBLL> .CreateInstance(); Vacation.VacationStartDate = Convert.ToDateTime(EndOfServices.EndOfServiceDate.ToString(ConfigurationManager.AppSettings["DateFormat"]), new CultureInfo("ar-SA")); //EndOfServices.EndOfServiceDate; int UmAlQuraYear, UmAlQuraMonth, UmAlQuraDay; UmAlQuraYear = Globals.Calendar.GetUmAlQuraYear(EndOfServices.EndOfServiceDate); UmAlQuraMonth = Globals.Calendar.GetUmAlQuraMonth(EndOfServices.EndOfServiceDate); UmAlQuraDay = Globals.Calendar.GetUmAlQuraDay(EndOfServices.EndOfServiceDate); ((NormalVacationsBLL)Vacation).GetVacationBalances(EndOfServices.EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, UmAlQuraYear, UmAlQuraMonth, UmAlQuraDay); //--======== Culculate EndOfService Vacation . int TotalEndOfServiceVacationsConsumedBalance = 0; List <EndOfServicesVacationsBLL> EndOfServicesVacationsList = new EndOfServicesVacationsBLL().GetByEndOfServiceID(endOfServiceID); foreach (EndOfServicesVacationsBLL EndOfServiceVacation in EndOfServicesVacationsList) { if (EndOfServiceVacation.VacationType.VacationTypeID == (int)VacationsTypesEnum.Normal) { TotalEndOfServiceVacationsConsumedBalance += EndOfServiceVacation.VacationPeriod; } } int MaxNormalCompensation = new EndOfServicesVacationsBLL().MaxNormalCompensation; TotalDeservedBalance = (Vacation as NormalVacationsBLL).TotalDeservedBalance.ToString(); TotalConsumedBalance = ((Vacation as NormalVacationsBLL).TotalConsumedBalance + TotalEndOfServiceVacationsConsumedBalance).ToString(); TotalRemainingBalance = ((Vacation as NormalVacationsBLL).TotalRemainingBalance - TotalEndOfServiceVacationsConsumedBalance).ToString(); TotalDeservedRemainingBalance = int.Parse(TotalRemainingBalance) >= MaxNormalCompensation?MaxNormalCompensation.ToString() : TotalRemainingBalance; }
public ActionResult EditEmployeeTransfer(TransfersViewModel EmployeesTransferVM) { BaseTransfersBLL TransferEmployee = new BaseTransfersBLL(); if (EmployeesTransferVM.TransfersTypes.TransferTypeID == Convert.ToInt16(TransfersTypesEnum.TransferEmployeeWithJob)) { TransferEmployee = GenericFactoryPattern <BaseTransfersBLL, TransferEmployeesWithJobBLL> .CreateInstance(); } else if (EmployeesTransferVM.TransfersTypes.TransferTypeID == Convert.ToInt16(TransfersTypesEnum.TransferEmployeeWithoutJob)) { TransferEmployee = GenericFactoryPattern <BaseTransfersBLL, TransferEmployeesWithoutJobBLL> .CreateInstance(); ((TransferEmployeesWithoutJobBLL)TransferEmployee).JobName = EmployeesTransferVM.JobName; ((TransferEmployeesWithoutJobBLL)TransferEmployee).RankName = EmployeesTransferVM.RankName; ((TransferEmployeesWithoutJobBLL)TransferEmployee).JobCode = EmployeesTransferVM.JobCode; ((TransferEmployeesWithoutJobBLL)TransferEmployee).CareerDegreeName = EmployeesTransferVM.CareerDegreeName; ((TransferEmployeesWithoutJobBLL)TransferEmployee).OrganizationName = EmployeesTransferVM.OrganizationName; } TransferEmployee.TransferID = EmployeesTransferVM.TransferID; TransferEmployee.LoginIdentity = this.UserIdentity; TransferEmployee.TransferType = new TransfersTypesBLL() { TransferTypeID = EmployeesTransferVM.TransfersTypes.TransferTypeID }; TransferEmployee.Destination = EmployeesTransferVM.Destination; TransferEmployee.KSACity = new KSACitiesBLL() { KSACityID = EmployeesTransferVM.KSACity.KSACityID }; TransferEmployee.TransferDate = EmployeesTransferVM.TransferDate; TransferEmployee.EmployeeCareerHistory = new EmployeesCareersHistoryBLL() { EmployeeCareerHistoryID = EmployeesTransferVM.EmployeeCareerHistoryID }; Result result = TransferEmployee.Update(); if (result.EnumMember == TransfersValidationEnum.Done.ToString()) { Session["TransferID"] = TransferEmployee.TransferID; } else if (result.EnumMember == TransfersValidationEnum.RejectedBecauseOfTransferDateIsLessThanHiringDateDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfTransferDateIsLessThanHiringDateText); } else if (result.EnumMember == TransfersValidationEnum.RejectedBecauseOfAlreadyProcessed.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfBecauseOfAlreadyProcessedText); } return(View(this.GetByTransferID(EmployeesTransferVM.TransferID))); }
public HttpResponseMessage GetVacationBalanceByEmployeeCodeNo(VacationsTypesEnum VacationType, string EmployeeCodeNo) { if (string.IsNullOrEmpty(EmployeeCodeNo)) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } EmployeesCodesBLL emp = new EmployeesCodesBLL().GetByEmployeeCodeNo(EmployeeCodeNo); if (emp != null) { BaseVacationsBLL Vacation = GenericFactoryPattern <BaseVacationsBLL, NormalVacationsBLL> .CreateInstance(); DateTime CurrentDate = DateTime.Now.Date; int MaturityYearFromCurrentDate = Globals.Calendar.GetUmAlQuraYear(CurrentDate); int MaturityMonthFromCurrentDate = Globals.Calendar.GetUmAlQuraMonth(CurrentDate); int MaturityDayFromCurrentDate = Globals.Calendar.GetUmAlQuraDay(CurrentDate); ((NormalVacationsBLL)Vacation).GetVacationBalances(emp.EmployeeCodeID, MaturityYearFromCurrentDate, MaturityMonthFromCurrentDate, MaturityDayFromCurrentDate); return(Request.CreateResponse(HttpStatusCode.OK, (NormalVacationsBLL)Vacation)); //return Request.CreateResponse(HttpStatusCode.OK, new //{ // EmployeeCodeID = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.EmployeeCodeID, // EmployeeCodeNo = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.EmployeeCodeNo, // EmployeeNameAr = ((NormalVacationsBLL)Vacation).EmployeeCareerHistory.EmployeeCode.Employee.EmployeeNameAr, // DeservedOldBalance = ((NormalVacationsBLL)Vacation).DeservedOldBalance, // ConsumedOldBalance = ((NormalVacationsBLL)Vacation).ConsumedOldBalance, // RemainingOldBalance = ((NormalVacationsBLL)Vacation).RemainingOldBalance, // DeservedCurrentBalance = ((NormalVacationsBLL)Vacation).DeservedCurrentBalance, // ConsumedCurrentBalance = ((NormalVacationsBLL)Vacation).ConsumedCurrentBalance, // ExpiredCurrentBalance = ((NormalVacationsBLL)Vacation).ExpiredCurrentBalance, // RemainingCurrentBalance = ((NormalVacationsBLL)Vacation).RemainingCurrentBalance, // TotalDeservedBalance = ((NormalVacationsBLL)Vacation).TotalDeservedBalance, // TotalConsumedBalance = ((NormalVacationsBLL)Vacation).TotalConsumedBalance, // TotalRemainingBalance = ((NormalVacationsBLL)Vacation).TotalRemainingBalance, // TotalConsumedSeparatedDays = ((NormalVacationsBLL)Vacation).TotalConsumedSeparatedDays, // InAdvanceBalance = ((NormalVacationsBLL)Vacation).InAdvanceBalance, // TotalAvailableVacationBalance = ((NormalVacationsBLL)Vacation).TotalAvailableVacationBalance, //}.ToXml()); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Employee not found!")); } }
public ActionResult Joining(ScholarshipsJoiningViewModel ScholarshipVM) { BaseScholarshipsBLL Scholarship = null; if (ScholarshipVM.ScholarshipTypeID == (int)ScholarshipsTypesEnum.Internal) { Scholarship = GenericFactoryPattern <BaseScholarshipsBLL, InternalScholarshipsBLL> .CreateInstance(); } else if (ScholarshipVM.ScholarshipTypeID == (int)ScholarshipsTypesEnum.External) { Scholarship = GenericFactoryPattern <BaseScholarshipsBLL, ExternalScholarshipsBLL> .CreateInstance(); } Scholarship.ScholarshipID = ScholarshipVM.ScholarshipID; Scholarship.ScholarshipStartDate = ScholarshipVM.ScholarshipStartDate.Value.Date; Scholarship.ScholarshipEndDate = ScholarshipVM.ScholarshipEndDate.Value.Date; Scholarship.ScholarshipJoinDate = ScholarshipVM.ScholarshipJoinDate.Value.Date; Scholarship.IsPassed = ScholarshipVM.IsPassed; Scholarship.Notes = ScholarshipVM.Notes; Scholarship.LoginIdentity = this.UserIdentity; Result result = Scholarship.Joining(); if (result.EnumMember == ScholarshipsValidationEnum.RejectedBecauseOfAlreadyCanceled.ToString()) { throw new CustomException(Resources.Globalization.ValidationScholarshipsAlreadyCanceledText); } else if (result.EnumMember == ScholarshipsValidationEnum.RejectedBecauseOfAlreadyPassed.ToString()) { throw new CustomException(Resources.Globalization.ValidationScholarshipsAlreadyPassedText); } else if (result.EnumMember == ScholarshipsValidationEnum.RejectedBecauseOfAlreadyJoinedBefore.ToString()) { throw new CustomException(Resources.Globalization.ValidationScholarshipsAlreadyJoinedDateText); } else if (result.EnumMember == ScholarshipsValidationEnum.RejectedBecauseOfScholarshipJoinDateBeforeScholarshipStartDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationScholarshipJoinDateBeforeScholarshipStartDateText); } else { return(Json(new { ScholarshipID = Scholarship.ScholarshipID }, JsonRequestBehavior.AllowGet)); } }
public ActionResult Create(ScholarshipsViewModel ScholarshipVM) { BaseScholarshipsBLL EmployeeScholarship = null; switch (ScholarshipVM.ScholarshipType.ScholarshipTypeID) { case (int)ScholarshipsTypesEnum.Internal: { EmployeeScholarship = GenericFactoryPattern <BaseScholarshipsBLL, InternalScholarshipsBLL> .CreateInstance(); EmployeeScholarship.ScholarshipTypeEnum = (ScholarshipsTypesEnum)ScholarshipVM.ScholarshipType.ScholarshipTypeID; EmployeeScholarship.ScholarshipStartDate = ScholarshipVM.ScholarshipStartDate.Value; EmployeeScholarship.ScholarshipEndDate = ScholarshipVM.ScholarshipEndDate.Value; EmployeeScholarship.Employee = new EmployeesCodesBLL() { EmployeeCodeID = ScholarshipVM.EmployeeCodeID }; ((InternalScholarshipsBLL)EmployeeScholarship).Location = ScholarshipVM.Location; ((InternalScholarshipsBLL)EmployeeScholarship).KSACity = new KSACitiesBLL() { KSACityID = ScholarshipVM.KSACity.KSACityID }; EmployeeScholarship.ScholarshipReason = ScholarshipVM.ScholarshipReason; EmployeeScholarship.Qualification = new QualificationsBLL() { QualificationID = ScholarshipVM.Qualification.QualificationID }; EmployeeScholarship.LoginIdentity = UserIdentity; Result result = EmployeeScholarship.Add(); if (result.EnumMember == ScholarshipsValidationEnum.Done.ToString()) { ScholarshipVM.ScholarshipID = ((InternalScholarshipsBLL)result.Entity).ScholarshipID; } Classes.Helpers.CommonHelper.ConflictValidationMessage(result); break; } case (int)ScholarshipsTypesEnum.External: { EmployeeScholarship = GenericFactoryPattern <BaseScholarshipsBLL, ExternalScholarshipsBLL> .CreateInstance(); EmployeeScholarship.ScholarshipTypeEnum = (ScholarshipsTypesEnum)ScholarshipVM.ScholarshipType.ScholarshipTypeID; EmployeeScholarship.ScholarshipStartDate = ScholarshipVM.ScholarshipStartDate.Value; EmployeeScholarship.ScholarshipEndDate = ScholarshipVM.ScholarshipEndDate.Value; EmployeeScholarship.Employee = new EmployeesCodesBLL() { EmployeeCodeID = ScholarshipVM.EmployeeCodeID }; EmployeeScholarship.ScholarshipReason = ScholarshipVM.ScholarshipReason; ((ExternalScholarshipsBLL)EmployeeScholarship).Country = new CountriesBLL() { CountryID = ScholarshipVM.Country.CountryID }; EmployeeScholarship.Qualification = new QualificationsBLL() { QualificationID = ScholarshipVM.Qualification.QualificationID }; EmployeeScholarship.LoginIdentity = UserIdentity; Result result = EmployeeScholarship.Add(); if (result.EnumMember == ScholarshipsValidationEnum.Done.ToString()) { ScholarshipVM.ScholarshipID = ((ExternalScholarshipsBLL)result.Entity).ScholarshipID; } Classes.Helpers.CommonHelper.ConflictValidationMessage(result); break; } default: break; } return(Json(new { ScholarshipID = ScholarshipVM.ScholarshipID }, JsonRequestBehavior.AllowGet)); }
public ActionResult Create(VacationsViewModel VacationVM) { BaseVacationsBLL Vacation = null; if (!VacationVM.VacationStartDate.HasValue || !VacationVM.VacationEndDate.HasValue) { throw new CustomException(Resources.Globalization.RequiredStartDateAndEndDateText); } if (VacationVM.VacationType.VacationTypeID == (int)VacationsTypesEnum.Normal) { Vacation = GenericFactoryPattern <BaseVacationsBLL, NormalVacationsBLL> .CreateInstance(); if (VacationVM.NormalVacationTypeID.HasValue) { ((NormalVacationsBLL)Vacation).NormalVacationType = new NormalVacationsTypesBLL() { NormalVacationTypeID = VacationVM.NormalVacationTypeID.Value } } ; } Vacation.EmployeeCareerHistory = new EmployeesCareersHistoryBLL().GetEmployeeCurrentJob(VacationVM.EmployeeCodeID.Value); Vacation.VacationType = (VacationsTypesEnum)VacationVM.VacationType.VacationTypeID; Vacation.VacationStartDate = VacationVM.VacationStartDate.Value.Date; Vacation.VacationEndDate = VacationVM.VacationEndDate.Value.Date; Vacation.Notes = VacationVM.Notes; Vacation.IsApprovedFromManager = false; Vacation.LoginIdentity = new EmployeesCodesBLL() { EmployeeCodeNo = this.WindowsUserIdentity, EmployeeCodeID = VacationVM.EmployeeCodeID.Value }; Result result = Vacation.Add(); if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfBeforeHiringDate.ToString()) { throw new CustomException(string.Format(Resources.Globalization.ValidationVacationBeforeHiringText, ((EmployeesCareersHistoryBLL)result.Entity).JoinDate.ToString(Classes.Helpers.CommonHelper.DateFormat))); } else if (result.EnumMember == VacationsValidationEnum.RejectedBeacuseOfEmployeeNotHasActualOrganization.ToString()) { throw new CustomException(Resources.Globalization.ValidationEmployeeNotHasActualOrganizationText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfDuringProbation.ToString()) { throw new CustomException(string.Format(Resources.Globalization.ValidationVacationDuringProbationText, ((EmployeesCareersHistoryBLL)result.Entity).ProbationEndDate.ToString(Classes.Helpers.CommonHelper.DateFormat))); } else if (result.EnumMember == VacationsValidationEnum.SportsSeasonDoesNotExist.ToString()) { throw new CustomException(Resources.Globalization.SportsSeasonDoesNotExistText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfInvalidDates.ToString()) { throw new CustomException(Resources.Globalization.ValidationInvalidDateText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfInvalidSportsDates.ToString()) { throw new CustomException(Resources.Globalization.ValidationInvalidSportsDateText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfNoBalance.ToString()) { throw new CustomException(Resources.Globalization.ValidationAlreadyReachTheVacationLimitText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfInvalidStartDate.ToString()) { throw new CustomException(Resources.Globalization.ValidationInvalidVacationStartDateText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfConsumedMaxLimit.ToString()) { throw new CustomException(Resources.Globalization.ValidationAlreadyReachTheNormalVacationLimitText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfNormalVacationBalanceExists.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfNormalVacationBalanceExistsText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfNormalVacationReachedToMaxLimitOfSeparatedDays.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfNormalVacationReachedToMaxLimitOfSeparatedDaysText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfVacationNotAllowedBetween1437and1438.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfVacationNotAllowedBetween1437and1438Text); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfVacationOutOfRange.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfVacationOutOfRangeText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseSickExceptionalVacationDatesOutOfRange.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfSickExceptionalVacationDatesOutOfRangeText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfErrorInTimeAttendanceApp.ToString()) { throw new CustomException(Resources.Globalization.ErrorInTimeAttendanceAppText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfMarriageVacationAcceptedOneTime.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfMarriageVacationAcceptedOneTimeText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfNoActiveProxyCreatedToOtherPerson.ToString()) { throw new CustomException(Resources.Globalization.ValidationBecauseOfNoActiveProxyCreatedToOtherPersonText); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfEmployeeHasProxyByOtherPerson.ToString()) { throw new CustomException(string.Format(Resources.Globalization.ValidationBecauseOfThereIsProxyByOtherPersonText, ((EServicesProxiesBLL)result.Entity).FromEmployee?.Employee?.EmployeeNameAr, ((EServicesProxiesBLL)result.Entity).StartDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat))); } else if (result.EnumMember == VacationsValidationEnum.RejectedBeacuseOfNotAllowedWeekEndBetweenTwoVacations.ToString()) { throw new CustomException(string.Format(Resources.Globalization.ValidationNotAllowedWeekEndBetweenTwoVacationsText, ((BaseVacationsBLL)result.Entity).VacationStartDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat), ((BaseVacationsBLL)result.Entity).VacationPeriod, ((BaseVacationsBLL)result.Entity).VacationEndDate.Date.ToString(Classes.Helpers.CommonHelper.DateFormat), ((BaseVacationsBLL)result.Entity).VacationTypeName)); } else if (result.EnumMember == VacationsValidationEnum.RejectedBecauseOfEVacationRequestPendingExist.ToString()) { throw new CustomException(string.Format(Resources.Globalization.ValidationBecauseOfEVacationRequestPendingExistText, ((BaseVacationsBLL)result.Entity).EVacationsRequest.EVacationRequestNo)); } Classes.Helpers.CommonHelper.ConflictValidationMessage(result); Session["EVacationRequestNo"] = Vacation.EVacationsRequest.EVacationRequestNo; return(Json(new { EVacationRequestNo = Vacation.EVacationsRequest.EVacationRequestNo }, JsonRequestBehavior.AllowGet)); }