Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // If querystring value is missing, send the user to ManageUsers.aspx
                string userName = Context.User.Identity.Name;
                //if (string.IsNullOrEmpty(userName))
                //    Response.Redirect("manageusers.aspx");

                holidays.user u = PolaczenieSQL.find_user(userName, false, true);

                // Get information about this user
                MembershipUser usr = Membership.GetUser(userName);

                //if (usr == null)
                //    Response.Redirect("manageusers.aspx");

                user_name_label.InnerText = "User Account: " + usr.UserName;
                TextBox_email.Text        = usr.Email;
                //HiddenFielduserid.Value = usr.UserName;

                if (Roles.IsUserInRole(usr.UserName, "emploee"))
                {
                    Pracownik.Checked = true;
                }
                if (Roles.IsUserInRole(usr.UserName, "hr_emploee"))
                {
                    PracownikHR.Checked = true;
                }
                if (Roles.IsUserInRole(usr.UserName, "Administrators"))
                {
                    PracownikAdmin.Checked = true;
                }
                if (Roles.IsUserInRole(usr.UserName, "menager"))
                {
                    PracownikMenager.Checked = true;
                }

                ImieTextBox.Text     = u.imie.ToString();
                NazwiskoTextBox.Text = u.nazwisko.ToString();
                PeselTextBox.Text    = u.pesel.ToString();
                string data_urodz        = u.data_urodzenia.ToString();
                string data_zatrudnienia = u.data_zatrudnienia.ToString();
                string kiedy26           = u.kiedy26.ToString();
                TeamTextBox.Text = u.team.ToString();

                string[] days_of_holidays = holidays.PolaczenieSQL.find_holiday_days_byuser(usr.UserName);
                Labelpr.Text  = days_of_holidays[0];
                Labelor.Text  = days_of_holidays[8];
                Labelnr.Text  = days_of_holidays[9];
                Labeldd.Text  = days_of_holidays[5];
                Labelnz.Text  = days_of_holidays[6];
                Labelsum.Text = days_of_holidays[10];
                Labelwyk.Text = days_of_holidays[3];

                if (Convert.ToInt16(Labelsum.Text) > 0)
                {
                    suncell.BackColor = Color.LightGreen;
                }
                if (Convert.ToInt16(Labelsum.Text) <= 0)
                {
                    suncell.BackColor = Color.LightPink;
                }

                DateTime myTime;

                if (data_urodz != string.Empty)
                {
                    myTime             = DateTime.Parse(data_urodz);
                    Dataurodzenia.Text = myTime.ToString("dd-MM-yyyy");
                }


                if (data_zatrudnienia != string.Empty)
                {
                    myTime = DateTime.Parse(data_zatrudnienia);
                    DataZatrudnienia.Text = myTime.ToString("dd-MM-yyyy");
                }


                switch (u.dniurlopowe.ToString())
                {
                case "1":
                    DropDownList2TextBox.Text = "20";
                    break;

                case "2":
                    DropDownList2TextBox.Text = "26";
                    break;

                default:
                    DropDownList2TextBox.Text = "26";
                    break;
                }

                if (u.dniurlopowe.ToString() == "1")
                {
                    uzyska26label.Visible   = true;
                    uzyska26TextBox.Visible = true;
                    if (kiedy26 != string.Empty)
                    {
                        myTime = DateTime.Parse(kiedy26);
                        uzyska26TextBox.Text = myTime.ToString("dd-MM-yyyy");
                    }
                }

                if (u.passtemp.ToString() == "True")
                {
                    info_label.Visible = true;
                    info_label.Text    = "Your password is setup as tempolary. Please change your password now!";
                }
                else
                {
                    info_label.Visible = false;
                }
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                string[] days_of_holidays = holidays.PolaczenieSQL.find_holiday_days_byuser(Context.User.Identity.Name);
                Labelpr.Text  = days_of_holidays[0];
                Labelor.Text  = days_of_holidays[8];
                Labelnr.Text  = days_of_holidays[9];
                Labeldd.Text  = days_of_holidays[5];
                Labelnz.Text  = days_of_holidays[6];
                Labelsum.Text = days_of_holidays[10];
                Labelwyk.Text = days_of_holidays[3];

                if (Convert.ToInt16(Labelsum.Text) > 0)
                {
                    suncell.BackColor = Color.LightGreen;
                }
                if (Convert.ToInt16(Labelsum.Text) <= 0)
                {
                    suncell.BackColor = Color.LightPink;
                }

                List <string> holiday_list = holidays.PolaczenieSQL.find_holiday_byuser(Context.User.Identity.Name);

                DataTable td = new DataTable();
                td.Columns.Add("From");
                td.Columns.Add("To");
                td.Columns.Add("Rodzaj");
                td.Columns.Add("ManagerId");
                td.Columns.Add("Status");
                td.Columns.Add("Id");
                td.Columns.Add("Ilosc_dni");
                DataRow dr = null;

                DateTime myTime;

                if (holiday_list != null)
                {
                    foreach (string holidayID in holiday_list)
                    {
                        holidays.holiday h = holidays.PolaczenieSQL.find_holiday(holidayID);

                        dr = td.NewRow();
                        if (h.date_od != null)
                        {
                            myTime = DateTime.Parse(h.date_od.ToString());
                            dr[0]  = myTime.ToString("yyyy-MM-dd");
                            if (h.statusid == "3" && (myTime <= DateTime.Today))
                            {
                                h.wykorzystany();
                                h.status = "Wykonany";
                            }
                        }
                        if (h.date_od != null)
                        {
                            myTime = DateTime.Parse(h.date_do.ToString());
                            dr[1]  = myTime.ToString("yyyy-MM-dd");
                        }
                        dr[2] = h.rodzaj.ToString();
                        holidays.user m = holidays.PolaczenieSQL.find_user(h.menager.ToString());
                        if (m != null)
                        {
                            dr[3] = m.ToString();
                        }
                        else
                        {
                            dr[3] = "User deleted";
                        }

                        dr[4] = h.status.ToString();
                        dr[5] = h.holidayid.ToString();
                        dr[6] = h.holiday_dyas_all.ToString();
                        td.Rows.Add(dr);
                    }
                }

                GridView1.DataSource = td;
                GridView1.DataBind();
                holidays.PageMetods.holiday_status_color(GridView1);
                DropDownMenager.DataBind();

                //if (Request.QueryString["teamadd"] != null)
                //{
                //    string teamadd = Request.QueryString["teamadd"];
                //    info_label.Text = "Team <b> " + teamadd + "</b> został dodant z bazy danych";
                //    info_label.CssClass = "goodNotification";
                //    info_label.Visible = true;
                //}
                //else { info_label.Text = ""; }

                //if (Request.QueryString["nodeleteteamid"] != null && Request.QueryString["nodeleteteamName"] != null && Request.QueryString["userscount"] == null)
                //{
                //    string noteamdeletename = Request.QueryString["nodeleteteamName"];
                //    string noteamdeleteid = Request.QueryString["nodeleteteamid"];
                //    info_label.Text = "Nie można usunąc tamu <b>id: " + noteamdeleteid + "</b>. Taki team nie istnieje w bazie danych";
                //    info_label.CssClass = "failureNotification";
                //    info_label.Visible = true;
                //}

                //if (Request.QueryString["deleteteamid"] != null && Request.QueryString["deleteteamName"] != null)
                //{
                //    string teamdeleteid = Request.QueryString["deleteteamid"];
                //    string teamdeletename = Request.QueryString["deleteteamName"];
                //    info_label.Text = "Team <b> " + teamdeletename + "</b> (id: " + teamdeleteid + ") został usunięty z bazy danych";
                //    info_label.CssClass = "failureNotification";
                //    info_label.Visible = true;
                //}

                //if (String.Equals(Request.QueryString["userscount"], "1"))
                //{
                //    string teamdeleteid = Request.QueryString["nodeleteteamid"];
                //    string teamdeletename = Request.QueryString["nodeleteteamName"];
                //    info_label.Text = "Team <b> " + teamdeletename + "</b> (id: " + teamdeleteid + ") nie może zostac usunięty, gdyż są do niego wciąż podłączeni pracownicy<br />By usunąś team odłącz od niego wszystkich przcowników. <a href='/hr/manageteam.aspx?teamid=" + teamdeleteid + "'>Zarządzaj Teamem " + teamdeletename + "</a>";
                //    info_label.CssClass = "failureNotification";
                //    info_label.Visible = true;
                //}
            }
            else
            {
                string menager1 = Request.Form[DropDownMenager.UniqueID];
                DropDownMenager.Text = menager1;
                string rodzaj1 = Request.Form[DropDownHoliday.UniqueID];
                DropDownHoliday.Text = rodzaj1;
                string date1 = Request.Form[OdTextBox.UniqueID];
                OdTextBox.Text = date1;
                string date3 = Request.Form[DoTextBox.UniqueID];
                DoTextBox.Text  = date3;
                info_label.Text = "";
            }

            DateTime date0 = new DateTime(DateTime.Today.Year, 1, 1);
            DateTime date2 = new DateTime(DateTime.Today.Year + 1, 3, 1);

            PageMetods.month_calendar_by_holidayid(bigDiv, date0, date2, Context.User.Identity.Name);
            Session.Contents.RemoveAll();
            GC.SuppressFinalize(this);
            foreach (System.Collections.DictionaryEntry entry in HttpContext.Current.Cache)
            {
                HttpContext.Current.Cache.Remove((string)entry.Key);
            }
        }