Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!LoginState.IsAdmin())
     {
         FormsAuthentication.RedirectToLoginPage();
     }
 }
Пример #2
0
    void inner_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        Post p = (Post)e.Item.DataItem;

        if (p == null)
        {
            return;
        }
        ImageButton btn = (ImageButton)e.Item.FindControl("ButtonDelete");

        btn.CommandArgument       = currentAppointment.Id.ToString() + '.' + p.Id.ToString();
        btn.Attributes["OwnerId"] = LoginState.IsAdmin() ? "admin" : p.UserId;
    }
Пример #3
0
 protected void ButtonDeleteAppointment_Click(object sender, EventArgs e)
 {
     try
     {
         if (LoginState.IsAdmin() || (((ImageButton)sender).Attributes["OwnerId"] == UserId.Value))
         {
             DBHelper.DeleteAppointment(int.Parse(((ImageButton)sender).CommandArgument));
         }
     }
     catch (Exception ex)
     {
         Log.Add(ex.ToString());
     }
     LoadAppointments();
 }
Пример #4
0
 protected void ButtonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         string[] tokens = ((ImageButton)sender).CommandArgument.Split('.');
         if (LoginState.IsAdmin() || (((ImageButton)sender).Attributes["OwnerId"] == UserId.Value))
         {
             DBHelper.DeletePost(int.Parse(tokens[0]), int.Parse(tokens[1]));
         }
     }
     catch (Exception ex)
     {
         Log.Add(ex.ToString());
     }
     LoadAppointments();
 }
Пример #5
0
    protected void Appointments_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        currentAppointment = (Appointment)e.Item.DataItem;
        if (currentAppointment == null)
        {
            return;
        }

        ImageButton btnDel = (ImageButton)e.Item.FindControl("ButtonDelete");

        btnDel.CommandArgument       = currentAppointment.Id.ToString();
        btnDel.Attributes["OwnerId"] = LoginState.IsAdmin() ? "admin" : currentAppointment.UserId;

        Repeater    inner = (Repeater)e.Item.FindControl("Posts");
        List <Post> posts = new List <Post>();

        foreach (Post p in currentAppointment.AppointmentPosts)
        {
            posts.Add(p);
        }
        posts.Sort((a, b) => a.PostingDate.CompareTo(b.PostingDate));
        inner.DataSource     = posts;
        inner.ItemDataBound += new RepeaterItemEventHandler(inner_ItemDataBound);
        inner.DataBind();
        TextBox txt = (TextBox)e.Item.FindControl("Name");
        Button  btn = (Button)e.Item.FindControl("ButtonSend");

        btn.CommandArgument = currentAppointment.Id.ToString();
        btn.OnClientClick   = string.Format("onSendPost('{0}');", txt.ClientID);
        HtmlImage img = (HtmlImage)e.Item.FindControl("Meteo");
        int       idx = currentAppointment.AppointmentDate.DayOfYear - DateTime.Now.DayOfYear;

        if (idx < 0 || idx > 6)
        {
            img.Visible = false;
        }
        else
        {
            img.Src = string.Format("http://www.ilmeteo.it/cartine2/{0}.LIG.png", idx);
        }
    }