示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            intProfile   = Int32.Parse(Request.Cookies["profileid"].Value);
            oPage        = new Pages(intProfile, dsn);
            oAppPage     = new AppPages(intProfile, dsn);
            oVacation    = new Vacation(intProfile, dsn);
            oHoliday     = new Holidays(intProfile, dsn);
            oSetting     = new Settings(intProfile, dsn);
            oUser        = new Users(intProfile, dsn);
            oVariable    = new Variables(intEnvironment);
            oFunction    = new Functions(intProfile, dsn, intEnvironment);
            oApplication = new Applications(intProfile, dsn);
            if (Request.QueryString["applicationid"] != null && Request.QueryString["applicationid"] != "")
            {
                intApplication = Int32.Parse(Request.QueryString["applicationid"]);
            }
            if (Request.QueryString["pageid"] != null && Request.QueryString["pageid"] != "")
            {
                intPage = Int32.Parse(Request.QueryString["pageid"]);
            }
            if (Request.Cookies["application"] != null && Request.Cookies["application"].Value != "")
            {
                intApplication = Int32.Parse(Request.Cookies["application"].Value);
            }
            if (Request.QueryString["all"] != null)
            {
                btnShowAll.Text         = "Show Preview of Resources";
                boolAll                 = true;
                intRows                 = 100;
                calThis.DayStyle.Width  = Unit.Percentage(15.00);
                calThis.DayStyle.Height = Unit.Percentage(100.00);
                calThis.Width           = Unit.Percentage(100.00);
                calThis.Height          = Unit.Percentage(100.00);
            }
            else
            {
                btnShowAll.Text         = "Show Full Listing of Resources";
                calThis.DayStyle.Width  = Unit.Percentage(15.00);
                calThis.DayStyle.Height = Unit.Pixel(80);
                calThis.Width           = Unit.Percentage(100.00);
                calThis.Height          = Unit.Pixel(500);
            }
            lblTitle.Text = oPage.Get(intPage, "title");
            DateTime _date       = DateTime.Today;
            double   dblFloating = double.Parse(oSetting.Get("floating"));
            double   dblPersonal = double.Parse(oSetting.Get("personal"));
            string   strVacation = oUser.Get(intProfile, "vacation");
            bool     boolDisable = true;

            if (strVacation != "")
            {
                double dblVacation = double.Parse(strVacation);
                if (dblVacation > 0)
                {
                    ds = oVacation.Gets(intProfile, DateTime.Today.Year);
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (DateTime.Parse(dr["start_date"].ToString()).Year == DateTime.Today.Year)
                        {
                            if (dr["vacation"].ToString() == "1")
                            {
                                dr["reason"] = "Vacation";
                                if (dr["morning"].ToString() == "1")
                                {
                                    dr["duration"] = "Morning";
                                    dblVacation    = dblVacation - .5;
                                }
                                else if (dr["afternoon"].ToString() == "1")
                                {
                                    dr["duration"] = "Afternoon";
                                    dblVacation    = dblVacation - .5;
                                }
                                else
                                {
                                    dr["duration"] = "Full Day";
                                    dblVacation    = dblVacation - 1;
                                }
                            }
                            else if (dr["holiday"].ToString() == "1")
                            {
                                dr["reason"] = "Floating Holiday";
                                if (dr["morning"].ToString() == "1")
                                {
                                    dr["duration"] = "Morning";
                                    dblFloating    = dblFloating - .5;
                                }
                                else if (dr["afternoon"].ToString() == "1")
                                {
                                    dr["duration"] = "Afternoon";
                                    dblFloating    = dblFloating - .5;
                                }
                                else
                                {
                                    dr["duration"] = "Full Day";
                                    dblFloating    = dblFloating - 1;
                                }
                            }
                            else if (dr["personal"].ToString() == "1")
                            {
                                dr["reason"] = "Personal / Sick Day";
                                if (dr["morning"].ToString() == "1")
                                {
                                    dr["duration"] = "Morning";
                                    dblPersonal    = dblPersonal - .5;
                                }
                                else if (dr["afternoon"].ToString() == "1")
                                {
                                    dr["duration"] = "Afternoon";
                                    dblPersonal    = dblPersonal - .5;
                                }
                                else
                                {
                                    dr["duration"] = "Full Day";
                                    dblPersonal    = dblPersonal - 1;
                                }
                            }
                        }
                    }
                    lblVacation.Text = dblVacation.ToString();
                    lblFloating.Text = dblFloating.ToString();
                    lblPersonal.Text = dblPersonal.ToString();
                    bool boolVacation = true;
                    bool boolFloating = true;
                    bool boolPersonal = true;
                    if (dblVacation < 1)
                    {
                        radVacation.Enabled = false;
                        boolVacation        = false;
                    }
                    if (dblFloating < 1)
                    {
                        radHoliday.Enabled = false;
                        boolFloating       = false;
                    }
                    if (dblPersonal < 1)
                    {
                        radPersonal.Enabled = false;
                        boolPersonal        = false;
                    }
                    if (boolVacation == false && boolFloating == false && boolPersonal == false)
                    {
                        boolDisable                = false;
                        radReason.Checked          = true;
                        divReason.Style["display"] = "inline";
                    }
                    else
                    {
                        boolDisable = false;
                    }
                    lblNone.Visible    = (ds.Tables[0].Rows.Count == 0);
                    rptView.DataSource = ds;
                    rptView.DataBind();
                    foreach (RepeaterItem ri in rptView.Items)
                    {
                        LinkButton _btnDelete = (LinkButton)ri.FindControl("btnDelete");
                        _btnDelete.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this event?');");
                        Label _lblDate = (Label)ri.FindControl("lblDate");
                        if (DateTime.Parse(_lblDate.Text) < DateTime.Today)
                        {
                            _btnDelete.Visible = false;
                        }
                    }
                }
            }
            if (boolDisable == true)
            {
                txtStart.Enabled     = false;
                txtEnd.Enabled       = false;
                imgStart.Enabled     = false;
                imgEnd.Enabled       = false;
                radMorning.Enabled   = false;
                radAfternoon.Enabled = false;
                radDay.Enabled       = false;
                radDays.Enabled      = false;
                radVacation.Enabled  = false;
                radPersonal.Enabled  = false;
                radHoliday.Enabled   = false;
                radReason.Enabled    = false;
                ddlReason.Enabled    = false;
                btnSubmit.Enabled    = false;
                lblConfigure.Visible = true;
            }
            if (Request.QueryString["d"] != null)
            {
                DateTime.TryParse(Request.QueryString["d"], out _date);
            }
            calThis.VisibleDate    = _date;
            calThis.SelectedDate   = _date;
            ddlYear.SelectedValue  = _date.Year.ToString();
            ddlMonth.SelectedValue = _date.Month.ToString();
            btnToday.ToolTip       = DateTime.Today.ToLongDateString();
            imgStart.Attributes.Add("onclick", "return ShowCalendar('" + txtStart.ClientID + "');");
            imgEnd.Attributes.Add("onclick", "return ShowCalendar('" + txtEnd.ClientID + "');");
            btnSubmit.Attributes.Add("onclick", "return ValidateVacation('" + radMorning.ClientID + "','" + radAfternoon.ClientID + "','" + radDay.ClientID + "','" + radDays.ClientID + "','" + txtStart.ClientID + "','" + txtEnd.ClientID + "','" + radVacation.ClientID + "','" + radHoliday.ClientID + "','" + radPersonal.ClientID + "','" + radReason.ClientID + "','" + ddlReason.ClientID + "');");
            radMorning.Attributes.Add("onclick", "Single('" + divStartDate.ClientID + "','" + divEndDate.ClientID + "','" + divType.ClientID + "','" + divReason.ClientID + "','" + divSubmit.ClientID + "');");
            radAfternoon.Attributes.Add("onclick", "Single('" + divStartDate.ClientID + "','" + divEndDate.ClientID + "','" + divType.ClientID + "','" + divReason.ClientID + "','" + divSubmit.ClientID + "');");
            radDay.Attributes.Add("onclick", "Single('" + divStartDate.ClientID + "','" + divEndDate.ClientID + "','" + divType.ClientID + "','" + divReason.ClientID + "','" + divSubmit.ClientID + "');");
            radDays.Attributes.Add("onclick", "Multiple('" + divStartDate.ClientID + "','" + divEndDate.ClientID + "','" + divType.ClientID + "','" + divReason.ClientID + "','" + divSubmit.ClientID + "');");
            radVacation.Attributes.Add("onclick", "ShowHideDiv('" + divReason.ClientID + "','none');");
            radPersonal.Attributes.Add("onclick", "ShowHideDiv('" + divReason.ClientID + "','none');");
            radHoliday.Attributes.Add("onclick", "ShowHideDiv('" + divReason.ClientID + "','none');");
            radReason.Attributes.Add("onclick", "ShowHideDiv('" + divReason.ClientID + "','inline');");
        }