Example #1
0
        bool HistoryCheck(Changes change)
        {
            string[]       date    = calendar.SplitDate(change.getFromDate());
            List <Changes> history = db.getChanges(change.getPersonId());

            if (history != null)
            {
                foreach (Changes ch in history)
                {
                    if (InRange(ch.getFromDate(), ch.getToDate(), change.getFromDate()))
                    {
                        this.change = ch;
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #2
0
        public List <Changes> getChanges(int person = 0, string from = "")
        {
            List <Changes> changes = new List <Changes>();
            string         sql     = "SELECT changes.id, changes.person, changes.from_date, " +
                                     "changes.to_date, changes.status, changes.reason, personnel.name " +
                                     "FROM changes INNER JOIN personnel ON changes.person = personnel.id";

            if (person != 0)
            {
                if (from != "")
                {
                    sql += " WHERE (changes.person =" + person +
                           " AND changes.from_date LIKE '" + from + "')";
                }
                else
                {
                    sql += " WHERE changes.person =" + person;
                }
            }
            sql += " ORDER BY changes.from_date;";

            try
            {
                connection.Open();
                SQLiteCommand    command = new SQLiteCommand(sql, connection);
                SQLiteDataReader reader  = command.ExecuteReader();
                while (reader.Read())
                {
                    Changes change = new Changes(int.Parse(reader["id"].ToString()),
                                                 int.Parse(reader["person"].ToString()), reader["from_date"].ToString(),
                                                 reader["to_date"].ToString(), reader["status"].ToString(),
                                                 reader["reason"].ToString(), reader["name"].ToString());
                    changes.Add(change);
                }
                connection.Close();
                return(changes);
            }
            catch (System.Exception)
            {
                connection.Close();
                return(null);
            }
        }
Example #3
0
        void AddPerson(int id, List <String> rest)
        {
            String dayStatus = "W";
            Color  color = Color.LightGreen;
            int    from, to, WORK, REST;

            from = to = WORK = REST = 0;
            string changeStatus = dayStatus;

            for (int i = 1; i <= MaxDay; i++)
            {
                Changes change = database.getChange(id, (Year + "-" + Month + "-" + i));
                if (change.getId() != 0)
                {
                    HasChange = true;
                    string[] date = calendar.SplitDate(change.getFromDate());
                    from      = int.Parse(date[2]);
                    date      = calendar.SplitDate(change.getToDate());
                    to        = int.Parse(date[2]);
                    dayStatus = changeStatus = change.getStatus();
                    color     = Color.MediumPurple;
                }
                else if (HasChange && (i >= from && i <= to))
                {
                    dayStatus = changeStatus;
                    color     = Color.MediumPurple;
                }
                else
                {
                    if (rest.Contains(i.ToString()))
                    {
                        dayStatus = "R";
                    }
                    else
                    {
                        dayStatus = "W";
                    }

                    if (dayStatus == "W")
                    {
                        color = Color.LightGreen;
                    }
                    else if (dayStatus == "R")
                    {
                        color = Color.LightPink;
                    }
                }
                if (Year == calendar.Year() && Month == calendar.Month() && i == calendar.Day())
                {
                    color = Color.LightBlue;
                }
                else if (dayStatus == "A")
                {
                    color = Color.Khaki;
                }

                if (dayStatus == "W")
                {
                    Available[i - 1]++;
                    Total[i - 1]++;
                    WORK++;
                }
                else if (dayStatus == "R")
                {
                    REST++;
                }

                this.Controls[PERSON + id + "-" + i].Text      = dayStatus;
                this.Controls[PERSON + id + "-" + i].Tag       = dayStatus + "~" + id + "~" + Year + "~" + Month + "~" + i;
                this.Controls[PERSON + id].Tag                 = id;
                this.Controls[PERSON + id + "-" + i].BackColor = color;
            }
            if (MaxDay < 31)
            {
                for (int i = MaxDay + 1; i <= 31; i++)
                {
                    this.Controls[PERSON + id + "-" + i].Text      = "";
                    this.Controls[PERSON + id + "-" + i].Tag       = null;
                    this.Controls[PERSON + id + "-" + i].BackColor = Color.White;
                }
            }
            this.Controls[PERSON_WORK + id].Text = (WORK).ToString();
            this.Controls[PERSON_REST + id].Text = (REST).ToString();
            Work += WORK;
            Rest += REST;
        }