Exemple #1
0
        /// <summary>
        /// Metoda pobiera z bazy dni w których jakikolwiek pracownik był na urlopie
        /// w danym niesiącu i w danym roku.
        /// Wynik zapisuje do listy.
        /// </summary>
        /// <param name="date">Data do sprawdzenia (miesiąc, rok)</param>
        /// <param name="disconnect">True - odłącza od bazy danych</param>
        public static void GetDayOffToList(DateTime date, ConnectionToDB disconnect)//misiąc+rok
        {
            string select = "select * from urlop_rodzaj_new where datepart(year,data)=" + date.Year + " AND datepart(month,data)=" + date.Month;

            arrayListWorkTime.Clear();

            SqlDataReader dataReader = Database.GetData(select);

            while (dataReader.Read())
            {
                DayOff d = new DayOff();
                //id potrzebne do grida
                d.IdEmployee        = dataReader.GetInt32(0);
                d.Date              = dataReader.GetDateTime(1);
                d.IdTypeDayOff      = dataReader.GetInt32(2);
                d.PercentTypeDayOff = dataReader.GetInt32(3);

                arrayListWorkTime.Add(d);
            }
            dataReader.Close();
            if (disconnect == ConnectionToDB.disconnect)
            {
                Polaczenia.OdlaczenieOdBazy();
            }
        }
Exemple #2
0
        public static void AddWorkTime(IWorkTime workTime, ConnectionToDB disconnect = ConnectionToDB.disconnect)
        {
            string select = String.Empty;

            if (workTime is Work)
            // if (typeof(Work).IsInstanceOfType(workTime))
            {
                Work work = (Work)workTime;
                select = "insert into praca values('" + work.Date.ToString("d", DateFormat.TakeDateFormat()) + "'" +
                         ",'" + work.IdEmployee + "','" + work.StartTime.ToString("d", DateFormat.TakeDateFormat()) + " " + work.StartTime.ToString("T", DateFormat.TakeDateFormat()) +
                         "','" + work.StopTime.ToString("d", DateFormat.TakeDateFormat()) + " " + work.StopTime.ToString("T", DateFormat.TakeDateFormat()) + "')";
            }
            if (workTime is Illness)
            {
                Illness illness = (Illness)workTime;
                select = "insert into choroba values('" + illness.IdEmployee + "'" +
                         ",'" + illness.Date.ToString("d", DateFormat.TakeDateFormat()) + "','" + illness.IdIllnessType + "')";
            }
            if (workTime is DayOff)
            {
                DayOff dayOff = (DayOff)workTime;
                select = "insert into urlop values('" + dayOff.IdEmployee + "'" +
                         ",'" + dayOff.Date.ToString("d", DateFormat.TakeDateFormat()) + "','" + dayOff.IdTypeDayOff + "')";
            }

            Database.Save(select, disconnect);
            //log
            LogSys.DodanieLoguSystemu(new LogSys(Polaczenia.idUser, RodzajZdarzenia.dodawanie, DateTime.Now, Polaczenia.ip, NazwaTabeli.praca, select), disconnect == ConnectionToDB.disconnect ? true : false);
        }
Exemple #3
0
        public static DayOff GetDayOff(int idEmployee, DateTime date, ConnectionToDB disconnect)//misiąc+rok
        {
            string select = "select * from urlop where id_pracownika=" + idEmployee +
                            " AND datepart(year,data)=" + date.Year + " AND datepart(month,data)=" + date.Month + " AND datepart(day,data)=" + date.Day;

            SqlDataReader dataReader = Database.GetData(select);

            DayOff d = new DayOff();

            while (dataReader.Read())
            {
                //id potrzebne do grida
                d.IdEmployee   = idEmployee;
                d.Date         = dataReader.GetDateTime(1);
                d.IdTypeDayOff = dataReader.GetInt32(2);
            }
            dataReader.Close();
            if (disconnect == ConnectionToDB.disconnect)
            {
                Polaczenia.OdlaczenieOdBazy();
            }
            return(d);
        }