コード例 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GridView1.Visible = false;
                Label1.Visible    = false;
                Label4.Visible    = false;
                Label5.Visible    = false;
                Label6.Visible    = false;
                Label7.Visible    = false;
                Label8.Visible    = false;
                Calendar1.Visible = false;

                using (FerryEntities DbModel = new FerryEntities())
                {
                    List <Sex> sex = new List <Sex>();
                    sex = DbModel.Sexes.ToList();
                    var filteredsexes = from s in sex
                                        select new { s.GenderName, s.GenderCode };
                    this.Sex.DataSource = filteredsexes;
                    Sex.DataTextField   = "GenderName";
                    Sex.DataValueField  = "GenderCode";
                    Sex.DataBind();
                }
            }
        }
コード例 #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         using (FerryEntities DbModel = new FerryEntities())
         {
             List <Country> country = new List <Country>();
             country = DbModel.Countries.ToList();
             var filteredcountry = from c in country
                                   select new { c.CountryName, c.ThreeCharCountryCode };
             Nationality.DataSource     = filteredcountry;
             Nationality.DataTextField  = "CountryName";
             Nationality.DataValueField = "ThreeCharCountryCode";
             Nationality.DataBind();
             List <Sex> sex = new List <Sex>();
             sex = DbModel.Sexes.ToList();
             var filteredsexes = from s in sex
                                 select new { s.GenderName, s.GenderCode };
             Sex.DataSource     = filteredsexes;
             Sex.DataTextField  = "GenderName";
             Sex.DataValueField = "GenderCode";
             Sex.DataBind();
             List <Destination> destination = new List <Destination>();
             destination = DbModel.Destinations.ToList();
             var filtereddes = from d in destination
                               select new { d.CountryName, d.TwoCharCountryCode };
             Destination.DataSource     = filtereddes;
             Destination.DataTextField  = "CountryName";
             Destination.DataValueField = "TwoCharCountryCode";
             Destination.DataBind();
         }
     }
 }
コード例 #3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     using (var DbModel = new FerryEntities())
     {
         List <Customer> Pass = new List <Customer>();
         Pass = DbModel.Customers.ToList();
         var FilteredPassengerList = (from p in Pass
                                      where p.Sex == Sex.SelectedItem.Value
                                      where p.EntryDate == Convert.ToDateTime(TextBox1.Text)
                                      select p).ToArray();
         Label1.Text          = FilteredPassengerList.Count().ToString();
         GridView1.DataSource = FilteredPassengerList;
         GridView1.DataBind();
         GridView1.Visible = true;
         Label1.Visible    = true;
         Label4.Visible    = true;
         Label5.Visible    = true;
         Label6.Visible    = true;
         Label7.Visible    = true;
         Label8.Visible    = true;
         Label6.Text       = Convert.ToString(DateTime.Now);
     }
 }
コード例 #4
0
        protected void Button4_Click(object sender, EventArgs e)
        {
            FerryEntities Db = new FerryEntities();

            var passeneger = new Customer();

            passeneger.FirstName      = Fname.Text;
            passeneger.MiddleName     = Mname.Text;
            passeneger.LastName       = Lname.Text;
            passeneger.Sex            = Sex.SelectedItem.Value;
            passeneger.DOB            = Convert.ToDateTime(DOB.Text);
            passeneger.Nationality    = Nationality.SelectedItem.Value;
            passeneger.PassportNumber = Passport.Text;
            passeneger.DateOfIssue    = Convert.ToDateTime(DateofIssue.Text);
            passeneger.DateOfExpire   = Convert.ToDateTime(DateofExpire.Text);
            passeneger.Destination    = Destination.SelectedItem.Value;
            passeneger.EntryDate      = Convert.ToDateTime(DateofEntry.Text);
            passeneger.Period         = Period.SelectedItem.Text;
            passeneger.VoyageNumber   = Voyage.Text;
            Db.Customers.Add(passeneger);
            Db.SaveChanges();
            Response.Redirect("Passenger.aspx");
        }
コード例 #5
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            FerryEntities Db     = new FerryEntities();
            var           person = new Person();

            person.Fname = TextBox1.Text;
            person.Lname = TextBox2.Text;
            person.Sex   = Sex.SelectedItem.Value;
            person.DOB   = Convert.ToDateTime(TextBox3.Text);
            Db.People.Add(person);
            Db.SaveChanges();
            int Result = Db.SaveChanges();

            if (Result > 0)
            {
                Response.Write("</script>alert('Data inserted successfully')</script>");
            }
            else
            {
                Response.Write("</script>alert('Data not inserted successfully')</script>");
            }
            Response.Redirect("WebForm1.aspx");
        }
コード例 #6
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (var Db = new FerryEntities())
            {
                var filteredusers = from u in Db.Users
                                    where u.Username == Username.Text.Trim() && u.Password == Password.Text.Trim()
                                    select u;

                if (filteredusers.Count() > 0)
                {
                    Label3.Visible   = true;
                    Label3.Text      = "sucessful";
                    Label3.ForeColor = System.Drawing.Color.Blue;
                    Response.Redirect("Passenger.aspx");
                }
                else
                {
                    Label3.Visible   = true;
                    Label3.Text      = "Invalid username or password";
                    Label3.ForeColor = System.Drawing.Color.Red;
                    //Response.Redirect("Passenger.aspx");
                }
            }
        }