Beispiel #1
0
        protected void DelTrip_Click(object sender, EventArgs e)
        {
            TripDAO    delTD   = new DAL.TripDAO();
            int        tripId  = Convert.ToInt32(Request.QueryString["tripId"]);
            int        results = delTD.delTrip(tripId);
            SmtpClient client  = new SmtpClient();

            client.Port                  = 25;
            client.Host                  = "smtp-mail.outlook.com";
            client.EnableSsl             = true;
            client.Timeout               = 10000;
            client.UseDefaultCredentials = false;
            client.Credentials           = new System.Net.NetworkCredential("*****@*****.**", "msJasmine1");
            Trip        tripObj = delTD.getTripById(tripId);
            MailMessage mail    = new MailMessage("*****@*****.**", "*****@*****.**");

            mail.Subject = "Trip cancelled";
            mail.Body    = "This is regarding the trip you sign up for: " + tripObj.tripTitle + "\nReason for cancel: " + tbReason.Text;
            client.Send(mail);

            const string accountSid = "AC90e3e868134c6a071114c494857cea63";
            const string authToken  = "25c2aa080ca442ffb5701fe61b6a7af7";

            TwilioClient.Init(accountSid, authToken);

            var message = MessageResource.Create(
                body: "This is regarding the trip " + tripObj.tripTitle + " you had signed up for. The trip has been cancelled due to : " + tbReason.Text,
                from: "(717) 429-0744",
                to: "+65 91783904"
                );

            Response.Redirect("TripDetails.aspx");
        }
Beispiel #2
0
        protected void addTrip(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                TripDAO addTD = new DAL.TripDAO();
                if (tripImageUpload.HasFile)
                {
                    string             addLocation   = ddlAddLocation.SelectedItem.Text;
                    string             addTitle      = tbAddTitle.Text;
                    DateTime           addStart      = Convert.ToDateTime(tbAddStart.Text);
                    DateTime           addEnd        = Convert.ToDateTime(tbAddEnd.Text);
                    DateTime           addOpen       = Convert.ToDateTime(tbOpenDay.Text);
                    string             addActivities = tbAddActivities.Text;
                    double             cost          = Convert.ToInt16(tbAddCost.Text);
                    string             addType       = DdlAddTripType.SelectedItem.Text;
                    HttpFileCollection uploadedFiles = Request.Files;
                    string[]           images        = new string[3];
                    int staffId = Convert.ToInt32(Session["StaffId"]);
                    for (int i = 0; i < uploadedFiles.Count; i++)
                    {
                        HttpPostedFile userPostedFile = uploadedFiles[i];
                        images[i] = SaveFile(userPostedFile);
                        System.Diagnostics.Debug.WriteLine(images[i]);
                    }
                    if (uploadedFiles.Count == 1)
                    {
                        images[1] = "NULL";
                        images[2] = "NULL";
                    }
                    else if (uploadedFiles.Count == 2)
                    {
                        images[2] = "NULL";
                    }
                    int results = addTD.insertTrip(addLocation, images[0], addTitle, addStart, addEnd, addOpen, addActivities, cost, addType, images[1], images[2], staffId);

                    Response.Redirect("TripDetails.aspx");
                }
                else
                {
                    //add validations? later la
                }
            }
        }