Exemple #1
0
        static void Main(string[] args)
        {
            Student s01 = new Student("002");
            Student s02 = new Student("001", "Rungrat", "Sriwirun");

            s01.setFirstname("Anocha");
            s01.setLastname("Prungtaeng");
            Console.WriteLine(s01.ToString());
            Console.WriteLine(s02.ToString());
            Console.WriteLine((new Student("018", "Rene", "Smith")).ToString());

            room r433 = new room("433", "433", 8, 8, "Computer");

            Console.WriteLine(r433.ToString());
            Console.WriteLine("_____________________________________________________________");
            Building s05 = new Building("04", "Faculty of Computer Science and Information Technology", "13.7442", "100.4608");

            Console.WriteLine(s05.ToString());
            Console.WriteLine("_____________________________________________________________");
            Subject s06 = new Subject("9022081", "Web Programming", 3, 2, 2);

            Console.WriteLine(s06.ToString());
            Console.WriteLine("_____________________________________________________________");
            Lecturer s03 = new Lecturer("Nitat", "Ninchawee", "Master of Sience (Electronic Transactions)");

            Console.WriteLine(s03.ToString());
            Console.WriteLine("_____________________________________________________________");
            Curriculum s04 = new Curriculum("Information Technology", "Bachelor");

            Console.WriteLine(s04.ToString());
            Console.WriteLine("_____________________________________________________________");
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     thisRm = Session["Room"] as room;
     System.Drawing.Image mainImage = thisRm.getMainPic;
     roomNMELBL.Text = thisRm.ToString();
     url             = "~/TempImages/" + Path.GetRandomFileName();
     url             = Path.ChangeExtension(url, ".jpg");
     mainImage.Save(Server.MapPath(url));
     rmPC.ImageUrl = url;
     descTXT.Text  = thisRm.description;
     priceLBL.Text = "$" + string.Format("{0:0.00}", thisRm.getAskedPrice.ToString());
     if (Session["User"] is customer)
     {
         LinkButton newBtn = new LinkButton();
         newBtn.Text   = "(" + thisRm.roomHotel.getName + ")";
         newBtn.Click += (a, t) =>
         {
             Session["Hotel"] = thisRm.roomHotel;
             Response.Redirect("~//HotPGE.aspx");
         };
         hotelLBL.Text = string.Empty;
         hotelLBL.Controls.Add(newBtn);
         theUser = Session["User"] as customer;
         setupCustomer();
     }
     else if (Session["User"] is hotel)
     {
         hotelLBL.Text = "(" + thisRm.roomHotel.getName + ")";
         theUser       = Session["User"] as hotel;
         setupHotel((theUser as hotel).returnId == thisRm.roomHotel.returnId);
     }
     else
     {
         subtractOffers();
     }
 }
    protected void addRoom(room rooms, hotel hot, string loc = null)
    {
        TableRow  newRow = new TableRow();
        TableCell cell1  = new TableCell();
        Image     newIMG = new Image();

        newIMG.BorderStyle = BorderStyle.Solid;
        newIMG.Height      = 150;
        newIMG.Width       = 150;
        //Set img url
        System.Drawing.Image mainImage = rooms.getMainPic;
        string url;

        if (mainImage != null)
        {
            url = "~/TempImages/" + Path.GetRandomFileName();
            url = Path.ChangeExtension(url, ".jpg");
            mainImage.Save(Server.MapPath(url));
            newIMG.ImageUrl = url;
        }
        cell1.HorizontalAlign = HorizontalAlign.Justify;
        cell1.Controls.Add(newIMG);
        newRow.Cells.Add(cell1);  //Adding image control to row
        TableCell cell2 = new TableCell();

        if (Session["User"] is siteUser)
        {
            LinkButton button = new LinkButton();
            button.Text   = rooms.ToString();
            button.Click += (s, e) =>
            {
                Session["Room"] = rooms;
                Response.Redirect("~//rmPGE.aspx");
            };
            cell2.HorizontalAlign = HorizontalAlign.Left;
            cell2.Controls.Add(button);
        }
        else
        {
            cell2.Text = rooms.ToString();
        }
        newRow.Cells.Add(cell2);
        TableCell cell3 = new TableCell();

        cell3.HorizontalAlign = HorizontalAlign.Left;
        if (!(Session["User"] is customer))
        {
            cell3.Text = hot.getName; //No link unless the user is a customer
        }
        else                          //The user is a customer
        {
            LinkButton newBTN = new LinkButton();
            newBTN.Text   = hot.getName;
            newBTN.Click += (a, t) =>
            {
                Session["Hotel"] = hot;
                Response.Redirect("~//HotPGE.aspx");
            };
            cell3.Controls.Add(newBTN);
        }
        newRow.Cells.Add(cell3);
        TableCell cell4 = new TableCell();

        cell4.HorizontalAlign = HorizontalAlign.Left;
        cell4.Text            = string.Format("${0:00}", rooms.getAskedPrice);
        newRow.Cells.Add(cell4);
        newRow.BorderWidth = width;
        newRow.BorderStyle = border;
        roomTBL.Rows.Add(newRow);
        if (!Page.IsPostBack)
        {
            List <string> myList = (List <string>)Session["Cities"];
            if (!(myList.Contains(hot.cityState)))
            {
                ListItem i = new ListItem(hot.cityState, hot.cityState); //Same for both text and value
                if (loc == hot.cityState)
                {
                    locationDRP.SelectedItem.Selected = false;
                    i.Selected = true;
                }
                locationDRP.Items.Add(i);
                myList.Add(hot.cityState);
                Session["Cities"] = myList;
            }
        }
    }