public VacationListItemPartViewModel(VacationListItemViewModel owner, VacationService.Vacation vacation)
        {
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));
            if (vacation == null)
                throw new ArgumentNullException(nameof(vacation));

            Owner = owner;
            Vacation = vacation;

            Owner.Owner.PropertyChanged += (_, e) => 
            {
                if (e.PropertyName == nameof(VacationsViewModel.CanManageVacations))
                {
                    RaisePropertyChanged(() => CanManage);
                    UpdateCommands();
                }
            };

            Owner.Owner.Staffing.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(Staffing.StaffingViewModel.Current))
                { 
                    RaisePropertyChanged(() => CanManage);
                    UpdateCommands();
                }
            };
        }
        public VacationListItemPartViewModel(VacationListItemViewModel owner, VacationService.Vacation vacation)
        {
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));
            if (vacation == null)
                throw new ArgumentNullException(nameof(vacation));

            Owner = owner;
            Vacation = vacation;

            Owner.Owner.PropertyChanged += (_, e) => 
            {
                if (e.PropertyName == nameof(VacationsViewModel.CanManageVacations))
                    UpdateCommands();
            };

            Owner.Owner.Staffing.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(Staffing.StaffingViewModel.Current))
                    UpdateCommands();
            };

            Vacation.PropertyChanged += (_, e) =>
            {
                if (e.PropertyName == nameof(Vacation.Agreements))
                    UpdateCommands();
            };

            timer = new System.Timers.Timer(1000);
            timer.Elapsed += (_, __) => Owner.Owner.RunUnderDispatcher(new Action(() => UpdateCommands()));
            timer.Start();
        }
 public VacationViewModel(VacationsViewModel owner, VacationService.Vacation vacation, bool createEdited)
 {
     Owner = owner;
     Vacation = vacation ?? new VacationService.Vacation();
     if (createEdited)
     {
         IsEditMode = true;
     }
 }
Beispiel #4
0
 protected void ShowVac_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteVac")
     {
         int             rowNumber = Convert.ToInt32(e.CommandArgument);
         int             vacId     = Convert.ToInt32(ShowVac.Rows[rowNumber].Cells[0].Text);
         VacationService vs        = new VacationService();
         vs.DeleteVacation(vacId);
         SortDDL_SelectedIndexChanged(sender, e);
     }
 }
Beispiel #5
0
        public MainWindow()
        {
            InitializeComponent();
            VacationService.CalculateVacationDays(DateTime.Now, DateTime.Now);
            _EmployeeList = new List <Employee>();

            EmployeeService personService = new EmployeeService();

            //Startwerte werden gesetzt
            _EmployeeList = personService.GetEmployees();
            lstv_Employees.ItemsSource = _EmployeeList;

            cmb_EmployeeType.Items.Add(EmployeeType.Trainee);
            cmb_EmployeeType.Items.Add(EmployeeType.Developer);
            cmb_EmployeeType.Items.Add(EmployeeType.ProjectLeader);

            cmb_EmployeeType.SelectedIndex = 0;
            dp_Birthday.SelectedDate       = DateTime.Now;
            dp_EntryDay.SelectedDate       = DateTime.Now;
            //string date = DateTime.Now.ToShortTimeString();
        }
        public JsonResult GetVacations(int id)
        {
            VacationService vs = new VacationService();

            List <vacationViewModel> liste = new List <vacationViewModel>();
            var listUser = vs.GetAll().Where(s => s.resource_id == id);

            //listUser.Where(s => s.resource_id == idresource);
            foreach (var item in listUser)
            {
                vacationViewModel userView = new vacationViewModel();
                userView.id        = item.id;
                userView.dateStart = item.dateStart;
                userView.dateEnd   = item.dateEnd;
                userView.duree     = item.duree;
                userView.typeLeave = item.typeLeave;
                userView.granted   = item.granted;
                liste.Add(userView);
            }
            return(Json(liste, JsonRequestBehavior.AllowGet));
        }
Beispiel #7
0
    protected void SortDDL_SelectedIndexChanged(object sender, EventArgs e)
    {
        DataSet         ds;
        VacationService vs         = new VacationService();
        string          whereclout = " WHERE DoctorId=VacationDoctorId and ManagerId=VacationManagerId";
        int             x          = SortDDL.SelectedIndex;

        switch (x)
        {
        case 1:
        {
            whereclout += " ORDER BY VacationDoctorId";
            break;
        }

        case 2:
        {
            whereclout += " ORDER BY VacationManagerId";
            break;
        }

        case 3:
        {
            whereclout += " ORDER BY VacationStartDate";
            break;
        }
        }
        ds = vs.SortVacation(whereclout);
        if (ds.Tables[0].Rows.Count != 0)
        {
            CloseVac.Visible   = true;
            ShowVac.Visible    = true;
            ShowVac.DataSource = ds;
            ShowVac.DataBind();
        }
        else
        {
            Response.Write("<script>alert('לא נמצאו חופשות')</script>");
        }
    }
Beispiel #8
0
 protected void ShowDataGridForDoctor_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
 {
     try
     {
         Vacation v = new Vacation();
         //validation
         DateTime start = Convert.ToDateTime(((TextBox)(ShowDataGridForDoctor.Rows[e.RowIndex].Cells[9].FindControl("StartVac"))).Text);
         DateTime end   = Convert.ToDateTime(((TextBox)(ShowDataGridForDoctor.Rows[e.RowIndex].Cells[9].FindControl("EndVac"))).Text);
         if (start == null || end == null)
         {
             Response.Write("<script>alert('בחירת תאריך לא תקינה')</script>");
             return;
         }
         if (start < DateTime.Now || end < DateTime.Now || end < start)
         {
             Response.Write("<script>alert('בחירת תאריך לא תקינה')</script>");
             return;
         }
         v.CVacationStartDate = start;
         v.CVacationEndDate   = end;
         Manager m = (Manager)Session["manager"];
         v.CVacationManagerId = m.CManagerId;
         v.CVacationDoctorId  = ShowDataGridForDoctor.Rows[e.RowIndex].Cells[0].Text;
         VacationService vs = new VacationService();
         vs.InsertVacation(v);
         GetAllData.VacationsForDoctor();
         Response.Write("<script>alert('חופשה התקבלה')</script>");
         ShowDataGridForDoctor.EditIndex = -1;
         ShowGrid_Click(sender, e);
     }
     catch
     {
         Response.Write("<script>alert('בחירת תאריך לא תקינה')</script>");
         return;
     }
 }
Beispiel #9
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         Manager m = (Manager)Session["manager"];
         HelloLabel.Text = m.CManagerName;
         GetAllData.VacationsForDoctor();
         VacationService vs         = new VacationService();
         string          whereclout = " WHERE DoctorId=VacationDoctorId and ManagerId=VacationManagerId";
         DataSet         ds         = vs.SortVacation(whereclout);
         ShowVac.Visible = false;
         if (ds.Tables[0].Rows.Count != 0)
         {
             CloseVac.Visible   = true;
             ShowVac.Visible    = true;
             ShowVac.DataSource = ds;
             ShowVac.DataBind();
         }
         else
         {
             Response.Write("<script>alert('לא נמצאו חופשות')</script>");
         }
     }
 }
        public VacationFunctionalGroupViewModel(VacationService.VacationFunctionalGroup group, VacationsViewModel owner)
        {
            if (group == null)
                throw new ArgumentNullException(nameof(group));
            if (owner == null)
                throw new ArgumentNullException(nameof(owner));

            Group = group;
            Owner = owner;

            IsEmpty = group.Id == 0;

            LoadEmployees(group);
            Group.PropertyChanged += (_, e) => 
            {
                if (e.PropertyName == nameof(Group.EmployeIds))
                    LoadEmployees(Group);
            };
        }
Beispiel #11
0
        public IEnumerable <Vacation> GetVacationNextList()
        {
            VacationService vacationService = new VacationService(db);

            return(vacationService.GetVacationNextList());
        }
 public VacationController(VacationService VacationService)
 {
     _vacationService = VacationService;
 }
Beispiel #13
0
    public static void Appointment()
    {
        //look for all the appointments in database
        //check if the date of the appointment has already had, if so, delete the appointment
        //check if the doctor is not in vacation in this day(i think i already did it but check again)

        AppointmentService appser = new AppointmentService();
        VacationService    vc = new VacationService();
        MessageService     ms = new MessageService();
        string             s = "SELECT * from Apointment", whereclout = "";
        string             tabels = "Apointment";
        DataSet            ds     = appser.GetApointmentAndSort(s, tabels, "");
        DataSet            vacationDs;
        DateTime           timeOfAppointment;
        DateTime           startVacDate, endVacDate;
        string             doctorId, userId, content = "";
        int     AppointmentId;
        Message m = new Message();
        Doctor  d;

        if (ds.Tables[0].Rows.Count != 0)
        {
            //check all the Appointments
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                AppointmentId     = Convert.ToInt32(ds.Tables[0].Rows[i]["ApointmentId"].ToString());
                timeOfAppointment = Convert.ToDateTime(ds.Tables[0].Rows[i]["ApointmentDate"].ToString());
                doctorId          = ds.Tables[0].Rows[i]["ApointmentDoctorId"].ToString();
                userId            = ds.Tables[0].Rows[i]["ApointmentUserId"].ToString();
                //if the date has been past, then delete the appointment
                if (timeOfAppointment < DateTime.Now)
                {
                    //delete the appointment
                    appser.DeleteAppointment(AppointmentId);
                    break;
                }
                //check if the doctor is in vacation in this date
                d          = GetAllDoctorDataById(doctorId);
                vacationDs = vc.IsDoctorOnVacation(doctorId);
                if (vacationDs.Tables[0].Rows.Count != 0)
                {
                    for (int j = 0; j < vacationDs.Tables[0].Rows.Count; j++)
                    {
                        startVacDate = Convert.ToDateTime(vacationDs.Tables[0].Rows[j]["VacationStartDate"].ToString());
                        endVacDate   = Convert.ToDateTime(vacationDs.Tables[0].Rows[j]["VacationEndDate"].ToString());
                        if (startVacDate <= timeOfAppointment && timeOfAppointment <= endVacDate)
                        {
                            //create a message from manager to user that says the appointment is canceled
                            //because the doctor is on vacation
                            m.CMessageUserId    = userId;
                            m.CMessageManagerId = "325132850";
                            m.CMessageSendDate  = DateTime.Now;
                            m.CMessageTheme     = "ביטול תור";
                            content             = "התור שהיה אמור להתקיים בתאריך " + timeOfAppointment + " עם הרופא " + d.CDoctorName + " התבטל בעקבות זה שהרופא יצא לחופשה";
                            m.CMessageContent   = content;
                            m.CMessageWhoSent   = "manager";
                            //Inseart the message to the database
                            whereclout  = "INSERT INTO Messages(MessageUserId,MessageManagerId,MessageTheme,MessageContent,MessageSendDate,MessageWhoSent)";
                            whereclout += " VALUES('" + m.CMessageUserId + "','" + m.CMessageManagerId + "','" + m.CMessageTheme + "','" + m.CMessageContent + "',#" + m.CMessageSendDate + "#,'" + m.CMessageWhoSent + "')";
                            ms.InseartMessageToDatabase(whereclout);
                        }
                    }
                }
            }
        }
    }
Beispiel #14
0
 public VacationsController(VacationService vacationService)
 {
     _vacationService = vacationService;
 }
Beispiel #15
0
        private async void SaveAsync(VacationService.Vacation vacationToSave)
        {
            IsBusy = true;
            try
            {
                var task = Task.Factory.StartNew(() => {
                    var sc = new VacationService.VacationServiceClient();
                    try
                    {
                        var updateRes = Vacation.Id == 0
                            ? sc.VacationInsert(vacationToSave)
                            : sc.VacationUpdate(vacationToSave);

                        if (!string.IsNullOrWhiteSpace(updateRes.Error))
                            throw new Exception(updateRes.Error);

                        return updateRes.Value;
                    }
                    finally
                    {
                        try { sc.Close(); } catch { }
                    }
                });

                Vacation.CopyObjectFrom(await task);
                
                Error = null;
                IsBusy = false;
                IsEditMode = false;
            }
            catch (Exception ex)
            {
                IsBusy = false;
                Error = GetExceptionText(nameof(SaveAsync), ex);
            }
        }
 internal static VacationFunctionalGroupViewModel CreateEdited(VacationService.VacationFunctionalGroup group, VacationsViewModel owner)
 {
     return new VacationFunctionalGroupViewModel(group, owner) { IsEditMode = true };
 }
 private void SaveEmployees(VacationService.VacationFunctionalGroup grp)
 {
     grp.EmployeIds = Employees
         .Where(e => e.Employee != null)
         .Select(e => e.Employee.Employee.Id)
         .ToArray();
 }
 private void LoadEmployees(VacationService.VacationFunctionalGroup grp)
 {
     Employees.Clear();
     var ids = grp?.EmployeIds ?? new long[] { };
     foreach (var id in ids)
         Employees.Add(new VacationFunctionalGroupEmployeePlacementViewModel(this, id));
     Employees.Add(new VacationFunctionalGroupEmployeePlacementViewModel(this, null));
 }
        private async void SaveAsync(VacationService.VacationFunctionalGroup groupToSave, Action sucessEndAction = null, Action errorEndAction = null)
        {
            SaveEmployees(groupToSave);
            IsBusy = true;
            try
            {
                var task = Task.Factory.StartNew(() => {
                    var sc = new VacationService.VacationServiceClient();
                    try
                    {
                        var updateRes = Group.Id == 0
                            ? sc.VacationFunctionalGroupInsert(groupToSave)
                            : sc.VacationFunctionalGroupUpdate(groupToSave);

                        if (!string.IsNullOrWhiteSpace(updateRes.Error))
                        {
                            throw new Exception(updateRes.Error);
                        }
                        else
                        {
                            Owner.RunUnderDispatcher(new Action(() => 
                            {
                                this.Group.CopyObjectFrom(updateRes.Value);

                                IsEmpty = Group.Id == 0;
                                Error = null;
                                IsBusy = false;
                                IsEditMode = false;
                                sucessEndAction?.Invoke();
                            }));
                        }
                    }
                    finally
                    {
                        try { sc.Close(); } catch { }
                    }
                });

                await task;
            }
            catch (Exception ex)
            {
                IsBusy = false;
                Error = GetExceptionText(nameof(SaveAsync), ex);
                errorEndAction?.Invoke();
            }
        }
Beispiel #20
0
 public BookableController(VacationService service)
 {
     _service = service;
 }
 public PurchasablesController(VacationService vService, FlightService fService)
 {
     _vService = vService;
     _fService = fService;
 }
 public VacationController(VacationService service)
 {
     _service = service;
 }
 private static bool GetIsItGoesOver(VacationService.Vacation vacation) => DateTime.Now > vacation.Begin;
Beispiel #24
0
    public static void VacationsForDoctor()
    {
        VacationService vs = new VacationService();
        DoctorService   docser = new DoctorService();
        DataSet         ds = docser.GetDoctors(), temp;
        DateTime        start, end;
        string          docId = "";
        int             vacId;

        for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
        {
            docId = ds.Tables[0].Rows[i]["DoctorId"].ToString();
            if (Convert.ToBoolean(ds.Tables[0].Rows[i]["DoctorIsOnVacation"].ToString()))
            {
                temp = vs.IsDoctorOnVacation(docId);
                if (temp.Tables[0].Rows.Count != 0)
                {
                    //loop runs on all the doctors possible vacations
                    for (int j = 0; j < temp.Tables[0].Rows.Count; j++)
                    {
                        start = Convert.ToDateTime(temp.Tables[0].Rows[j]["VacationStartDate"].ToString());
                        end   = Convert.ToDateTime(temp.Tables[0].Rows[j]["VacationEndDate"].ToString());
                        if (DateTime.Now > end || DateTime.Now < start)
                        {
                            //update doctor
                            docser.UpdateDoctorVacation(false, docId);
                            //delete the vacation from database
                            if (DateTime.Now > end)
                            {
                                vacId = Convert.ToInt32(temp.Tables[0].Rows[j]["VacationId"].ToString());
                                vs.DeleteVacation(vacId);
                            }
                        }
                        else
                        {
                            docser.UpdateDoctorVacation(true, docId);
                            break;
                        }
                    }
                }
                else
                {
                    //update doctor
                    docser.UpdateDoctorVacation(false, docId);
                }
            }
            else
            {
                //if the doctors have vacations but DoctorIsOnVacation=false
                temp = vs.IsDoctorOnVacation(docId);
                if (temp.Tables[0].Rows.Count != 0)
                {
                    for (int j = 0; j < temp.Tables[0].Rows.Count; j++)
                    {
                        start = Convert.ToDateTime(temp.Tables[0].Rows[j]["VacationStartDate"].ToString());
                        end   = Convert.ToDateTime(temp.Tables[0].Rows[j]["VacationEndDate"].ToString());
                        if (DateTime.Now <= end && DateTime.Now >= start)
                        {
                            //update DoctorIsOnVacation=True
                            docser.UpdateDoctorVacation(true, docId);
                        }
                        else
                        {
                            //if the doctor have future vacation
                            if (DateTime.Now > end)
                            {
                                vacId = Convert.ToInt32(temp.Tables[0].Rows[j]["VacationId"].ToString());
                                vs.DeleteVacation(vacId);
                            }
                        }
                    }
                }
            }
        }
    }
 internal static bool GetCanManage(VacationsViewModel vm, VacationService.Vacation vacation)
 {
     var isItMyOwnVacation = vm.Staffing.Current.Id == vacation.EmployeeId;
     var isAgrrementExists = (vacation.Agreements?.Any() ?? false);
     var canUserChengeHisOwn = isItMyOwnVacation 
         && !GetIsItGoesOver(vacation)
         && !vacation.NotUsed;
     return !isAgrrementExists && (vm.CanManageVacations || canUserChengeHisOwn);
 }
Beispiel #26
0
 public EmpsController(EmployeeService employeeService, VacationService vacationService)
 {
     _employeeService = employeeService;
     _vacationService = vacationService;
 }
 public VacationController()
 {
     this.service = new VacationService();
 }