protected void lnkBtnSave_Click(object sender, EventArgs e)
    {
        int    routerID  = Convert.ToInt32(ddlRouter.SelectedItem.Value.ToString());
        string busPlate  = ddlBus.SelectedItem.Value.ToString();
        string departure = txtDeparture.Text.ToString() + " " + ddlStartTime.SelectedItem.Text.ToString();
        string arrival   = txtArrival.Text.ToString() + " " + ddlEndTime.SelectedItem.Text.ToString();
        float  price     = float.Parse(txtPrice.Text.ToString());

        ListBus newListBus = new ListBus();

        newListBus.ListBusID = listBus.ListBusID;
        newListBus.BusPlate  = busPlate;
        newListBus.RouterID  = routerID;
        newListBus.Departure = DateTime.Parse(departure);
        newListBus.Arrival   = DateTime.Parse(arrival);
        newListBus.Price     = price;
        if (cbStatus.Checked)
        {
            newListBus.Status = true;
        }
        else
        {
            newListBus.Status = true;
        }

        int k = BLLListBus.UpdateListBus(newListBus);

        Response.Redirect("ListBus.aspx");
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        int listBusId = Convert.ToInt32(Request.QueryString["ListBusID"].ToString());

        listBus = BLLListBus.getListBusByID(listBusId)[0];
        if (!Page.IsPostBack)
        {
            LoadData();
        }
    }
Beispiel #3
0
    public void LoadData()
    {
        string   from     = Request.QueryString["From"].ToString().Trim();
        string   to       = Request.QueryString["To"].ToString().Trim();
        Router   router   = BLLRouter.getIDrouter(from, to);
        DateTime fromDate = DateTime.Parse(Request.QueryString["FromDate"].ToString().Trim());
        DateTime toDate   = DateTime.Parse(Request.QueryString["toDate"].ToString().Trim());

        ViewState["router"]  = from + " - " + to;
        GridView1.DataSource = BLLListBus.getListBusCustomer(fromDate, toDate, router.RouterID, true);
        GridView1.DataBind();
    }
Beispiel #4
0
    protected override void OnPreRender(EventArgs e)
    {
        if (MultiView1.ActiveViewIndex == 1)
        {
            int      listBusID = int.Parse(_listbusID.Value.ToString());
            ListBus  listbus   = BLLListBus.getListBusByID(listBusID);
            Bus      bus       = BLLBus.getBusByID(listbus.BusPlate);
            Ticket[] ticket    = BLLTicket.getTicketByListBusID(listBusID);
            int      count     = 1;
            if (chkSeat.Items.Count == 0)
            {
                for (int i = 0; i < bus.Seat; i++)
                {
                    chkSeat.Items.Add(count.ToString());
                    for (int j = 0; j < ticket.Length; j++)
                    {
                        if (count == ticket[j].NumberSeat)
                        {
                            chkSeat.Items[i].Selected = true;
                            chkSeat.Items[i].Enabled  = false;
                        }
                    }
                    count++;
                }
            }
        }
        else if (MultiView1.ActiveViewIndex == 2)
        {
            lbRouterName1.Text = lbRouterName.Text;
            lbDeparture2.Text  = lbDeparture.Text;
            lbArrival2.Text    = lbArrival.Text;
            lbPrice2.Text      = lbPrice.Text;
            ArrayList arrSeat = new ArrayList();
            for (int i = 0; i < chkSeat.Items.Count; i++)
            {
                if (chkSeat.Items[i].Selected == true & chkSeat.Items[i].Enabled == false)
                {
                    int numberSeat = Int32.Parse(chkSeat.Items[i].Text);
                    arrSeat.Add(numberSeat);
                }
            }
            ViewState["CountSeat"] = arrSeat;
        }
        //else if (MultiView1.ActiveViewIndex == 3)
        //{
        //    litCustomerNameStep4.Text = txtcustomername.Text;
        //    litSeatStep4.Text = litSeat.Text;
        //    litPriceStep4.Text = litPrices.Text;
        //}

        base.OnPreRender(e);
    }
    protected void LoadData()
    {
        DataTable dt = BLLListBus.getAllListBus();

        dv         = new DataView(dt);
        dv.Sort    = "Status DESC, Departure DESC";
        total.Text = dv.Count.ToString();
        gvListBusList.DataSource = dv;
        gvListBusList.DataBind();
        if (gvListBusList.HeaderRow != null)
        {
            gvListBusList.HeaderRow.TableSection = TableRowSection.TableHeader;
        }
    }
    protected void lnkExpired_Click(object sender, EventArgs e)
    {
        DataTable dt = BLLListBus.getAllListBusByStatus(true);

        foreach (DataRow dr in dt.Rows)
        {
            DateTime date = DateTime.Parse(dr["Departure"].ToString());
            if (DateTime.Compare(date, DateTime.Now) < 0)
            {
                ListBus listBus = new ListBus();
                listBus.ListBusID = Int32.Parse(dr["ListBusID"].ToString());
                listBus.RouterID  = Int32.Parse(dr["RouterID"].ToString());
                listBus.BusPlate  = dr["BusPlate"].ToString();
                listBus.Departure = DateTime.Parse(dr["Departure"].ToString());
                listBus.Arrival   = DateTime.Parse(dr["Arrival"].ToString());
                listBus.Price     = Double.Parse(dr["Price"].ToString());
                listBus.Status    = false;
                int k = BLLListBus.UpdateListBus(listBus);
            }
        }
        LoadData();
    }
    protected void lnkDelete_Click(object sender, EventArgs e)
    {
        int test = 0;

        foreach (GridViewRow row in gvListBusList.Rows)
        {
            CheckBox cb = (CheckBox)row.FindControl("chkSel");
            if (cb.Checked)
            {
                ++test;
                int id = int.Parse(row.Cells[1].Text);
                int k  = BLLListBus.DeleteListBus(id);
            }
        }
        if (test == 0)
        {
            ClientScript.RegisterStartupScript(this.GetType(), "Notify", "alert('!!!Please select a ListBus from the list to delete');", true);
        }
        else
        {
            Response.Redirect("ListBusList.aspx");
        }
    }