Ejemplo n.º 1
0
        public void SaveTempo(object sender, EventArgs e)
        {
            try
            {
                using (MetromizerDataEntities context = new MetromizerDataEntities())
                {

                    tempos tempo = new tempos();
                    TextBox namebox = (TextBox)LoginView1.FindControl("SettingName");
                    string name = namebox.Text;
                    int bmp = int.Parse(TextBox1.Text);
                    int minutes = int.Parse(minutesfield.Text);

                    tempo.name = name;
                    tempo.bpm = bmp;
                    tempo.timeout = minutes;
                    tempo.user = User.Identity.Name;

                    context.tempos.Add(tempo);
                    context.SaveChanges();
                }
            }
            catch
            {
                Session.Add("message", "Opps, sorry ! Operation didn't succed...");
                Response.Redirect("~/result.aspx");
            }
            finally
            {
                Session.Add("message", "Operation was succed !");
                Response.Redirect("~/result.aspx");
            }
        }
Ejemplo n.º 2
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int ID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0]);

             using (MetromizerDataEntities context = new MetromizerDataEntities())
             {
                 tempos tempo = context.tempos.Find(ID);
                 context.tempos.Remove(tempo);

                 context.SaveChanges();
                 Response.Redirect("~/Organizer.aspx");

             }
        }
Ejemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated == false)
            {
                Response.Redirect("~/Login.aspx");
                return;
            }

            if (!IsPostBack)
            {
                using (MetromizerDataEntities context = new MetromizerDataEntities())
                {
                    var  result = from t in context.tempos where t.user == User.Identity.Name select t;

                    if (result.Count() == 0)
                    {
                        Label lb = new Label();
                        lb.Text = "You don't have any saved tempos at your collecion! You can do this by using ";
                        HyperLink hl = new HyperLink();
                        hl.Text = "Simple Metronome";
                        hl.NavigateUrl = "~/simple-metronome.aspx";
                        content.Controls.Add(lb);
                        content.Controls.Add(hl);
                        Wizard1.Visible = false;
                        return;
                    }

                    dt = new DataTable();

                    dt.Columns.Add("ajdi", typeof(int));
                    dt.Columns.Add("Name", typeof(string));
                    dt.Columns.Add("Beats Per Minute", typeof(int));
                    dt.Columns.Add("Minutes", typeof(string));

                    foreach (var item in result)
                        dt.Rows.Add(item.ID, item.name, item.bpm, item.timeout);

                    GridView1.DataSource = dt;
                    GridView1.DataBind();
                    ViewState["template"] = dt.Clone();
                }
            }
        }