public ActionResult LeaveBalance(int?Id) { if (Id == null) { Id = Convert.ToInt32(Session["EmpCode"]); } else { ViewBag.SideBar = _moduleService.AdminEmployeeDetailsMenu(Convert.ToInt32(Id)); } try { LeaveBalanceModel result = new LeaveBalanceModel(); result.LeaveBalance = _LeaveAddAdmin.LeaveBalanceSearch(); result.LeaveBalance.EmpCodeList = _LeaveEarnedService.GetBrancheEmployeeSelectList(Convert.ToInt32(Session["EmpCode"])); if (Id >= 0) { result.LeaveBalance.EmpCode = Convert.ToInt32(Id); } else { result.LeaveBalance.EmpCode = Convert.ToInt32(Session["EmpCode"]); } result.LeaveBalanceDetails = _LeaveAddAdmin.LeaveBalanceList(result.LeaveBalance.LeaveYearId, Convert.ToInt32(result.LeaveBalance.EmpCode)); return(View(result)); } catch (Exception Ex) { Session["error"] = Ex.Message; return(View()); } }
/// <summary> /// Maps the specified original. /// </summary> /// <param name="original">The original.</param> /// <returns></returns> public static LeaveBalanceModel Map(this LeaveBalance original, string name, string surname) { var mappedOutcome = new LeaveBalanceModel { EmployeeId = original.EmployeeId.Value, Balance = original.Balance.Value, Name = name, Surname = surname }; return(mappedOutcome); }
/// <summary> /// Maps the specified original. /// </summary> /// <param name="original">The original.</param> /// <returns></returns> public static LeaveBalanceViewModel Map(this LeaveBalanceModel original) { var mappedOutcome = new LeaveBalanceViewModel { EmployeeId = original.EmployeeId, Balance = original.Balance, Name = original.Name, Surname = original.Surname }; return(mappedOutcome); }
public ActionResult LeaveBalance(LeaveBalanceModel result) { try { result.LeaveBalance.EmpCode = Convert.ToInt32(Session["EmpCode"]); result.LeaveBalanceDetails = _LeaveAddAdmin.LeaveBalanceList(result.LeaveBalance.LeaveYearId, result.LeaveBalance.EmpCode); result.LeaveBalance = _LeaveAddAdmin.LeaveBalanceSearch(); return(View(result)); } catch (Exception Ex) { Session["error"] = Ex.Message; return(View(result)); } }
private void cboLeaveType_SelectedValueChanged(object sender, EventArgs e) { ServiceLeaveApplication service = new ServiceLeaveApplication(); try { DateTime inTime = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 8, 45, 0); DateTime outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 17, 15, 0); lblLeaveBalanceInfo.Text = string.Empty; if (cboLeaveType.SelectedItem != null) { this.SelectedLeaveTypeID = ((SelectListItem)cboLeaveType.SelectedItem).ID; EmployeeID = ((SelectListItem)cboEmployees.SelectedItem).ID; btnSave.Enabled = true; if (SelectedLeavFormTypeID == service.LEAVE_TYPE_LEAVE_ID) { LeaveBalanceModel model = service.GetLeaveBalanceModelOfEmployeeForYear(EmployeeID, Program.CURR_USER.FinYearID, SelectedLeaveTypeID); if (model != null) { lblLeaveBalanceInfo.Text = string.Format("Allowed [{0}] Earned [{1}] Taken [{2}] Balance [{3}]", model.Allowed, model.Earned, model.Taken, model.Balance); if (model.Balance <= 0) { btnSave.Enabled = false; } } // if (SelectedLeaveTypeID == service.LEAVE_TYPE_HALFDAY_ID) // { // double cntDays = 0.5; // txtNoOfDays.Text = cntDays.ToString(); // } } if (SelectedLeavFormTypeID == service.LEAVE_TYPE_OUTDOOR_ID) { inTime = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 8, 45, 0); outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 17, 15, 0); int outDoorTypeID = ((SelectListItem)cboLeaveType.SelectedItem).ID; if (outDoorTypeID == service.OUTDOOR_FULLSHIFT_ID) { inTime = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 8, 45, 0); outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 17, 15, 0); } if (outDoorTypeID == service.OUTDOOR_FIRST_HALF_ID) { inTime = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 8, 45, 0); outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 13, 00, 0); } if (outDoorTypeID == service.OUTDOOR_SECOND_HALF_ID) { inTime = new DateTime(dtFromTime.Value.Year, dtFromTime.Value.Month, dtFromTime.Value.Day, 13, 45, 0); outTime = new DateTime(dtToTime.Value.Year, dtToTime.Value.Month, dtToTime.Value.Day, 17, 15, 0); } } dtFromTime.Value = inTime; dtToTime.Value = outTime; txtNoOfDays.Text = AppCommon.GetTimeDuration(dtFromTime.Value, dtToTime.Value).Text; } } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditLeaveApplication::cboLeaveType_SelectedValueChanged", MessageBoxButtons.OK, MessageBoxIcon.Error); } }