protected void gridViewJobType_Command(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Select")
            {
                GetMyAccessRights();

                modalLabelError.Text = "";
                modalLabelError.Visible = false;
                modalChkboxAll.Checked = false;
                int index = Convert.ToInt32(e.CommandArgument);
                int jobtypeId = Convert.ToInt32(((Label)gridViewJobType.Rows[index].FindControl("labelJobTypeId")).Text);
                modalBtnSubmit.CommandArgument = "Update";
                JobType jobtype = new JobType();
                jobtype = jobtype.GetJobType(jobtypeId);
                modalLabelJobTypeId.Text = jobtype.Id.ToString();
                modalTxtBoxDescription.Text = jobtype.Description;
                modalTxtBoxAcronym.Text = jobtype.Acronym;
                modalTxtBoxPosition.Text = jobtype.Position.ToString();
                modalChkBoxComputeTime.Checked = Convert.ToBoolean(jobtype.ComputeTime);
                modalChkBoxRequiredJobId.Checked = Convert.ToBoolean(jobtype.RequiredJobId);
                modalChkBoxShowJobOverview.Checked = Convert.ToBoolean(jobtype.ShowInJobOverview);
                InitializeModalGridViewDepartment(jobtype.Id);
                //InitializeModalDropDownDepartment(jobtype.DepartmentId.ToString());
                SetStatus(Convert.ToBoolean(myAccessRights.CanUpdate));
                this.programmaticModalPopup.Show();
            }
        }
        protected void BtnBreak_Click(object sender, EventArgs e)
        {
            int userid = Convert.ToInt32(Session["UserId"]);
            JobType jobtype = new JobType();
            jobtype = jobtype.GetDefaultBreak();
            DateTime selectedDate = DateTime.Parse(txtBoxDate.Text);
            JobTracker jobtracker = new JobTracker();
            bool noError = true;
            User user = new User();
            user = user.GetUser(userid, selectedDate);

            if (jobtracker.HasPreviousUnclosedJobs(userid,DateTime.Today)) //check if user has unclosed jobs
            {
                noError = false;
                panelAlertHeader2.CssClass = "modalAlertHeader";
                alertModalBtnOK2.CssClass = "buttonalert";
                labelAlertHeader2.Text = "Error";
                labelAlertMessage2.Text = "Please close all jobs before adding a new one.";
                programmaticAlertModalPopup2.Show();
            }
            else
            {
                string errMsg = "";
                errMsg = jobtracker.GetError(userid, selectedDate, 30); //check if there is an error
                if (errMsg.Trim() != "")
                {
                    noError = false;
                    panelAlertHeader2.CssClass = "modalAlertHeader";
                    alertModalBtnOK2.CssClass = "buttonalert";
                    labelAlertHeader2.Text = "Error";
                    labelAlertMessage2.Text = errMsg.Trim() + " Please settle error first.";
                    programmaticAlertModalPopup2.Show();
                }
            }
            if (noError)
            {
                if (TimeSpan.Parse(user.startTime) > TimeSpan.Parse(user.endTime)) //check if user has shifting hours
                {
                    RunBreakButtonActionForShifting();
                }
                else
                {
                    RunBreakButtonAction();
                }

            }
        }
Exemplo n.º 3
0
        public List<Analysis> GetAnalysis(int departmentid, DateTime startdate, DateTime enddate, string stringjobid,string customer,int roleid)
        {
            List<Analysis> data = new List<Analysis>();
            JobTracker jobtracker = new JobTracker();
            List<JobTracker> joblist = new List<JobTracker>();
            JobTypeDepartment jobtypeDepartment = new JobTypeDepartment();
            List<JobType> jobtypelist = new List<JobType>();
            if (departmentid == 0)
            {
                //joblist = jobtracker.GetJobTrackerForAnalysis(startdate, enddate);
                JobType jobtype = new JobType();
                jobtypelist = jobtype.GetJobTypeListByRoleId(roleid);
            }
            else
            {
                //joblist = jobtracker.GetJobTrackerForAnalysis(departmentid, startdate, enddate);
                jobtypelist = jobtypeDepartment.GetJobTypeList(departmentid);
            }
            for (int i = 0; i < jobtypelist.Count; i++)
            {
                Analysis newAnalysis = new Analysis();
                newAnalysis.jobtype = jobtypelist[i].Description;
                newAnalysis.jobtypeid = jobtypelist[i].Id.ToString();
                newAnalysis.totalworktime = jobtracker.GetTotalHours(jobtypelist[i].Id, startdate, enddate, "Approved", departmentid, stringjobid,customer);
                newAnalysis.totalforapproval = jobtracker.GetTotalHours(jobtypelist[i].Id, startdate, enddate, "For Approval", departmentid, stringjobid,customer);
                newAnalysis.totaljobTime = "";
                if (stringjobid.Trim() != "" || customer.Trim() != "")
                {
                    newAnalysis.totaljobTime = jobtracker.GetTotalHours(jobtypelist[i].Id, Convert.ToDateTime("1900-01-01"), DateTime.Now, "Approved", departmentid, stringjobid, customer);
                }
                //newAnalysis.totalrejectedtime = jobtracker.GetTotalHours(jobtypelist[i].Id, startdate, enddate, "Rejected", departmentid, stringjobid,customer);
                //newAnalysis.totalunclosedjobs = jobtracker.GetTotalUnclosedJobs(jobtypelist[i].Id, startdate, enddate, "Pending", departmentid, stringjobid).ToString();
                data.Add(newAnalysis);
            }

            return data;
        }
        protected void InitializeGridViewJobType()
        {
            GetMyAccessRights();
            if (myAccessRights.CanAdd == true)
                linkBtnAdd.Visible = true;
            else
                linkBtnAdd.Visible = false;
            JobTypeDepartment jobtypeDepartment = new JobTypeDepartment();
            JobType jobtype = new JobType();
            List<JobType> jobtypeList = new List<JobType>();

            if (dropDownListDepartment.SelectedItem.Text == "All")
                jobtypeList = jobtype.GetJobTypeList();
            else
                jobtypeList = jobtypeDepartment.GetJobTypeList(Convert.ToInt32(dropDownListDepartment.SelectedItem.Value));

            gridViewJobType.DataSource = jobtypeList;
            gridViewJobType.DataBind();
        }
        protected void modalDescription_Changed(object sender, EventArgs e)
        {
            string errorMsg = "Description already used. ";
            if (modalTxtBoxDescription.Text.Trim() != "")
            {
                JobType jobtype = new JobType();
                jobtype = jobtype.GetJobTypeByDescription(modalTxtBoxDescription.Text.Trim());

                if (jobtype != null)
                {
                    if (modalLabelJobTypeId.Text.Trim() == "")
                    {
                        modalLabelError.Text += errorMsg;
                        modalLabelError.Visible = true;
                    }
                    else
                    {
                        JobType j = jobtype.GetJobType(Convert.ToInt32(modalLabelJobTypeId.Text));
                        if (j.Description.Trim().Equals(modalTxtBoxDescription.Text.Trim(), StringComparison.OrdinalIgnoreCase) == true)
                        {
                            modalLabelError.Text += errorMsg;
                            modalLabelError.Visible = true;
                        }
                        else
                        {
                            modalLabelError.Text = modalLabelError.Text.Replace(errorMsg, "").Trim();
                        }
                    }
                }
                else
                {
                    modalLabelError.Text = modalLabelError.Text.Replace(errorMsg, "").Trim();
                }
            }
            else
            {
                modalLabelError.Text = modalLabelError.Text.Replace(errorMsg, "").Trim();
            }
            if (modalLabelError.Text.Trim().Length == 0)
            {
                modalLabelError.Visible = false;
            }
            this.programmaticModalPopup.Show();
        }
        protected void modalBtnSubmit_Command(object sender, CommandEventArgs e)
        {
            if (modalLabelError.Visible == true)
                this.programmaticModalPopup.Show();
            else
            {
                bool ischkBoxEmpty = IsDeptCheckBoxEmpty();
                int userid = Convert.ToInt32(Session["UserId"]);
                JobType jobtype = new JobType();
                if (modalLabelJobTypeId.Text.Trim() != "")
                {
                    jobtype = jobtype.GetJobType(Convert.ToInt32(modalLabelJobTypeId.Text));
                }
                jobtype.Description = modalTxtBoxDescription.Text.Trim();
                jobtype.Acronym = modalTxtBoxAcronym.Text.Trim();
                jobtype.Position = Convert.ToInt32(modalTxtBoxPosition.Text);
                jobtype.LastUpdateDate = DateTime.Now;
                jobtype.LastUpdatedBy = userid;
                //jobtype.DepartmentId = Convert.ToInt32(modalDropDownDepartment.SelectedItem.Value);
                if (modalChkBoxRequiredJobId.Checked == true)
                    jobtype.RequiredJobId = true;
                else
                    jobtype.RequiredJobId = false;
                if (modalChkBoxComputeTime.Checked == true)
                    jobtype.ComputeTime = true;
                else
                    jobtype.ComputeTime = false;
                if (modalChkBoxShowJobOverview.Checked == true)
                    jobtype.ShowInJobOverview = true;
                else
                    jobtype.ShowInJobOverview = false;
                if (e.CommandArgument.ToString() == "Add" && ischkBoxEmpty == false)
                {
                    jobtype.CreateDate = DateTime.Now;
                    jobtype.CreatedBy = userid;
                    jobtype.Insert(jobtype);
                    jobtype = jobtype.GetJobTypeByAcronym(modalTxtBoxAcronym.Text.Trim());
                    JobTypeDepartmentAction(jobtype.Id);
                    this.programmaticModalPopup.Hide();
                }
                else if (e.CommandArgument.ToString() == "Update" && ischkBoxEmpty == false)
                {
                    jobtype.Update(jobtype);
                    JobTypeDepartmentAction(jobtype.Id);
                    this.programmaticModalPopup.Hide();
                }
                else if (e.CommandArgument.ToString() == "Update" && ischkBoxEmpty == true)
                {
                    JobTypeDepartmentAction(jobtype.Id);
                    jobtype.Delete(jobtype.Id);
                    this.programmaticModalPopup.Hide();
                }

                InitializeGridViewJobType();
            }
        }
        private void InitializeModalJobType()
        {
            JobType jobType = new JobType();
            List<JobType> jobtypeList = new List<JobType>();
            jobtypeList = jobType.GetJobTypeList();

            modalDropDownJobType.DataSource = jobtypeList;
            modalDropDownJobType.DataValueField = "Id";
            modalDropDownJobType.DataTextField = "Description";
            modalDropDownJobType.DataBind();
        }
Exemplo n.º 8
0
 private void UpdateParse(T_JobType t_jobtype, JobType jobtype)
 {
     t_jobtype.Description = jobtype.Description;
     t_jobtype.CreateDate = jobtype.CreateDate;
     t_jobtype.LastUpdateDate = jobtype.LastUpdateDate;
     t_jobtype.CreatedBy = jobtype.CreatedBy;
     t_jobtype.LastUpdatedBy = jobtype.LastUpdatedBy;
     t_jobtype.RequiredJobId = jobtype.RequiredJobId;
     t_jobtype.ComputeTime = jobtype.ComputeTime;
     t_jobtype.Position = jobtype.Position;
     t_jobtype.ShowInJobOverview = jobtype.ShowInJobOverview;
     t_jobtype.Acronym = jobtype.Acronym;
     t_jobtype.IsDefaultBreak = jobtype.IsDefaultBreak;
 }
Exemplo n.º 9
0
 private T_JobType InsertParse(JobType jobtype)
 {
     T_JobType t_jobtype = new T_JobType();
     t_jobtype.Description = jobtype.Description;
     t_jobtype.CreateDate = jobtype.CreateDate;
     t_jobtype.LastUpdateDate = jobtype.LastUpdateDate;
     t_jobtype.CreatedBy = jobtype.CreatedBy;
     t_jobtype.LastUpdatedBy = jobtype.LastUpdatedBy;
     t_jobtype.RequiredJobId = jobtype.RequiredJobId;
     t_jobtype.ComputeTime = jobtype.ComputeTime;
     t_jobtype.Position = jobtype.Position;
     t_jobtype.ShowInJobOverview = jobtype.ShowInJobOverview;
     t_jobtype.Acronym = jobtype.Acronym;
     t_jobtype.IsDefaultBreak = jobtype.IsDefaultBreak;
     return t_jobtype;
 }
Exemplo n.º 10
0
 public void Update(JobType jobtype)
 {
     using (TimeTrackerEntities db = new TimeTrackerEntities())
     {
         try
         {
             T_JobType t_jobtype = db.T_JobType.FirstOrDefault(d => d.Id == jobtype.Id);
             UpdateParse(t_jobtype, jobtype);
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             string msg = ex.Message;
         }
     }
 }
Exemplo n.º 11
0
        //public List<JobType> GetJobOverviewJobType(int departmentid)
        //{
        //    TimeTrackerEntities db = new TimeTrackerEntities();
        //    var data = (from j in db.T_JobType
        //                where j.DepartmentId == departmentid
        //                && j.ShowInJobOverview == true
        //                orderby j.M_Department.Position, j.Position
        //                select new JobType()
        //                {
        //                    Id = j.Id,
        //                    Description = j.Description,
        //                    CreatedBy = j.CreatedBy,
        //                    LastUpdatedBy = j.LastUpdatedBy,
        //                    CreateDate = j.CreateDate,
        //                    LastUpdateDate = j.LastUpdateDate,
        //                    RequiredJobId = j.RequiredJobId,
        //                    ComputeTime = j.ComputeTime,
        //                    Position = j.Position,
        //                    ShowInJobOverview = j.ShowInJobOverview,
        //                    Acronym = j.Acronym,
        //                }).ToList();
        //    db.Dispose();
        //    return data;
        //}
        //public List<JobType> GetExclusiveJobTypeList(int departmentid)
        //{
        //    TimeTrackerEntities db = new TimeTrackerEntities();
        //    var data = (from j in db.T_JobType
        //                where j.DepartmentId == departmentid
        //                orderby j.M_Department.Position, j.Position
        //                select new JobType()
        //                {
        //                    Id = j.Id,
        //                    Description = j.Description,
        //                    CreatedBy = j.CreatedBy,
        //                    LastUpdatedBy = j.LastUpdatedBy,
        //                    CreateDate = j.CreateDate,
        //                    LastUpdateDate = j.LastUpdateDate,
        //                    RequiredJobId = j.RequiredJobId,
        //                    ComputeTime = j.ComputeTime,
        //                    Position = j.Position,
        //                    Acronym = j.Acronym,
        //                    ShowInJobOverview = j.ShowInJobOverview
        //                }).ToList();
        //    db.Dispose();
        //    return data;
        //}
        public void Insert(JobType jobtype)
        {
            T_JobType t_jobtype = InsertParse(jobtype);

            using (TimeTrackerEntities db = new TimeTrackerEntities())
            {
                try
                {
                    db.T_JobType.Add(t_jobtype);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    string msg = ex.Message;
                }
            }
        }
        protected void modalDropDownJobType_IndexChanged(object sender, EventArgs e)
        {
            JobType jobType = new JobType();
            jobType.Id = Convert.ToInt32(modalDropDownJobType.SelectedItem.Value);
            jobType = jobType.GetJobType(jobType.Id);
            if (jobType != null)
            {
                modalReqJobId.Enabled = Convert.ToBoolean(jobType.RequiredJobId); //Set jobid validation depending on the JobType setup.

                modalReqJobStatus.Enabled = Convert.ToBoolean(jobType.ComputeTime); //If time is computed, require Job Status, otherwise do not require it.
            }
            //if (modalTxtBoxJobId.Enabled == false)
            //{
            //    modallabelCustomer.Text = "";
            //    modallabelBoxJobDescription.Text = "";
            //    modalTxtBoxJobId.Text = "";
            //    modalLabelError.Visible = false;
            //    InitializeModalJobStatus();
            //}
            this.programmaticModalPopup.Show();
        }
        private void RunBreakButtonActionForShifting()
        {
            int userid = Convert.ToInt32(Session["UserId"]);
            JobType jobtype = new JobType();
            jobtype = jobtype.GetDefaultBreak();
            DateTime selectedDate = DateTime.Parse(txtBoxDate.Text);
            JobTracker jobtracker = new JobTracker();
            int jobtrackid = 0;
            bool noError = true;
            User user = new User();
            user = user.GetUser(userid, selectedDate);
            TimeSpan cutOffTime = user.GetMyCutOfTime();

            if (BtnBreak.Text == "Take a break")
            {
                DateTime startTime = new DateTime();
                if (gridJobTrack.Rows.Count > 0)
                {
                    jobtrackid = Convert.ToInt32(((Label)gridJobTrack.Rows[gridJobTrack.Rows.Count - 1].FindControl("labelJobTrackId")).Text);
                    jobtracker = jobtracker.GetJobTracker(jobtrackid, false);
                    JobType jtype = jobtype.GetJobType(Convert.ToInt32(jobtracker.JobTypeId));
                    if (Convert.ToDateTime(jobtracker.StartTime).TimeOfDay < cutOffTime && DateTime.Now.TimeOfDay >= cutOffTime)
                    {
                        if (jobtracker.EndTime == null)
                        {
                            noError = false;
                            TimeSetting tsetting = new TimeSetting();
                            tsetting = tsetting.GetTimeSetting();
                            panelAlertHeader2.CssClass = "modalAlertHeader";
                            alertModalBtnOK2.CssClass = "buttonalert";
                            labelAlertHeader2.Text = "Error";
                            labelAlertMessage2.Text = "Please close all task first.";
                        }
                        else
                        {
                            GenerateStartHour();
                            GenerateStartMin(Convert.ToInt32(modalDropDownStartTimeHour.SelectedItem.Value));
                            startTime = DateTime.Parse(selectedDate.Year + "-" + selectedDate.Month + "-" + selectedDate.Day + " " + modalDropDownStartTimeHour.SelectedValue + ":" + modalDropDownStartTimeMin.SelectedValue + ":00");
                        }
                    }
                    else
                    {
                        if (jobtracker.EndTime == null)
                        {
                            DateTime stime = Convert.ToDateTime(jobtracker.StartTime);
                            GenerateEndHour(stime.Hour, stime.Minute, true);
                            GenerateEndMin(stime.Hour, stime.Minute, "--");
                            modalDropDownEndTimeHour.SelectedIndex = (modalDropDownEndTimeHour.Items.Count - 1);
                            GenerateEndMin(stime.Hour, stime.Minute, modalDropDownEndTimeHour.SelectedItem.Text.Trim(), modalDropDownEndTimeMin.Items.Count == 0 ? "" : modalDropDownEndTimeHour.Items[modalDropDownEndTimeHour.Items.Count - 1].Text.Trim() + ":" + modalDropDownEndTimeMin.SelectedItem.Text.Trim());
                            if (modalDropDownEndTimeHour.Items[modalDropDownEndTimeHour.Items.Count - 1].Text != "--")
                            {
                                if (modalDropDownEndTimeHour.SelectedValue == "24") //end date selected is 12:00 AM next day
                                {
                                    jobtracker.EndTime = DateTime.Parse((selectedDate.AddDays(1)).Year + "-" + (selectedDate.AddDays(1)).Month + "-" + (selectedDate.AddDays(1)).Day + " 00:00:00");
                                }
                                else
                                {
                                    jobtracker.EndTime = DateTime.Parse(selectedDate.Year + "-" + selectedDate.Month + "-" + selectedDate.Day + " " + modalDropDownEndTimeHour.Items[modalDropDownEndTimeHour.Items.Count - 1].Value + ":" + modalDropDownEndTimeMin.Items[modalDropDownEndTimeMin.Items.Count - 1].Value + ":00");
                                }
                                jobtracker.Status = "Approved";
                                jobtracker.ApprovedBy = userid;
                                jobtracker.ActionRequest = "Update";
                                jobtracker.Update(jobtracker);
                                startTime = Convert.ToDateTime(jobtracker.EndTime);
                                InitializeGrid();
                            }
                            else
                            {
                                noError = false;
                                TimeSetting tsetting = new TimeSetting();
                                tsetting = tsetting.GetTimeSetting();
                                panelAlertHeader2.CssClass = "modalAlertHeader";
                                alertModalBtnOK2.CssClass = "buttonalert";
                                labelAlertHeader2.Text = "Error";
                                labelAlertMessage2.Text = "Cannot take a break without spending at least " + tsetting + " minutes on the last task.";
                            }
                        }
                        else
                        {
                            startTime = Convert.ToDateTime(jobtracker.EndTime);
                        }
                    }
                }
                else
                {
                    GenerateStartHour();
                    GenerateStartMin(Convert.ToInt32(modalDropDownStartTimeHour.SelectedItem.Value));
                    startTime = DateTime.Parse(selectedDate.Year + "-" + selectedDate.Month + "-" + selectedDate.Day + " " + modalDropDownStartTimeHour.SelectedValue + ":" + modalDropDownStartTimeMin.SelectedValue + ":00");
                }
                if (noError)
                {
                    jobtracker = new JobTracker();
                    jobtracker.StartTime = startTime;
                    jobtracker.Status = "Pending";
                    jobtracker.JobStatus = "";
                    jobtracker.ApprovedBy = userid;
                    jobtracker.ActionRequest = "Add";
                    jobtracker.UserId = userid;
                    jobtracker.CreateDate = DateTime.Now;
                    jobtracker.CreatedBy = userid;
                    jobtracker.LastUpdateDate = DateTime.Now;
                    jobtracker.LastUpdatedBy = userid;
                    jobtracker.Description = jobtype.Description;
                    jobtracker.JobTypeId = jobtype.Id;
                    jobtracker.ScheduleDate = selectedDate;
                    jobtracker.Remarks = "";
                    jobtracker.Insert(jobtracker);
                    InitializeGrid();
                }
                else
                {
                    programmaticAlertModalPopup2.Show();
                }
            }
            else if (BtnBreak.Text == "End break")
            {
                jobtrackid = Convert.ToInt32(((Label)gridJobTrack.Rows[gridJobTrack.Rows.Count - 1].FindControl("labelJobTrackId")).Text);
                jobtracker = jobtracker.GetJobTracker(jobtrackid, false);
                jobtracker.LastUpdateDate = DateTime.Now;
                jobtracker.LastUpdatedBy = userid;
                if (jobtracker.JobTypeId == jobtype.Id)
                {
                    DateTime stime = Convert.ToDateTime(jobtracker.StartTime);
                    GenerateEndHour(stime.Hour, stime.Minute, true);
                    GenerateEndMin(stime.Hour, stime.Minute, "--");
                    modalDropDownEndTimeHour.SelectedIndex = (modalDropDownEndTimeHour.Items.Count - 1);
                    GenerateEndMin(stime.Hour, stime.Minute, modalDropDownEndTimeHour.SelectedItem.Text.Trim(), modalDropDownEndTimeMin.Items.Count == 0 ? "" : modalDropDownEndTimeHour.Items[modalDropDownEndTimeHour.Items.Count - 1].Text.Trim() + ":" + modalDropDownEndTimeMin.SelectedItem.Text.Trim());
                    if (modalDropDownEndTimeHour.Items[modalDropDownEndTimeHour.Items.Count - 1].Text != "--")
                    {
                        if (modalDropDownEndTimeHour.SelectedValue == "24") //end date selected is 12:00 AM next day
                        {
                            jobtracker.EndTime = DateTime.Parse((selectedDate.AddDays(1)).Year + "-" + (selectedDate.AddDays(1)).Month + "-" + (selectedDate.AddDays(1)).Day + " 00:00:00");
                        }
                        else
                        {
                            jobtracker.EndTime = DateTime.Parse(selectedDate.Year + "-" + selectedDate.Month + "-" + selectedDate.Day + " " + modalDropDownEndTimeHour.Items[modalDropDownEndTimeHour.Items.Count - 1].Value + ":" + modalDropDownEndTimeMin.Items[modalDropDownEndTimeMin.Items.Count - 1].Value + ":00");
                        }
                        jobtracker.Status = "Approved";
                        jobtracker.ApprovedBy = userid;
                        jobtracker.ActionRequest = "Update";
                        jobtracker.Update(jobtracker);
                        InitializeGrid();
                    }
                    else//delete break if start time and end time are the same
                    {
                        jobtracker.Delete(jobtracker.Id);
                        InitializeGrid();
                    }
                }
                if (gridJobTrack.Rows.Count > 1) // continue the last created job
                {
                    for (int i = gridJobTrack.Rows.Count - 1; i >= 0; i--)
                    {
                        jobtrackid = Convert.ToInt32(((Label)gridJobTrack.Rows[i].FindControl("labelJobTrackId")).Text);
                        JobTracker jtracker = jobtracker.GetJobTracker(jobtrackid, false);
                        JobType jtype = jobtype.GetJobType(Convert.ToInt32(jtracker.JobTypeId));
                        if (jtype.ComputeTime == true)
                        {
                            jtracker.StartTime = jobtracker.EndTime;
                            jtracker.UserId = userid;
                            jtracker.CreateDate = DateTime.Now;
                            jtracker.CreatedBy = userid;
                            jtracker.LastUpdateDate = DateTime.Now;
                            jtracker.LastUpdatedBy = userid;
                            jtracker.EndTime = null;
                            jtracker.ActionRequest = "Add";
                            jtracker.Status = "Approved";
                            if(Convert.ToDateTime(jobtracker.EndTime).TimeOfDay != new TimeSpan(0,0,0)) //only insert if endtime is not equal to 24:00 (next day)
                                jtracker.Insert(jtracker);
                            InitializeGrid();
                            break;
                        }
                    }
                }
            }
        }
        protected void InitializeGrid()
        {
            int userid = Convert.ToInt32(Session["UserId"]);
            JobTracker jobTracker = new JobTracker();
            List<JobTracker> data = new List<JobTracker>();
            DateTime date = Convert.ToDateTime(txtBoxDate.Text);
            data = jobTracker.GetJobTrackerList(userid,date,true);
            //Converter model = new Converter();
            //DataTable table = model.ConvertToDataTable(data);
            gridJobTrack.DataSource = data;
            gridJobTrack.DataBind();
            Session["StartTime"] = null;
            GenerateStartHour();
            if (modalDropDownStartTimeHour.Items.Count < 1)
            {
                linkBtnAddJobTrack.Visible = false;
            }
            else
            {
                linkBtnAddJobTrack.Visible = true;
            }

            if (date.CompareTo(DateTime.Today) == 0)//If doing job track on the current day, show take a break button
            {
                BtnBreak.Text = "Take a break";
                BtnBreak.CssClass = "buttongreen";
                BtnBreak.Visible = true;
                if (data.Count > 0)
                {
                    JobType jobtype = new JobType();
                    jobtype = jobtype.GetJobType(Convert.ToInt32(data[data.Count - 1].JobTypeId));
                    if (jobtype.IsDefaultBreak == true && data[data.Count - 1].Status == "Pending")
                    {
                        BtnBreak.Text = "End break";
                        BtnBreak.CssClass = "buttonred";
                    }
                }
            }
            else
            {
                BtnBreak.Visible = false;
            }
        }
        //protected void InitializeModal()
        //{
        //    JobType jobtype = new JobType();
        //    var data = jobtype.GetJobTypeList(Convert.ToInt32(Session["DepartmentId"]));
        //    modalDropDownJobType.DataSource = data;
        //    modalDropDownJobType.DataTextField = "Description";
        //    modalDropDownJobType.DataValueField = "Id";
        //    modalDropDownJobType.DataBind();
        //    Time time = new Time();
        //    var starttime = time.GetStartTimeList();
        //    modalDropDownStartTime.DataSource = starttime;
        //    modalDropDownStartTime.DataTextField = "Description";
        //    modalDropDownStartTime.DataValueField = "C24hrConversion";
        //    modalDropDownStartTime.DataBind();
        //    bool hasSelected = false;
        //    foreach (ListItem i in modalDropDownStartTime.Items)
        //    {
        //        TimeSpan selectedTime = TimeSpan.Parse(i.Value);
        //        TimeSpan curtime = TimeSpan.Parse(DateTime.Now.Hour + ":" + DateTime.Now.Minute);
        //        if (selectedTime >= curtime && hasSelected == false)
        //        {
        //            i.Selected = true;
        //            hasSelected = true;
        //        }
        //        else
        //            i.Selected = false;
        //    }
        //    var endtime = time.GetEndTimeList(modalDropDownStartTime.SelectedValue);
        //    modalDropDownEndTime.DataSource = endtime;
        //    modalDropDownEndTime.DataTextField = "Description";
        //    modalDropDownEndTime.DataValueField = "C24hrConversion";
        //    modalDropDownEndTime.DataBind();
        //}
        private void InitializeModalJobType(string value = "")
        {
            JobTypeDepartment jobtypeDepartment = new JobTypeDepartment();
            var data = jobtypeDepartment.GetJobTypeList(Convert.ToInt32(Session["DepartmentId"]));
            modalDropDownJobType.DataSource = data;
            modalDropDownJobType.DataTextField = "Description";
            modalDropDownJobType.DataValueField = "Id";
            modalDropDownJobType.DataBind();
            if (value.Trim() != "")
            {
                foreach (ListItem i in modalDropDownJobType.Items)
                {
                    if (i.Value.Trim() == value.Trim())
                    {
                        i.Selected = true;

                        //if (jobType != null)
                        //{
                        //    //modalTxtBoxJobId.Enabled = Convert.ToBoolean(jobType.RequiredJobId);
                        //    modalReqJobId.Enabled = Convert.ToBoolean(jobType.RequiredJobId);
                        //}
                        //if (modalTxtBoxJobId.Enabled == false)
                        //{
                        //    modallabelCustomer.Text = "";
                        //    modallabelBoxJobDescription.Text = "";
                        //    modalTxtBoxJobId.Text = "";
                        //    modalLabelError.Visible = false;
                        //}
                        break;
                    }
                }
            }
            int jobtypeId = Convert.ToInt32(modalDropDownJobType.SelectedValue);
            JobType jobType = new JobType();
            jobType = jobType.GetJobType(jobtypeId);
            if (jobType != null)
            {
                modalReqJobId.Enabled = Convert.ToBoolean(jobType.RequiredJobId);
                modalReqJobStatus.Enabled = Convert.ToBoolean(jobType.ComputeTime); //If time is computed, require Job Status, otherwise do not require it.
                //modalDropDownJobStatus.Enabled = Convert.ToBoolean(jobType.RequiredJobId);
            }
        }