Example #1
0
        protected void cldExam_DayRender(object sender, DayRenderEventArgs e)
        {
            #region Day Render Rows
            /********** render day ************/
            daysCounter++;
            if (e.Day.Date.Day == 1 && !e.Day.IsOtherMonth) // 1st of current month. Turn visibility of row to ON.
            {
                isLastRow = false;
            }
            else if (daysCounter == 36 && e.Day.IsOtherMonth) // 5 rows already rendered. If its the next row is next month, hide it.
            {
                isLastRow = true;
            }
            else if (daysCounter == 1 && e.Day.IsOtherMonth && e.Day.Date.Month == e.Day.Date.AddDays(6).Month)
            {   // If first row completely is previous month, hide it.
                // Actually the flag should be isFirstRow, but I dont want one more boolean just for the sake of it.
                isLastRow = true;
            }

            if (isLastRow)
            {
                e.Cell.Visible = false;
                return;
            }
            if (e.Day.IsWeekend && !e.Day.IsSelected)
            {
                e.Cell.Style.Add("background-color", "#f0e7f1");
            }
            /********* end render ************/
            #endregion
            e.Day.IsSelectable = false;
            e.Cell.Enabled     = false;
            e.Cell.ForeColor   = System.Drawing.Color.Gray;

            BLL.ExamScheduleBiz   biz     = new BLL.ExamScheduleBiz();
            Func <string, string> GetCrit = anyString =>
            {
                return(string.IsNullOrEmpty(anyString) ? string.Empty : anyString);
            };

            if (ExamSchedules.Count() > 0)
            {
                DateTime exam = ExamSchedules.FirstOrDefault(a => a.Date == e.Day.Date);


                if (exam != null && exam != DateTime.MinValue)
                {
                    LinkButton lnk = new LinkButton();

                    e.Cell.Controls.Add(new LiteralControl("</br>"));

                    lnk.ID        = "lnkButton";
                    lnk.Text      = "รายละเอียด";
                    lnk.ForeColor = System.Drawing.Color.Green;

                    e.Cell.Attributes.Add("onclick", e.SelectUrl);
                    e.Cell.Style.Add("cursor", "pointer");

                    e.Cell.Controls.Add(lnk);
                }
            }


            if (Holidays.Count() > 0)
            {
                //DataTable dt = dsHoliday.Tables[0];
                GBHoliday holiday  = Holidays.FirstOrDefault(s => s.HL_DATE.Date == e.Day.Date);
                DateTime  dtToday  = DateTime.Today.AddDays(-1);
                DateTime  dtFinish = DateTime.Today.AddDays(+5);

                //ExamRender examrender = new ExamRender();
                if (holiday != null)
                {
                    e.Cell.Controls.Add(new LiteralControl("</br>"));
                    Label lnk = new Label();
                    lnk.ID        = "lnkButton";
                    lnk.Enabled   = false;
                    lnk.Text      = holiday.HL_DESC;
                    lnk.ForeColor = System.Drawing.Color.Red;
                    lnk.BackColor = System.Drawing.Color.FromArgb(250, 200, 135);
                    e.Cell.Attributes.Add("onclick", e.SelectUrl);
                    e.Cell.Style.Add("cursor", "pointer");
                    e.Cell.Controls.Add(lnk);
                }
            }

            e.Cell.DataBind();
        }
Example #2
0
        internal static void AddDayOff(DayOff dayOff, int dayCounter)
        {
            string holidayDescription = "";

            Polaczenia.BeginTransaction();
            for (int i = 1; i <= dayCounter; i++)
            {
                if (dayOff.Date.DayOfWeek != DayOfWeek.Sunday && dayOff.Date.DayOfWeek != DayOfWeek.Saturday && !Holidays.IsHoliday(dayOff.Date, out holidayDescription, ConnectionToDB.notDisconnect))
                {
                    WorkManager.AddWorkTime(dayOff, ConnectionToDB.notDisconnect);
                    if (dayOff.IdTypeDayOff == (int)DayOffType.halfDay)
                    {
                        dayOff.DayOffSubtraction("0.5", ConnectionToDB.notDisconnect);
                    }
                    if (dayOff.IdTypeDayOff == (int)DayOffType.rest)
                    {
                        dayOff.DayOffSubtraction("1", ConnectionToDB.notDisconnect);
                    }

                    dayOff.Date = dayOff.Date.AddDays(1);//next day
                }
                else
                {
                    dayOff.Date = dayOff.Date.AddDays(1);//next day
                }
            }
            Polaczenia.CommitTransaction();
            //jeżeli wpisuje godziny w ostatni dzień miesiąca to nie przechodzi na kolejny
            int numbersOfDays = DateTime.DaysInMonth(MainForm.mainDate.Year, MainForm.mainDate.Month);

            if (numbersOfDays != MainForm.mainDate.Day)
            {
                //dodaje jeden dzień do aktualnej daty do zmiennej pomocniczej
                MainForm.mainDate = MainForm.mainDate.AddDays(dayCounter);
            }
        }
Example #3
0
        public static IEnumerable <string> RetrieveExampleList(string word)
        {
            word = word.ToLower();
            if (!word.StartsWith("something"))
            {
                if (word.StartsWith("the title") || word.StartsWith("a title"))
                {
                    word = word.Replace("the title ", string.Empty).Replace("a title ", string.Empty);
                }
                else
                {
                    Regex firstWordRegex = new Regex(@"^\w+ ");
                    word = firstWordRegex.Replace(word, "");
                    word = word.Replace("type of ", string.Empty);
                    word = word.Replace("kind of ", string.Empty);
                }
            }
            switch (word)
            {
            case "noun":
                return(Nouns.Take(3));

            case "adjective":
                return(Adjectives.Take(3));

            case "plural noun":
            case "noun (plural)":
                return(PluralNouns.Take(3));

            case "verb":
                return(Verbs.Take(3));

            case "number":
                Random rand = new Random();
                return(new List <string>()
                {
                    rand.Next(1, 999).ToString(), rand.Next(1, 999).ToString(), rand.Next(1, 999).ToString()
                });

            case @"verb ending in ""ing""":
                return(GerundVerbs.Take(3));

            case "adverb":
                return(Adverbs.Take(3));

            case "part of the body":
            case "body part":
                return(PartsOfBody.Take(3));

            case "liquid":
                return(Liquids.Take(3));

            case "place":
                return(Places.Take(3));

            case "animal":
                return(Animals.Take(3));

            case "food":
                return(Foods.Take(3));

            case "color":
                return(Colors.Take(3));

            case "verb (past tense)":
                return(PastTenseVerbs.Take(3));

            case "celebrity":
                return(Celebrities.Take(3));

            case "exclamation":
                return(Exclamations.Take(3));

            case "part of the body (plural)":
            case "body part (plural)":
                return(PluralBodyParts.Take(3));

            case "silly word":
                return(SillyWords.Take(3));

            case "animal (plural)":
                return(PluralAnimals.Take(3));

            case "city":
                return(Cities.Take(3));

            case "nonsense word":
                return(NonsenseWords.Take(3));

            case "famous person":
                return(FamousPeople.Take(3));

            case "article of clothing":
                return(Clothing.Take(3));

            case "vehicle":
                return(Vehicles.Take(3));

            case "something alive (plural)":
                return(PluralAliveSomethings.Take(3));

            case "geographical location":
                return(GeographicalLocations.Take(3));

            case "town":
                return(Towns.Take(3));

            case "country":
                return(Countries.Take(3));

            case "container":
                return(Containers.Take(3));

            case "last name":
                return(LastNames.Take(3));

            case "name":
                return(Names.Take(3));

            case @"verb ending in ""s""":
                return(VerbsEndingInS.Take(3));

            case "occupation":
            case "occupation or job":
            case "profession":
                return(Occupations.Take(3));

            case "silly noise":
                return(SillyNoises.Take(3));

            case "male celebrity":
            case "celebrity (male)":
                return(MaleCelebrities.Take(3));

            case "article of clothing (plural)":
                return(PluralClothing.Take(3));

            case "name of a school":
            case "school":
                return(Schools.Take(3));

            case "building":
                return(Buildings.Take(3));

            case "bird":
                return(Birds.Take(3));

            case @"adjective ending in ""est""":
            case "adjective (superlative)":
                return(Superlatives.Take(3));

            case "letter":
                return(Letters.Take(3));

            case "game":
                return(Games.Take(3));

            case "holiday":
                return(Holidays.Take(3));

            case "silly word (plural)":
                return(PluralSillyWords.Take(3));

            case "something round":
                return(RoundSomethings.Take(3));

            case "piece of furniture":
                return(Furniture.Take(3));

            case "vegetable":
                return(Vegetables.Take(3));

            case "spanish word":
                return(SpanishWords.Take(3));

            case "tv actor":
                return(TVActors.Take(3));

            case "boy's name":
                return(BoyNames.Take(3));

            case "something alive":
                return(AliveSomethings.Take(3));

            case "female celebrity":
            case "celebrity (female)":
                return(FemaleCelebrities.Take(3));

            case "italian word":
                return(ItalianWords.Take(3));

            case "occupation (plural)":
                return(PluralOccupations.Take(3));

            case "first name":
                return(FirstNames.Take(3));

            case "room in a house":
                return(HouseRooms.Take(3));

            case "relative":
                return(Relatives.Take(3));

            case "movie star":
                return(MovieStars.Take(3));

            case "disease":
                return(Diseases.Take(3));

            case "sport":
                return(Sports.Take(3));

            case "something icky":
                return(IckySomethings.Take(3));

            case "actor":
                return(Actors.Take(3));

            case "concept or ideal":
                return(Concepts.Take(3));

            default:
                return(new string[3] {
                    string.Empty, string.Empty, string.Empty
                });
            }
        }
 private HolidayItem getHolidayItem(int curDay)
 {
     return(Holidays.FirstOrDefault(item => item.Year == _year && item.Month == _month && item.Day == curDay));
 }
        private void PrintPreparation(object sender, PrintPageEventArgs e)
        {
            //na początku ustawia id pracownika na pierwszą wartość na liście
            idEmployee = (EmployeeManager.arrayEmployees[j] as Employee).IdEmployee;
            //następnie zwiększa i o 1
            j++;

            // utworzenie fonta
            Font font12     = new Font("Arial", 12, FontStyle.Regular, GraphicsUnit.Point);
            Font font10     = new Font("Arial", 10, FontStyle.Regular, GraphicsUnit.Point);
            Font font10Bold = new Font("Arial", 10, FontStyle.Bold, GraphicsUnit.Point);
            Font font12Bold = new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point);
            Font font14     = new Font("Arial", 14, FontStyle.Regular, GraphicsUnit.Point);
            Font font14Bold = new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point);

            //ustawienie wysokości fonta
            float wysokoscFonta10 = font10.GetHeight(e.Graphics);
            float wysokoscFonta12 = font12.GetHeight(e.Graphics);
            float wysokoscFonta14 = font14.GetHeight(e.Graphics);

            //kolor pióra czarny
            Pen penBlack = new Pen(Brushes.Black);

            //kolor wypełnienia
            Brush brushSzary = Brushes.LightGray;

            //zmienne lewego górnego punktu
            int y = 30;
            int x = e.MarginBounds.Left;

            //zmienna zawierająca 1/3 szerokosci strony
            int jednaTrzecia = (e.MarginBounds.Width / 3);

            //pobieranie danych pracownika
            foreach (Employee p in EmployeeManager.arrayEmployees)
            {
                if (p.IdEmployee == idEmployee)
                {
                    employee = p;
                }
            }

            //ustawienie tekstu w prostokątach
            StringFormat sf = new StringFormat();

            sf.Alignment     = StringAlignment.Center;//wśrodkowanie
            sf.LineAlignment = StringAlignment.Center;

            //PIERWSZA LINIA
            e.Graphics.DrawLine(penBlack, x, y, e.MarginBounds.Right, y);
            Rectangle rect = new Rectangle(x, y, e.MarginBounds.Right, (int)Math.Ceiling(font14.GetHeight(e.Graphics)));

            e.Graphics.DrawString(string.Format("EWIDENCJA CZASU PRACY - {0:MMMM} {1:yyy}", date.Date, date.Date), font14Bold, Brushes.Black, rect, sf);

            //DRUGA LINIA
            //zwiększenie y o wysokosc prostokata
            y += rect.Height;
            //przypisanie nowego Y do prostokąta
            rect.Y = y;
            e.Graphics.DrawLine(penBlack, x, y, e.MarginBounds.Right, y);//linia
            e.Graphics.DrawString(string.Format("{0} {1}", employee.FirstName, employee.LastName), font14Bold, Brushes.Black, rect, sf);
            //zwiekszenie Y o wysokosc prostokoata
            y += rect.Height;
            e.Graphics.DrawLine(penBlack, x, y, e.MarginBounds.Right, y);//linia

            //dodatkowy odstęp
            y += 10;

            #region NAGŁÓWKI TABELI

            //pierwszy prostokąt DZIEŃ
            SizeF     sF_Dzien = e.Graphics.MeasureString("poniedziałek", font10Bold);
            Rectangle r_Dzien  = new Rectangle();
            //data
            Rectangle r_DzienNr = new Rectangle();
            //słownie
            Rectangle r_DzienTyg = new Rectangle();

            //drugi prostokąt PODPIS PRACOWNIKA
            SizeF     sF_Podpis = e.Graphics.MeasureString("pracownika", font10Bold);
            Rectangle r_Podpis  = new Rectangle();

            //trzeci prostokąt CZAS PRACY
            Rectangle r_CzasPracy = new Rectangle();
            //rozpoczecie
            Rectangle r_CzasPracyRozp = new Rectangle();
            //zakonczenie
            Rectangle r_CzasPracyZakon = new Rectangle();
            //ilosc godz
            Rectangle r_CzasPracyIlosc = new Rectangle();

            //czwarty prostokąt NIEOBECNOSCI
            Rectangle r_Nieobecnosci = new Rectangle();
            //urlop
            Rectangle r_NieobecnosciUrlop = new Rectangle();
            //L4
            Rectangle r_NieobecnosciL4 = new Rectangle();
            //inne
            Rectangle r_NieobecnosciInne = new Rectangle();

            //zwiększa Y o wysokość prostokąta
            y += rect.Height;

            //
            //NAGŁÓWKI TABELI
            //DZIEŃ
            //
            r_Dzien.X      = x;
            r_Dzien.Y      = y;
            r_Dzien.Width  = (int)((jednaTrzecia * 60) / 100); // szerokość prostokąta 60% z 1/3
            r_Dzien.Height = font10Bold.Height * 3;            //wysokość prostokąta wg SizeF
            //rysowanie danych
            e.Graphics.DrawString("dzień", font10Bold, Brushes.Black, r_Dzien, sf);
            e.Graphics.DrawRectangle(penBlack, r_Dzien);

            //PODPIS PRACOWNIKA
            r_Podpis.X      = r_Dzien.Right;
            r_Podpis.Y      = r_Dzien.Y;
            r_Podpis.Width  = (int)((jednaTrzecia * 40) / 100);
            r_Podpis.Height = r_Dzien.Height;
            //rysowanie danych
            e.Graphics.DrawString("podpis pracownika", font10Bold, Brushes.Black, r_Podpis, sf);
            e.Graphics.DrawRectangle(penBlack, r_Podpis);

            //
            //CZAS PRACY
            //
            r_CzasPracy.X      = r_Podpis.Right;
            r_CzasPracy.Y      = r_Dzien.Y;
            r_CzasPracy.Width  = jednaTrzecia;       //szerokość prostokąta 1/3 strony
            r_CzasPracy.Height = r_Dzien.Height / 2; //wysokość prostokąta wg SizeF
            //rysowanie danych
            e.Graphics.DrawString("czas pracy", font10Bold, Brushes.Black, r_CzasPracy, sf);
            e.Graphics.DrawRectangle(penBlack, r_CzasPracy);

            //rozp
            r_CzasPracyRozp.X      = r_Podpis.Right;
            r_CzasPracyRozp.Y      = r_Dzien.Y + r_CzasPracy.Height; //+ wys CZAS PRACY
            r_CzasPracyRozp.Width  = r_CzasPracy.Width / 3;          //szerokość prostokąta 1/3 CZAS PRACY
            r_CzasPracyRozp.Height = r_Dzien.Height / 2;             //wysokość prostokąta
            //rysowanie danych
            e.Graphics.DrawString("rozp.", font10, Brushes.Black, r_CzasPracyRozp, sf);
            e.Graphics.DrawRectangle(penBlack, r_CzasPracyRozp);

            //zakonczenie
            r_CzasPracyZakon.X      = r_CzasPracyRozp.Right;
            r_CzasPracyZakon.Y      = r_CzasPracyRozp.Y;
            r_CzasPracyZakon.Width  = r_CzasPracy.Width / 3; //szerokość prostokąta 1/3 CZAS PRACY
            r_CzasPracyZakon.Height = r_Dzien.Height / 2;    //wysokość prostokąta
            //rysowanie danych
            e.Graphics.DrawString("zakończ.", font10, Brushes.Black, r_CzasPracyZakon, sf);
            e.Graphics.DrawRectangle(penBlack, r_CzasPracyZakon);

            //ilosc godzin
            r_CzasPracyIlosc.X      = r_CzasPracyZakon.Right;
            r_CzasPracyIlosc.Y      = r_CzasPracyRozp.Y;
            r_CzasPracyIlosc.Width  = r_CzasPracy.Width / 3; //szerokość prostokąta 1/3 CZAS PRACY
            r_CzasPracyIlosc.Height = r_Dzien.Height / 2;    //wysokość prostokąta
            //rysowanie danych
            e.Graphics.DrawString("ilość godz.", font10, Brushes.Black, r_CzasPracyIlosc, sf);
            e.Graphics.DrawRectangle(penBlack, r_CzasPracyIlosc);

            //
            //NIEOBECNOŚCI
            //
            r_Nieobecnosci.X      = r_CzasPracy.Right;
            r_Nieobecnosci.Y      = r_Dzien.Y;
            r_Nieobecnosci.Width  = jednaTrzecia;       //szerokość prostokąta wg SizeF
            r_Nieobecnosci.Height = r_Dzien.Height / 2; //wysokość prostokąta wg SizeF
            //rysowanie danych
            e.Graphics.DrawString("nieobecności", font10Bold, Brushes.Black, r_Nieobecnosci, sf);
            e.Graphics.DrawRectangle(penBlack, r_Nieobecnosci);

            //urlop
            r_NieobecnosciUrlop.X      = r_CzasPracyIlosc.Right;
            r_NieobecnosciUrlop.Y      = r_Dzien.Y + r_Nieobecnosci.Height;
            r_NieobecnosciUrlop.Width  = r_Nieobecnosci.Width / 3; // 1/3 szerokości NIEOBECNOSCI
            r_NieobecnosciUrlop.Height = r_Dzien.Height / 2;       //wysokość prostokąta wg SizeF
            //rysowanie danych
            e.Graphics.DrawString("urlop", font10, Brushes.Black, r_NieobecnosciUrlop, sf);
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciUrlop);

            //L4
            r_NieobecnosciL4.X      = r_NieobecnosciUrlop.Right;
            r_NieobecnosciL4.Y      = r_NieobecnosciUrlop.Y;
            r_NieobecnosciL4.Width  = r_Nieobecnosci.Width / 3; // 1/3 szerokości NIEOBECNOSCI
            r_NieobecnosciL4.Height = r_Dzien.Height / 2;       //wysokość prostokąta wg SizeF
            //rysowanie danych
            e.Graphics.DrawString("zwoln. lek.", font10, Brushes.Black, r_NieobecnosciL4, sf);
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciL4);

            //inne
            r_NieobecnosciInne.X      = r_NieobecnosciL4.Right;
            r_NieobecnosciInne.Y      = r_NieobecnosciUrlop.Y;
            r_NieobecnosciInne.Width  = r_Nieobecnosci.Width / 3; // 1/3 szerokości NIEOBECNOSCI
            r_NieobecnosciInne.Height = r_Dzien.Height / 2;       //wysokość prostokąta wg SizeF
            //rysowanie danych
            e.Graphics.DrawString("inne", font10, Brushes.Black, r_NieobecnosciInne, sf);
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciInne);

            #endregion

            #region tabela

            //
            //przygotowanie zmiennych
            //
            y = r_Dzien.Bottom;
            //data potrzebna w pętli do wypisywania dni
            DateTime dataTemp;
            //DZIEŃ NR
            r_DzienNr.X      = x;
            r_DzienNr.Y      = y;
            r_DzienNr.Width  = ((r_Dzien.Width * 25) / 100); // szerokość prostokąta 25% z 1/3 DZIEN
            r_DzienNr.Height = font14Bold.Height;            //wysokość prostokąta

            //DZIEŃ TYG
            r_DzienTyg.X      = r_DzienNr.Right;
            r_DzienTyg.Y      = y;
            r_DzienTyg.Width  = r_Dzien.Width - r_DzienNr.Width;
            r_DzienTyg.Height = font14Bold.Height;//wysokość prostokąta

            //podpis
            r_Podpis.Y      = y;
            r_Podpis.Height = font14Bold.Height;//wysokość prostokąta

            //rozp
            r_CzasPracyRozp.Y      = y;
            r_CzasPracyRozp.Height = font14Bold.Height;//wysokość prostokąta

            //zakńcz
            r_CzasPracyZakon.Y      = y;
            r_CzasPracyZakon.Height = font14Bold.Height;//wysokość prostokąta

            //ilosc godzin
            r_CzasPracyIlosc.Y      = y;
            r_CzasPracyIlosc.Height = font14Bold.Height;//wysokość prostokąta

            //urlop
            r_NieobecnosciUrlop.Y      = y;
            r_NieobecnosciUrlop.Height = font14Bold.Height;//wysokość prostokąta

            //L4
            r_NieobecnosciL4.Y      = y;
            r_NieobecnosciL4.Height = font14Bold.Height;//wysokość prostokąta

            //inne
            r_NieobecnosciInne.Y      = y;
            r_NieobecnosciInne.Height = font14Bold.Height;//wysokość prostokąta

            //pobieranie godzin z bazy do listy
            Holidays.GetAll(date);
            //ustawia date na 1 zien danego miesiaca
            dataTemp = new DateTime(date.Year, date.Month, 1);


            //Tworzenie tabeli
            for (int i = 1; i <= DateTime.DaysInMonth(date.Year, date.Month); i++)
            {
                //wypełnienie prostokąta na szaro gdy weekend lub
                //dniWolne ma id (gdy nie ma to zanczy że to nie świeto tylko brak wpisu)
                if (Holidays.IsHolidayOrWeekend(dataTemp))
                {
                    e.Graphics.FillRectangle(brushSzary, r_DzienNr);
                    e.Graphics.FillRectangle(brushSzary, r_DzienTyg);
                    e.Graphics.FillRectangle(brushSzary, r_Podpis);
                    e.Graphics.FillRectangle(brushSzary, r_CzasPracyRozp);
                    e.Graphics.FillRectangle(brushSzary, r_CzasPracyZakon);
                    e.Graphics.FillRectangle(brushSzary, r_CzasPracyIlosc);
                    e.Graphics.FillRectangle(brushSzary, r_NieobecnosciUrlop);
                    e.Graphics.FillRectangle(brushSzary, r_NieobecnosciL4);
                    e.Graphics.FillRectangle(brushSzary, r_NieobecnosciInne);
                }

                //dzień NR
                e.Graphics.DrawString(i.ToString(), font10, Brushes.Black, r_DzienNr, sf);
                e.Graphics.DrawRectangle(penBlack, r_DzienNr);
                //dzień TYG
                e.Graphics.DrawString(string.Format("{0:dddd}", dataTemp), font10, Brushes.Black, r_DzienTyg, sf);
                e.Graphics.DrawRectangle(penBlack, r_DzienTyg);
                //pozostałe
                e.Graphics.DrawRectangle(penBlack, r_Podpis);
                e.Graphics.DrawRectangle(penBlack, r_CzasPracyRozp);
                e.Graphics.DrawRectangle(penBlack, r_CzasPracyZakon);
                e.Graphics.DrawRectangle(penBlack, r_CzasPracyIlosc);
                e.Graphics.DrawRectangle(penBlack, r_NieobecnosciUrlop);
                e.Graphics.DrawRectangle(penBlack, r_NieobecnosciL4);
                e.Graphics.DrawRectangle(penBlack, r_NieobecnosciInne);

                //dodaje kolejny dzień
                dataTemp = dataTemp.AddDays(1);
                //kolejny wiersz
                r_DzienNr.Y           += r_DzienNr.Height;
                r_DzienTyg.Y          += r_DzienTyg.Height;
                r_Podpis.Y            += r_Podpis.Height;
                r_CzasPracyRozp.Y     += r_CzasPracyRozp.Height;
                r_CzasPracyZakon.Y    += r_CzasPracyZakon.Height;
                r_CzasPracyIlosc.Y    += r_CzasPracyIlosc.Height;
                r_NieobecnosciUrlop.Y += r_NieobecnosciUrlop.Height;
                r_NieobecnosciL4.Y    += r_NieobecnosciL4.Height;
                r_NieobecnosciInne.Y  += r_NieobecnosciInne.Height;
            }

            #endregion

            #region podliczenia

            //suma godzin
            rect.X      = r_Dzien.Right;
            rect.Y      = r_DzienNr.Y;
            rect.Height = font14Bold.Height;
            rect.Width  = r_Podpis.Width + r_CzasPracyRozp.Width + r_CzasPracyZakon.Width;
            //wyrównanie do prawej
            sf.Alignment = StringAlignment.Far;
            //pozostałe prostokąty
            e.Graphics.DrawString("suma godzin przepracowanych:", font10Bold, Brushes.Black, rect, sf);
            e.Graphics.DrawRectangle(penBlack, r_CzasPracyIlosc);    //rysowanie prostokąta
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciUrlop); //rysowanie prostokąta
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciL4);    //rysowanie prostokąta
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciInne);  //rysowanie prostokąta

            //normatywny czas pracy
            rect.Y += rect.Height;
            e.Graphics.DrawString("normatywny czas pracy:", font10Bold, Brushes.Black, rect, sf);
            //ilosc godz
            rect.X       = r_CzasPracyIlosc.X;
            rect.Width   = r_CzasPracyIlosc.Width;
            sf.Alignment = StringAlignment.Center;
            e.Graphics.DrawString(string.Format("{0}h", HumanResources.Salaries.Salary.GetHoursToWork(date)), font10Bold, Brushes.Black, rect, sf);
            //pozostałe prostokąty
            r_CzasPracyIlosc.Y += r_CzasPracyIlosc.Height;           //zmiana Y
            e.Graphics.DrawRectangle(penBlack, r_CzasPracyIlosc);    //rysowanie prostokąta
            r_NieobecnosciUrlop.Y += r_NieobecnosciUrlop.Height;     //zmiana Y
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciUrlop); //rysowanie prostokąta
            r_NieobecnosciL4.Y += r_NieobecnosciL4.Height;           //zmiana Y
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciL4);    //rysowanie prostokąta
            r_NieobecnosciInne.Y += r_NieobecnosciInne.Height;       //zmiana Y
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciInne);  //rysowanie prostokąta

            //liczba nadgodzin
            rect.X     = r_Dzien.Right;
            rect.Y     = r_CzasPracyIlosc.Bottom;
            rect.Width = r_Podpis.Width + r_CzasPracyRozp.Width + r_CzasPracyZakon.Width;
            //wyrównanie do prawej
            sf.Alignment = StringAlignment.Far;
            //pozostałe prostokąty
            e.Graphics.DrawString("liczba nadgodzin:", font10Bold, Brushes.Black, rect, sf);
            r_CzasPracyIlosc.Y += r_CzasPracyIlosc.Height;           //zmiana Y
            e.Graphics.DrawRectangle(penBlack, r_CzasPracyIlosc);    //rysowanie prostokąta
            r_NieobecnosciUrlop.Y += r_NieobecnosciUrlop.Height;     //zmiana Y
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciUrlop); //rysowanie prostokąta
            r_NieobecnosciL4.Y += r_NieobecnosciL4.Height;           //zmiana Y
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciL4);    //rysowanie prostokąta
            r_NieobecnosciInne.Y += r_NieobecnosciInne.Height;       //zmiana Y
            e.Graphics.DrawRectangle(penBlack, r_NieobecnosciInne);  //rysowanie prostokąta
            #endregion

            //sprawdzenie czy trzeba drukować więcej stron
            if (EmployeeManager.arrayEmployees.Count > j)
            {
                e.HasMorePages = true;
            }

            //jeżeli jest wł podgląd wydruku, to trzeba wyzerować zmienną, ponieważ podgląd zwiększa o jeden i następnie drukowanie
            //zaczyna od zwiększonego j zamiast o zera i jest błąd indeksu
            if (EmployeeManager.arrayEmployees.Count == j)
            {
                j = 0;
            }
        }
Example #6
0
        public void Initialize()
        {
            try
            {
                if (_db.Database.GetPendingMigrations().Count() > 0)
                {
                    _db.Database.Migrate();
                }
            }
            catch (Exception ex)
            {
            }

            if (_db.Roles.Any(r => r.Name == StaticData.AdminRole))
            {
                return;
            }

            _roleManager.CreateAsync(new IdentityRole(StaticData.AdminRole)).GetAwaiter().GetResult();
            _roleManager.CreateAsync(new IdentityRole(StaticData.EmployeeRole)).GetAwaiter().GetResult();
            _roleManager.CreateAsync(new IdentityRole(StaticData.UserRole)).GetAwaiter().GetResult();

            _userManager.CreateAsync(new ApplicationUser
            {
                UserName       = "******",
                Email          = "*****@*****.**",
                EmailConfirmed = true,
                FirstName      = "Dawid",
                LastName       = "Dawidowicz",
                City           = "Częstochowa",
                PostalCode     = "44-777",
                Street         = "Pierwsza",
                HouseNumber    = 12,
                FlatNumber     = 2,
                PhoneNumber    = "123123123"
            }, "Password123!@#").GetAwaiter().GetResult();

            ApplicationUser user = _db.ApplicationUser.Where(u => u.Email == "*****@*****.**").FirstOrDefault();

            _userManager.AddToRoleAsync(user, StaticData.AdminRole).GetAwaiter().GetResult();
            _userManager.AddToRoleAsync(user, StaticData.EmployeeRole).GetAwaiter().GetResult();
            _userManager.AddToRoleAsync(user, StaticData.UserRole).GetAwaiter().GetResult();
            _db.SaveChanges();

            _db.BusStop.Add(new BusStop()
            {
                Name     = "Brak",
                IsActive = true
            });
            _db.SaveChanges();

            _db.BankAccount.Add(new BankAccount()
            {
                CompanyName    = "Bus Application",
                CompanyAddress = "ul. Busów, 22-434 Częstochowa",
                AccountNumber  = "12 2312 5645 8978 4758 2698 1397"
            });
            _db.SaveChanges();

            #region holidays
            Holidays hol1 = new Holidays()
            {
                Name  = "Nowy Rok",
                Day   = 1,
                Month = 1
            };
            _db.Holidays.Add(hol1);
            _db.SaveChanges();

            Holidays hol2 = new Holidays()
            {
                Name  = "Święto Trzech Króli",
                Day   = 6,
                Month = 1
            };
            _db.Holidays.Add(hol2);
            _db.SaveChanges();

            Holidays hol3 = new Holidays()
            {
                Name  = "1 Maja",
                Day   = 1,
                Month = 5
            };
            _db.Holidays.Add(hol3);
            _db.SaveChanges();

            Holidays hol4 = new Holidays()
            {
                Name  = "3 Maja",
                Day   = 3,
                Month = 5
            };
            _db.Holidays.Add(hol4);
            _db.SaveChanges();

            Holidays hol5 = new Holidays()
            {
                Name  = "Zielone świątki",
                Day   = 23,
                Month = 5
            };
            _db.Holidays.Add(hol5);
            _db.SaveChanges();

            Holidays hol6 = new Holidays()
            {
                Name  = "Wniebowzięcie Najświętszej Maryi Panny",
                Day   = 15,
                Month = 8
            };
            _db.Holidays.Add(hol6);
            _db.SaveChanges();

            Holidays hol7 = new Holidays()
            {
                Name  = "Wszystkich świętych",
                Day   = 1,
                Month = 11
            };
            _db.Holidays.Add(hol7);
            _db.SaveChanges();

            Holidays hol8 = new Holidays()
            {
                Name  = "Święto Niepodległości",
                Day   = 11,
                Month = 11
            };
            _db.Holidays.Add(hol8);
            _db.SaveChanges();

            Holidays hol9 = new Holidays()
            {
                Name  = "1 dzień Bożego Narodzenia",
                Day   = 25,
                Month = 12
            };
            _db.Holidays.Add(hol9);
            _db.SaveChanges();

            Holidays hol10 = new Holidays()
            {
                Name  = "2 dzień Bożego Narodzenia",
                Day   = 26,
                Month = 12
            };
            _db.Holidays.Add(hol10);
            _db.SaveChanges();
            #endregion
        }
Example #7
0
        protected void BookButton_Click(object sender, EventArgs e)
        {
            OkButton.Visible = false;


            constraints.AcceptedHolidays = ws.GetApprovedHolidays();


            // Selected data
            DateTime from  = FromCalendar.SelectedDate;
            DateTime to    = ToCalendar.SelectedDate;
            DateTime today = DateTime.Now;


            // Validate selected date
            if (from >= today && to >= today && to >= from)
            {
                bookingRequest = new Holidays {
                    Staff = user, Start = from, End = to
                };

                try
                {
                    // If no errors found
                    if (constraints.CheckHoliday(bookingRequest) == null)
                    {
                        // If booking successful
                        if (ws.SubmitBooking(user.Username, bookingRequest.Start, bookingRequest.End))
                        {
                            // Update label
                            MsgLabel.Visible = true;
                            MsgLabel.Text    = "Holiday Booked";
                        }
                        else
                        {
                            // Update label
                            MsgLabel.Visible = true;
                            MsgLabel.Text    = "Unable to book";
                        }
                    }
                    else
                    {
                        bookingRequest = constraints.SuggestNewDate(bookingRequest);

                        // If new recommended date found
                        if (bookingRequest != null)
                        {
                            // Alternative date text
                            MsgLabel.Text    = "An alternative date has been found between " + bookingRequest.Start.ToLongDateString() + " - " + bookingRequest.End.ToLongDateString() + "<br />Would you like to book then?";
                            OkButton.Visible = true;
                        }
                        else
                        {
                            MsgLabel.Visible = true;
                            MsgLabel.Text    = "Unable to book a holiday during that time";
                        }
                    }
                }
                catch (Exception e1)
                {
                }
            }
            else
            {
                MsgLabel.Visible = true;
                MsgLabel.Text    = "Dates selected cannot be chosen";
            }
        }