Ejemplo n.º 1
0
        /// <summary>
        /// Send the message
        /// </summary>
        private void SendButton_Click(object sender, System.EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }

            //string from = user.Name;

            ArrayList toList = new ArrayList();

            foreach (ListItem item in ToListBox.Items)
            {
                toList.Add(item.Value);
            }

            //Message msg = new Message(from, toList, message);

            string time = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
            // insert into database
            DBDriver myDB = new DBDriver();

            myDB.Query =
                "insert into messages (SenderID, Subject, Body, timestamp)\n"
                + "values (@sender, @subject, @body, @time);";
            myDB.addParam("@sender", Request.Cookies["user"]["id"]);
            myDB.addParam("@subject", this.SubjectTextBox.Text);
            myDB.addParam("@body", this.MessageTextBox.InnerText);
            myDB.addParam("@time", time);
            myDB.nonQuery();

            myDB.Query = "select id from messages where timestamp=@time;";
            myDB.addParam("@time", time);
            int mID = Convert.ToInt32(myDB.scalar());

            //insert into the recipients table as well
            for (int i = 0; i < this.ToListBox.Items.Count; i++)
            {
                myDB.Query = "insert into recipients (MessageID, RecipientID, Timestamp) values (@id, @recipient, @time);";
                myDB.addParam("@id", mID);
                myDB.addParam("@recipient", this.ToListBox.Items[i].Value);
                myDB.addParam("@time", time);
                myDB.nonQuery();
            }

            Server.Transfer(Request.Url.AbsolutePath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Send the message
        /// </summary>
        private void SendButton_Click(object sender, System.EventArgs e)
        {
            if (!Page.IsValid)
                return;

            //string from = user.Name;

            ArrayList toList = new ArrayList();
            foreach (ListItem item in ToListBox.Items)
            {
                toList.Add(item.Value);
            }

            //Message msg = new Message(from, toList, message);

            string time=DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss");
            // insert into database
            DBDriver myDB=new DBDriver();
            myDB.Query=
                "insert into messages (SenderID, Subject, Body, timestamp)\n"
                + "values (@sender, @subject, @body, @time);";
            myDB.addParam("@sender", Request.Cookies["user"]["id"]);
            myDB.addParam("@subject", this.SubjectTextBox.Text);
            myDB.addParam("@body", this.MessageTextBox.InnerText);
            myDB.addParam("@time", time);
            myDB.nonQuery();

            myDB.Query="select id from messages where timestamp=@time;";
            myDB.addParam("@time", time);
            int mID=Convert.ToInt32(myDB.scalar());

            //insert into the recipients table as well
            for(int i=0;i<this.ToListBox.Items.Count;i++)
            {
                myDB.Query="insert into recipients (MessageID, RecipientID, Timestamp) values (@id, @recipient, @time);";
                myDB.addParam("@id", mID);
                myDB.addParam("@recipient", this.ToListBox.Items[i].Value);
                myDB.addParam("@time", time);
                myDB.nonQuery();
            }

            Server.Transfer(Request.Url.AbsolutePath);
        }