Exemple #1
0
    protected void Button5_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text.Length < 2 || TextBox2.Text.Length < 2 || TextBox5.Text.Length < 2 || TextBox6.Text.Length < 1 || TextBox3.Text.Length < 1 || TextBox8.Text.Length < 2 || TextBox9.Text.Length < 2 || TextBox10.Text.Length < 2 || TextBox3.Text.Length < 1 || TextBox3.Text.Length < 1)
        {
            Label5.Visible = true;
            return;
        }

        /*if (int.Parse(TextBox3.Text) < 0 || int.Parse(TextBox3.Text) < 0 || int.Parse(TextBox3.Text) > 23 || int.Parse(TextBox3.Text) > 59)
         * {
         *  Label2.Visible = true;
         *  return;
         * }
         * if (int.Parse(TextBox6.Text) < 0 || int.Parse(TextBox6.Text) < 0 || int.Parse(TextBox6.Text) > 23 || int.Parse(TextBox3.Text) > 59)
         * {
         *  Label3.Visible = true;
         *  return;
         * }*/

        string   fn = TextBox1.Text.ToString();
        TimeSpan dt = TimeSpan.Parse(TextBox3.Text);
        DateTime dd = Convert.ToDateTime(TextBox2.Text);

        //TimeSpan at = new TimeSpan(int.Parse(TextBox6.Text), int.Parse(TextBox7.Text), 0);
        //DateTime ad = new DateTime(Calendar3.SelectedDate.Year, Calendar3.SelectedDate.Month, Calendar3.SelectedDate.Day, at.Hours, at.Minutes, at.Seconds);
        TimeSpan at    = TimeSpan.Parse(TextBox6.Text);
        DateTime ad    = Convert.ToDateTime(TextBox5.Text);
        float    price = float.Parse(TextBox8.Text);
        string   dl    = TextBox9.Text;
        string   al    = TextBox10.Text;
        string   pc    = DropDownList1.SelectedValue.ToString();
        float    chpr  = float.Parse(TextBox11.Text);

        Process.flight fl = new Process.flight();
        fl.depT     = dd;
        fl.arrT     = ad;
        fl.depl     = dl;
        fl.arrl     = al;
        fl.flightno = fn;
        fl.regp     = price;
        fl.chp      = chpr;
        List <int> det = pid(pc);

        fl.planeid = det[0];
        fl.avseat  = det[1];


        try
        {
            Process db = new Process();
            db.addFlight(fl);
            Response.Redirect("flight_list.aspx");
        }
        catch (Exception ex)
        {
            Label5.Visible = true;
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        foreach (Process.flight temp in fl)
        {
            if (temp.depl.Equals(DropDownList1.SelectedItem.ToString().TrimEnd()) && temp.arrl.Equals(DropDownList2.SelectedItem.ToString().TrimEnd()) && temp.depT == DateTime.Parse(ListBox1.SelectedItem.ToString()))
            {
                selected = temp;
                check    = true;
            }
        }
        string seats = Text1.Value;

        string[] t = seats.Split(',');
        if (t.Length != number)
        {
            Label18.Text    = "Please choose the seats";
            Label18.Visible = true;
            return;
        }
        Process pr = new Process();

        Process.reservation res = new Process.reservation();
        res.fid   = selected.flightId;
        res.chno  = Int32.Parse(DropDownList4.SelectedItem.ToString());
        res.regno = Int32.Parse(DropDownList3.SelectedItem.ToString());
        res.total = res.regno * selected.regp + res.chno * selected.chp;;
        res.us    = Session["user"].ToString().TrimEnd();
        string status = "";
        string cardno = "";

        if (RadioButton1.Checked)
        {
            status = "BOOKED";
            if (TextBox1.Text.Length > 2)
            {
                cardno = TextBox1.Text;
            }
            else
            {
                cardno = Label17.Text;
            }
        }
        else
        {
            status = "RESERVED";
        }
        res.st     = status;
        res.cardno = cardno;
        pr.newResrvation(res);
        pr.dedav(ad + ch, res.fid);
        int idres = pr.getLastResId();

        pr.addOccSeat(seats, res.fid, idres);

        Response.Redirect("ReservationHistory.aspx");
    }
 protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     foreach (Process.flight temp in fl)
     {
         if (temp.depl.Equals(DropDownList1.SelectedItem.ToString().TrimEnd()) && temp.arrl.Equals(DropDownList2.SelectedItem.ToString().TrimEnd()) && temp.depT == DateTime.Parse(ListBox1.SelectedItem.ToString()))
         {
             selected = temp;
             check    = true;
         }
     }
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        Process pr = new Process();

        if (Session["User"] == null)
        {
            RadioButton1.Visible = false;
            RadioButton2.Visible = false;

            HyperLink2.Visible = true;
            Button2.Visible    = false;
        }
        else
        {
            Label17.Text = pr.getcno(Session["User"].ToString().TrimEnd());
        }
        check           = false;
        Label18.Visible = false;

        selected = new Process.flight();
        fl       = pr.getflights();
        if (!IsPostBack)
        {
            confirm.Visible = false;
            SEL.Visible     = false;
            fillDep();
        }
        else
        {
            if (Session["S"] != null)
            {
                string test     = Session["S"].ToString();
                string function = "setSelected('" + Session["S"].ToString().Trim() + "');";
                ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", function, true);
            }
        }
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        Label18.Visible = false;
        foreach (Process.flight temp in fl)
        {
            if (temp.depl.Equals(DropDownList1.SelectedItem.ToString().TrimEnd()) && temp.arrl.Equals(DropDownList2.SelectedItem.ToString().TrimEnd()) && temp.depT == DateTime.Parse(ListBox1.SelectedItem.ToString()))
            {
                selected = temp;
                check    = true;
            }
        }
        if (check == true)
        {
            Label13.Text    = selected.arrT.ToString();
            Label14.Text    = selected.regp.ToString() + " RM";
            Label15.Text    = selected.chp.ToString() + " RM";
            ad              = Int32.Parse(DropDownList3.SelectedItem.ToString());
            ch              = Int32.Parse(DropDownList4.SelectedItem.ToString());
            total           = ad * selected.regp + ch * selected.chp;
            Label16.Text    = total.ToString() + " RM";
            confirm.Visible = true;
            SEL.Visible     = true;
        }
        else
        {
            Label18.Visible = true;
        }
        int flightId = selected.flightId;

        Process pr = new Process();
        // int flightId = Int32.Parse(Session["selected"].ToString().Trim());
        string seats    = pr.getOccSeats(flightId);
        string function = "set('" + seats + "');";

        ScriptManager.RegisterStartupScript(this, GetType(), "displayalertmessage", function, true);
        number = Int32.Parse(DropDownList4.SelectedItem.ToString()) + Int32.Parse(DropDownList3.SelectedItem.ToString());
    }