Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        public static void GetIllnessToList(int idEmployee, DateTime date, ConnectionToDB disconnect)//misiąc+rok
        {
            string select = "select * from choroba_rodzaj_new where id_pracownika=" + idEmployee +
                            " AND datepart(year,data)=" + date.Year + " AND datepart(month,data)=" + date.Month;

            SqlDataReader dataReader = Database.GetData(select);

            while (dataReader.Read())
            {
                Illness i = new Illness();

                i.IdEmployee         = idEmployee;
                i.Date               = dataReader.GetDateTime(1);
                i.IdIllnessType      = dataReader.GetInt32(2);
                i.PercentTypeIllness = dataReader.GetFloat(3);

                arrayListWorkTime.Add(i);
            }
            dataReader.Close();
            if (disconnect == ConnectionToDB.disconnect)
            {
                Polaczenia.OdlaczenieOdBazy();
            }
        }