コード例 #1
0
        //protected void ImageButtonDate_Click(object sender, ImageClickEventArgs e)
        //{
        //    if (CalendarDate.Visible == false)
        //    {
        //        CalendarDate.Visible = true;
        //    }
        //    else
        //    {
        //        CalendarDate.Visible = false;
        //    }
        //}

        //protected void CalendarDate_SelectionChanged(object sender, EventArgs e)
        //{
        //    TextBoxDate.Text = CalendarDate.SelectedDate.ToShortDateString();
        //}

        protected void btnCreate_Click(object sender, EventArgs e)
        {
            if (NameTB.Text == "")
            {
                Labelerr.Text      = "Name is required";
                Labelerr.ForeColor = Color.Red;
            }
            if (DDLPlaces.SelectedIndex == -1)
            {
                Labelerr.Text      = "You need to choose a place";
                Labelerr.ForeColor = Color.Red;
            }
            //if(TextBoxDate.Text == "")
            //{
            //    Labelerr.Text = "You need to choose a date";

            //}
            else
            {
                int    placeid = int.Parse(DDLPlaces.SelectedItem.Value);
                string name    = NameTB.Text;
                int    userId  = Convert.ToInt32(Session["UserID"].ToString());
                /*string date = TextBoxDate.Text*/



                Itinerary it  = new Itinerary(placeid, name, userId);
                int       res = it.Addnew();
                if (res == 1)
                {
                    Labelerr.Text      = "Successfully created";
                    Labelerr.ForeColor = Color.Green;
                    Response.Redirect("ViewItinerary.aspx");
                }
                else
                {
                    Labelerr.Text      = "Error";
                    Labelerr.ForeColor = Color.Green;
                }
            }
        }