Esempio n. 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            int mid = 1, msgid = 1;
            //System.Windows.Forms.MessageBox.Show("Before alert " + Request.Params.Get("alert"));
            if (Request.Params.Get("alert") != null)
            {
                //System.Windows.Forms.MessageBox.Show("In alert ");
                Mails m;
                Messages mg;
                Clock c;
                bool MailEnabled = (Request.Params.Get("mail") != null);
                bool MessageEnabled = Request.Params.Get("message") != null;

                if (MailEnabled || MessageEnabled)
                {

                    c = InitializeClock();
                    c.Save();
                    if (MailEnabled)
                    {
                        Label1.Text += "  Mail  ";
                        m = new Mails(-1, TextBox1.Text, TextBox2.Text, TextBox3.Text, c.getId());
                        m.save();
                        mid = m.getId();
                    }
                    if (MessageEnabled)
                    {
                        Label1.Text += "   Message";
                        mg = new Messages(-1, TextBox4.Text, TextBox6.Text, c.getId());
                        mg.save();
                        msgid = mg.getId();
                    }
                }
            }
           // System.Windows.Forms.MessageBox.Show("Before saving");
            Label1.Text += "       Remainder";
            Reminder r = new Reminder(u.getUserName(), Calendar1.SelectedDate.ToString("dd/MMM/yyyy"), DropDownList10.SelectedItem.Text, TextBox7.Text, mid, msgid);
           // System.Windows.Forms.MessageBox.Show("After saving");
            Label1.Text = r.getQuery();
            if (r.save())
            {
                /*Response.Write("<script language='javascript'>"+
                                    "alert('Reminder added successfully..');"+
                                    "window.open('./RemindersList.aspx');"+
                                    "alert('new Page');"+
                               "</script>");*/
                Response.Redirect("RemindersList.aspx");
            }
            else
                Response.Write("<script language='javascript'>alert('An error occured in saving your reminder , try again after few seconds');</script>");
        }
        catch (Exception ee) { Response.Write(ee.Message); }
    }