Esempio n. 1
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);
     }
 }
Esempio n. 2
0
        public async Task <IActionResult> DeleteVacationConfirmed(int id)
        {
            await _vacationService.DeleteVacation(id);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 3
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);
                            }
                        }
                    }
                }
            }
        }
    }