Ejemplo n.º 1
0
        public DataView LoadAvailables(int jobId)
        {
            if (DalSubstitute.LoadAvailables(jobId))
            {
                int substituteId = 0;
                int locationId = 0;
                bool isAvailable;
                Job job = new Job(jobId);
                Substitute substitute = new Substitute();
                Dal.Preferred pref = new Miami.Substitute.Dal.Preferred();
                Dal.SubstituteExceptions substituteExceptions = new Miami.Substitute.Dal.SubstituteExceptions();
                DataRowView drv;
                DalSubstitute.DefaultView.Table.Columns.Add("IsApplied");
                DalSubstitute.DefaultView.Table.Columns.Add("TimeWorks");
                DalSubstitute.DefaultView.Table.Columns.Add("DatetimeStart");
                DalSubstitute.DefaultView.Table.Columns.Add("VisibleAssign");
                foreach (DataRow dr in DalSubstitute.DefaultView.Table.Rows)
                {
                    if (dr["SubstituteId"] != null && dr["SubstituteId"] != DBNull.Value)
                    {
                        substituteId = Convert.ToInt32(dr["SubstituteId"]);
                        substitute = new Substitute(substituteId);
                        locationId = Convert.ToInt32(dr["JobLocationId"]);
                        isAvailable = !substituteExceptions.IsOverlapped(substitute.UserId, job.DatetimeStart, job.DatetimeEnd);

                        drv = job.LoadLastJobBySubstitute(substituteId);
                        if (drv != null)
                        {
                            dr["TimeWorks"] = drv["TimeWorks"];
                            dr["DatetimeStart"] = drv["DatetimeStart"];
                        }

                        if (job.IsOverlap(jobId, substituteId))
                        {
                            dr["IsApplied"] = "<img src='Images/clerkassigned.gif' border='0'>";
                            dr["VisibleAssign"] = 0;
                        }
                        else if (!isAvailable)
                        {
                            dr["IsApplied"] = "<img src='Images/notapplied.gif' border='0'>";
                            dr["VisibleAssign"] = 0;
                        }
                        else
                        {
                            if (job.LoadSubstituteJob(jobId, substituteId))
                                dr["IsApplied"] = "<img src='Images/applied.gif' border='0'>";
                            else
                                dr["IsApplied"] = "<img src='Images/blue.gif' border='0'>";
                            dr["VisibleAssign"] = 1;
                        }
                    }
                    else
                    {
                        dr["IsApplied"] = "<img src='Images/notapplied.gif' border='0'>";
                        dr["VisibleAssign"] = 0;
                    }
                }
                DalSubstitute.DefaultView.Sort = "IsClerkPreferred DESC, IsPreferred DESC";
                return DalSubstitute.DefaultView;
            }
            else
                return null;
        }
Ejemplo n.º 2
0
        public DataView LoadAvailables(int jobId)
        {
            if (DalSubstitute.LoadAvailables(jobId))
            {
                int                      substituteId = 0;
                int                      locationId   = 0;
                bool                     isAvailable;
                Job                      job                  = new Job(jobId);
                Substitute               substitute           = new Substitute();
                Dal.Preferred            pref                 = new Miami.Substitute.Dal.Preferred();
                Dal.SubstituteExceptions substituteExceptions = new Miami.Substitute.Dal.SubstituteExceptions();
                DataRowView              drv;
                DalSubstitute.DefaultView.Table.Columns.Add("IsApplied");
                DalSubstitute.DefaultView.Table.Columns.Add("TimeWorks");
                DalSubstitute.DefaultView.Table.Columns.Add("DatetimeStart");
                DalSubstitute.DefaultView.Table.Columns.Add("VisibleAssign");
                foreach (DataRow dr in DalSubstitute.DefaultView.Table.Rows)
                {
                    if (dr["SubstituteId"] != null && dr["SubstituteId"] != DBNull.Value)
                    {
                        substituteId = Convert.ToInt32(dr["SubstituteId"]);
                        substitute   = new Substitute(substituteId);
                        locationId   = Convert.ToInt32(dr["JobLocationId"]);
                        isAvailable  = !substituteExceptions.IsOverlapped(substitute.UserId, job.DatetimeStart, job.DatetimeEnd);

                        drv = job.LoadLastJobBySubstitute(substituteId);
                        if (drv != null)
                        {
                            dr["TimeWorks"]     = drv["TimeWorks"];
                            dr["DatetimeStart"] = drv["DatetimeStart"];
                        }

                        if (job.IsOverlap(jobId, substituteId))
                        {
                            dr["IsApplied"]     = "<img src='Images/clerkassigned.gif' border='0'>";
                            dr["VisibleAssign"] = 0;
                        }
                        else if (!isAvailable)
                        {
                            dr["IsApplied"]     = "<img src='Images/notapplied.gif' border='0'>";
                            dr["VisibleAssign"] = 0;
                        }
                        else
                        {
                            if (job.LoadSubstituteJob(jobId, substituteId))
                            {
                                dr["IsApplied"] = "<img src='Images/applied.gif' border='0'>";
                            }
                            else
                            {
                                dr["IsApplied"] = "<img src='Images/blue.gif' border='0'>";
                            }
                            dr["VisibleAssign"] = 1;
                        }
                    }
                    else
                    {
                        dr["IsApplied"]     = "<img src='Images/notapplied.gif' border='0'>";
                        dr["VisibleAssign"] = 0;
                    }
                }
                DalSubstitute.DefaultView.Sort = "IsClerkPreferred DESC, IsPreferred DESC";
                return(DalSubstitute.DefaultView);
            }
            else
            {
                return(null);
            }
        }