Esempio n. 1
0
    protected void btn_add_User_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(User_name.Value.ToString()) && !String.IsNullOrEmpty(User_contact.Value.ToString()))
        {
            bus_dbEntities db = new bus_dbEntities();
            //Create new instance and assign values to columns
            tbl_user user = new tbl_user();

            user.user_name    = User_name.Value.ToString();
            user.user_contact = User_contact.Value.ToString();
            user.user_email   = User_email.Value.ToString();
            user.user_address = User_address.Value.ToString();
            user.fk_type      = Int32.Parse(user_type.SelectedValue.ToString());
            //Add instance in db
            db.tbl_user.Add(user);
            db.SaveChanges();

            List <tbl_user> lgs      = (from x in db.tbl_user select x).ToList();
            var             userType = (from x in db.tbl_usertype select x).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
            user_type.DataSource     = userType;
            user_type.DataTextField  = "type_name";
            user_type.DataValueField = "type_id";
            user_type.DataBind();
        }
        else
        {
            //Show alert
            ScriptManager.RegisterStartupScript(this, GetType(), "errorAlert", "alert('Please Enter usermane or password');", true);
        }
    }
Esempio n. 2
0
    public static string[] getPlan(String name, String deptarture, String arrival, String time, String date)
    {
        bus_dbEntities db          = new bus_dbEntities();
        int            bus         = int.Parse(name);
        int            dept        = int.Parse(deptarture);
        int            arr         = int.Parse(arrival);
        string         datetime    = date + " " + time;
        DateTime       interval    = DateTime.Parse(datetime);
        int            schedule_id = (from x in db.tbl_schedule
                                      join y in db.tbl_route on x.fk_route equals y.route_id
                                      join a in db.tbl_bus on x.fk_bus equals a.bus_id
                                      where y.route_source == dept && y.route_destination == arr && a.bus_id == bus
                                      select x).ToList()[0].schedule_id;
        List <pr_get_seats_Result> seatList = db.pr_get_seats(schedule_id, interval).ToList();
        int i = 0;

        String[] toreturn = new String[seatList.Count()];
        foreach (pr_get_seats_Result seat in seatList)
        {
            String s = seat.seat_name + ";" + seat.seat_status;
            toreturn[i] = s;
            i++;
        }

        return(toreturn);
    }
Esempio n. 3
0
    protected void submit_Click(object sender, EventArgs e)
    {
        bus_dbEntities db       = new bus_dbEntities();
        String         seatData = seatList.Value;

        foreach (String s in seatData.Split(';'))
        {
            if (!String.IsNullOrEmpty(s))
            {
                tbl_booking d     = new tbl_booking();
                int         bus   = int.Parse(b_bus.SelectedValue.ToString());
                int         dst   = int.Parse(b_arrv.SelectedValue.ToString());
                int         src   = int.Parse(b_dept.SelectedValue.ToString());
                int         route = (from x in db.tbl_route where x.route_source == src && x.route_destination == dst select x).ToList()[0].route_id;
                d.booking_datetime = DateTime.Parse(b_date.Value.ToString() + " " + b_time.SelectedItem.Text.ToString());
                int seat = int.Parse(s);
                d.booking_seatno = seat;
                string cnic = c_cnic.Value.ToString();
                d.fk_user     = (from x in db.tbl_user where x.user_cnic == cnic select x).ToList()[0].user_id;
                d.fk_schedule = (from x in db.tbl_schedule
                                 join y in db.tbl_bus on x.fk_bus equals y.bus_id
                                 join z in db.tbl_route on x.fk_route equals z.route_id
                                 join a in db.tbl_station on z.route_source equals a.station_id
                                 join b in db.tbl_station on z.route_destination equals b.station_id
                                 where a.station_id == src && b.station_id == dst && y.bus_id == bus
                                 select x.schedule_id).ToList()[0];
                db.tbl_booking.Add(d);
                db.SaveChanges();
                ScriptManager.RegisterStartupScript(this, GetType(), "ok", "alert('Seats Reserved Successfully. You can print the receipt from booking history.');", true);
                seatList.Value = "";
                b_date.Value   = "";
            }
        }
    }
Esempio n. 4
0
    protected void btn_add_Station_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(Bus_name.Value.ToString()) && !String.IsNullOrEmpty(Bus_capacity.Value.ToString()))
        {
            bus_dbEntities db = new bus_dbEntities();
            //Create new instance and assign values to columns
            tbl_bus bus = new tbl_bus();
            bus.bus_name     = Bus_name.Value.ToString();
            bus.bus_capacity = int.Parse(Bus_capacity.Value.ToString());
            bus.bus_driver   = Bus_driver.Value.ToString();
            bus.bus_contact  = Bus_contact.Value.ToString();
            //Add instance in db
            db.tbl_bus.Add(bus);
            db.SaveChanges();

            List <tbl_bus> lgs = (from x in db.tbl_bus select x).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
        }
        else
        {
            //Show alert
            ScriptManager.RegisterStartupScript(this, GetType(), "errorAlert", "alert('Please Enter bus name and capcaity');", true);
        }
    }
Esempio n. 5
0
    protected void b_arrv_SelectedIndexChanged(object sender, EventArgs e)
    {
        bus_dbEntities db          = new bus_dbEntities();
        int            source      = int.Parse(b_dept.SelectedValue.ToString());
        int            destination = int.Parse(b_arrv.SelectedValue.ToString());

        var buses = (from x in db.tbl_schedule
                     join y in db.tbl_bus on x.fk_bus equals y.bus_id
                     join z in db.tbl_route on x.fk_route equals z.route_id
                     where z.route_source == source && z.route_destination == destination
                     select y).ToList();

        b_bus.DataSource     = buses;
        b_bus.DataTextField  = "bus_name";
        b_bus.DataValueField = "bus_id";
        b_bus.DataBind();

        int bus     = int.Parse(b_bus.SelectedValue.ToString());
        var timming = (from x in db.tbl_schedule
                       join y in db.tbl_bus on x.fk_bus equals y.bus_id
                       join z in db.tbl_route on x.fk_route equals z.route_id
                       join a in db.tbl_station on z.route_source equals a.station_id
                       join b in db.tbl_station on z.route_destination equals b.station_id
                       where a.station_id == source && b.station_id == destination && y.bus_id == bus
                       select x.schedule_time).ToList();

        b_time.DataSource = timming;
        b_time.DataBind();
    }
Esempio n. 6
0
 protected void grid1_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("canceled"))
     {
         int            index   = int.Parse(e.CommandArgument.ToString());
         GridViewRow    gr      = (GridViewRow)((Button)e.CommandSource).NamingContainer;
         int            user_id = int.Parse(((HiddenField)gr.FindControl("booking_id")).Value.ToString());
         bus_dbEntities db      = new bus_dbEntities();
         tbl_booking    login   = (from x in db.tbl_booking where x.booking_id == user_id select x).ToList()[0];
         db.tbl_booking.Remove(login);
         //Save to database
         db.SaveChanges();
         var lgs = (from x in db.tbl_booking
                    join y in db.tbl_schedule on x.fk_schedule equals y.schedule_id
                    join b in db.tbl_bus on y.fk_bus equals b.bus_id
                    join r in db.tbl_route on y.fk_route equals r.route_id
                    join s in db.tbl_station on r.route_source equals s.station_id
                    join d in db.tbl_station on r.route_destination equals d.station_id
                    where x.booking_id == user_id
                    select new { x.booking_id, x.booking_datetime, x.booking_seatno, b.bus_name, source = s.station_name, destination = d.station_name }).ToList();
         grid1.DataSource = lgs;
         grid1.DataBind();
     }
     else if (e.CommandName.Equals("print"))
     {
         int         index   = int.Parse(e.CommandArgument.ToString());
         GridViewRow gr      = (GridViewRow)((Button)e.CommandSource).NamingContainer;
         int         user_id = int.Parse(((HiddenField)gr.FindControl("booking_id")).Value.ToString());
         HttpCookie  cook    = new HttpCookie("printData");
         cook.Value = user_id.ToString();
         Response.Cookies.Add(cook);
         Response.Redirect("PrintSlip.aspx");
     }
 }
Esempio n. 7
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         bus_dbEntities  db  = new bus_dbEntities();
         List <tbl_time> lgs = (from x in db.tbl_time select x).ToList();
         grid1.DataSource = lgs;
         grid1.DataBind();
     }
 }
Esempio n. 8
0
    protected void grid1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName.Equals("canceled"))
        {
            int            index   = int.Parse(e.CommandArgument.ToString());
            GridViewRow    gr      = (GridViewRow)((Button)e.CommandSource).NamingContainer;
            int            user_id = int.Parse(((HiddenField)gr.FindControl("user_id")).Value.ToString());
            bus_dbEntities db      = new bus_dbEntities();
            tbl_login      login   = (from x in db.tbl_login where x.fk_user == user_id select x).ToList()[0];
            db.tbl_login.Remove(login);
            //Save to database
            db.SaveChanges();
            var original = db.tbl_user.Find(user_id);

            if (original != null)
            {
                db.Entry(original).State = EntityState.Modified;
                original.user_status     = "not verified";
                db.SaveChanges();
            }

            var lgs = (from x in db.tbl_user select x).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
        }
        else if (e.CommandName.Equals("verify"))
        {
            int            index    = int.Parse(e.CommandArgument.ToString());
            GridViewRow    gr       = (GridViewRow)((Button)e.CommandSource).NamingContainer;
            int            user_id  = int.Parse(((HiddenField)gr.FindControl("user_id")).Value.ToString());
            String         username = gr.Cells[8].Text.ToString();
            String         password = gr.Cells[9].Text.ToString();
            bus_dbEntities db       = new bus_dbEntities();
            tbl_login      login    = new tbl_login();
            login.login_password = password;
            login.login_user     = username;
            login.fk_user        = user_id;
            db.tbl_login.Add(login);
            db.SaveChanges();

            var original = db.tbl_user.Find(user_id);

            if (original != null)
            {
                db.Entry(original).State = EntityState.Modified;
                original.user_status     = "verified";
                db.SaveChanges();
            }

            var lgs = (from x in db.tbl_user select x).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
        }
    }
Esempio n. 9
0
    protected void bus_dept_SelectedIndexChanged(object sender, EventArgs e)
    {
        bus_dbEntities db     = new bus_dbEntities();
        int            source = int.Parse(bus_dept.SelectedValue.ToString());
        var            dest   = (from x in db.tbl_route join y in db.tbl_station on x.route_destination equals y.station_id where x.route_source == source select y).ToList();

        bus_arvl.DataSource     = dest;
        bus_arvl.DataTextField  = "station_name";
        bus_arvl.DataValueField = "station_id";
        bus_arvl.DataBind();
    }
Esempio n. 10
0
 protected void btn_login_Click(object sender, EventArgs e)
 {
     userBlock.Visible     = false;
     passwordBlock.Visible = false;
     if (!String.IsNullOrEmpty(username.Value.ToString()))
     {
         if (!String.IsNullOrEmpty(password.Value.ToString()))
         {
             bus_dbEntities   db   = new bus_dbEntities();
             String           user = username.Value.ToString();
             String           pass = password.Value.ToString();
             List <tbl_login> dt   = (from x in db.tbl_login where x.login_user == user && x.login_password == pass select x).ToList();
             if (dt.Count > 0)
             {
                 HttpCookie login = new HttpCookie("login_data");
                 login.Values.Add("id", dt[0].login_id.ToString());
                 login.Values.Add("user", dt[0].login_user.ToString());
                 login.Values.Add("userId", dt[0].fk_user.ToString());
                 int             user_id = (int)dt[0].fk_user;
                 List <tbl_user> dtu     = (from x in db.tbl_user where x.user_id == user_id select x).ToList();
                 login.Values.Add("name", dtu[0].user_name.ToString());
                 login.Values.Add("role", dtu[0].fk_type.ToString());
                 login.Values.Add("pwd", password.Value.ToString());
                 login.Expires = DateTime.Now.AddDays(4);
                 Response.Cookies.Add(login);
                 if (dtu[0].fk_type.ToString().Equals("1"))
                 {
                     Response.Redirect("Default.aspx");
                 }
                 else
                 {
                     Response.Redirect("OnlineBooking.aspx");
                 }
             }
             else
             {
                 loginErrorMsg.Visible = true;
             }
         }
         else
         {
             Page.SetFocus(password);
             passwordBlock.Visible = true;
         }
     }
     else
     {
         Page.SetFocus(username);
         userBlock.Visible = true;
     }
 }
Esempio n. 11
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         bus_dbEntities  db       = new bus_dbEntities();
         List <tbl_user> lgs      = (from x in db.tbl_user select x).ToList();
         var             userType = (from x in db.tbl_usertype select x).ToList();
         grid1.DataSource = lgs;
         grid1.DataBind();
         user_type.DataSource     = userType;
         user_type.DataTextField  = "type_name";
         user_type.DataValueField = "type_id";
         user_type.DataBind();
     }
 }
Esempio n. 12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["printData"] != null)
        {
            if (!IsPostBack)
            {
                String id          = Request.Cookies["printData"].Value;
                int    schedule_id = int.Parse(id);
                bookin_id.InnerText = id;
                String         name        = "Nil";
                String         cnic        = "Nil";
                String         source      = "Nil";
                String         destination = "Nil";
                String         datetime    = "Nil";
                String         bus         = "Nil";
                bus_dbEntities db          = new bus_dbEntities();

                int      userid = (int)(from x in db.tbl_booking where x.booking_id == schedule_id select x.fk_user).ToList()[0];
                DateTime dtime  = (DateTime)(from x in db.tbl_booking where x.booking_id == schedule_id select x.booking_datetime).ToList()[0];
                bus = (from x in db.tbl_booking
                       join y in db.tbl_schedule on x.fk_schedule equals y.schedule_id
                       join b in db.tbl_bus on y.fk_bus equals b.bus_id
                       where x.booking_id == schedule_id select b.bus_name).ToList()[0].ToString();
                source = (from x in db.tbl_booking
                          join y in db.tbl_schedule on x.fk_schedule equals y.schedule_id
                          join b in db.tbl_route on y.fk_route equals b.route_id
                          join a in db.tbl_station on b.route_source equals a.station_id
                          where x.booking_id == schedule_id
                          select a.station_name).ToList()[0].ToString();
                destination = (from x in db.tbl_booking
                               join y in db.tbl_schedule on x.fk_schedule equals y.schedule_id
                               join b in db.tbl_route on y.fk_route equals b.route_id
                               join a in db.tbl_station on b.route_destination equals a.station_id
                               where x.booking_id == schedule_id
                               select a.station_name).ToList()[0].ToString();
                List <tbl_user> userList = (from x in db.tbl_user where x.user_id == userid select x).ToList();
                name = userList[0].user_name;
                cnic = userList[0].user_cnic;

                bookin_name.InnerText = name;
                bookin_cnic.InnerText = cnic;
                bookin_date.InnerText = dtime.ToString("yyyy-MM-dd HH:mm:ss");
                bookin_bus.InnerText  = bus;
                bookin_from.InnerText = source;
                bookin_to.InnerText   = destination;
            }
        }
    }
Esempio n. 13
0
    protected void Unnamed_Click(object sender, EventArgs e)
    {
        bus_dbEntities db     = new bus_dbEntities();
        int            source = int.Parse(bus_dept.SelectedValue.ToString());
        int            dest   = int.Parse(bus_arvl.SelectedValue.ToString());
        var            lgs    = (from x in db.tbl_schedule
                                 join y in db.tbl_bus on x.fk_bus equals y.bus_id
                                 join z in db.tbl_route on x.fk_route equals z.route_id
                                 join a in db.tbl_station on z.route_source equals a.station_id
                                 join b in db.tbl_station on z.route_destination equals b.station_id
                                 where a.station_id == source && b.station_id == dest
                                 select new { ID = x.schedule_id, Source = a.station_name, Destination = b.station_name, Bus = y.bus_name, Seats = y.bus_capacity, Time = x.schedule_time }).ToList();

        gridview1.DataSource = lgs;
        gridview1.DataBind();
    }
Esempio n. 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         bus_dbEntities db       = new bus_dbEntities();
         var            lgs      = (from x in db.tbl_route join y in db.tbl_station on x.route_source equals y.station_id join z in db.tbl_station on x.route_destination equals z.station_id select new { ID = x.route_id, Source = y.station_name, Destination = z.station_name }).ToList();
         var            stations = (from x in db.tbl_station select x).ToList();
         grid1.DataSource = lgs;
         grid1.DataBind();
         Route_Source.DataSource     = stations;
         Route_Source.DataTextField  = "station_name";
         Route_Source.DataValueField = "station_id";
         Route_Source.DataBind();
         Route_Destination.DataSource     = stations;
         Route_Destination.DataTextField  = "station_name";
         Route_Destination.DataValueField = "station_id";
         Route_Destination.DataBind();
     }
 }
Esempio n. 15
0
    protected void btn_add_Route_Click(object sender, EventArgs e)
    {
        bus_dbEntities db = new bus_dbEntities();
        //Create new instance and assign values to columns
        tbl_route route = new tbl_route
        {
            route_source      = int.Parse(Route_Source.SelectedValue),
            route_destination = int.Parse(Route_Destination.SelectedValue)
        };

        //Add instance in db
        db.tbl_route.Add(route);
        db.SaveChanges();

        var lgs = (from x in db.tbl_route join y in db.tbl_station on x.route_source equals y.station_id join z in db.tbl_station on x.route_destination equals z.station_id select new { ID = x.route_id, Source = y.station_name, Destination = z.station_name }).ToList();

        grid1.DataSource = lgs;
        grid1.DataBind();
    }
Esempio n. 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            String user_id = Request.Cookies["login_data"]["userId"].ToString();
            int    uid     = int.Parse(user_id);

            bus_dbEntities db  = new bus_dbEntities();
            var            lgs = (from x in db.tbl_booking
                                  join y in db.tbl_schedule on x.fk_schedule equals y.schedule_id
                                  join b in db.tbl_bus on y.fk_bus equals b.bus_id
                                  join r in db.tbl_route on y.fk_route equals r.route_id
                                  join s in db.tbl_station on r.route_source equals s.station_id
                                  join d in db.tbl_station on r.route_destination equals d.station_id
                                  where x.fk_user == uid
                                  select new { x.booking_id, x.booking_datetime, x.booking_seatno, b.bus_name, source = s.station_name, destination = d.station_name }).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
        }
    }
Esempio n. 17
0
    protected void btn_add_Schedule_Click(object sender, EventArgs e)
    {
        bus_dbEntities db = new bus_dbEntities();
        //Create new instance and assign values to columns
        tbl_schedule route  = new tbl_schedule();
        int          source = int.Parse(Schedule_Source.SelectedValue.ToString());
        int          dest   = int.Parse(Schedule_Destination.SelectedValue.ToString());

        route.fk_route      = (from x in db.tbl_route where x.route_source == source && x.route_destination == dest select x).ToList()[0].route_id;
        route.schedule_time = TimeSpan.Parse(Schedule_timming.SelectedItem.Text.ToString());
        route.fk_bus        = int.Parse(Schedule_bus.SelectedValue.ToString());
        //Add instance in db
        db.tbl_schedule.Add(route);
        db.SaveChanges();

        var lgs = (from x in db.tbl_route join y in db.tbl_station on x.route_source equals y.station_id join z in db.tbl_station on x.route_destination equals z.station_id select new { ID = x.route_id, Source = y.station_name, Destination = z.station_name }).ToList();

        grid1.DataSource = lgs;
        grid1.DataBind();
    }
Esempio n. 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bus_dbEntities db = new bus_dbEntities();
            //   var stations = (from x in db.tbl_station select x).ToList();

            //  bus_dept.DataSource = stations;
            bus_dept.DataTextField  = "station_name";
            bus_dept.DataValueField = "station_id";
            bus_dept.DataBind();
            bus_dept.SelectedIndex = 0;

            // int source = int.Parse(bus_dept.SelectedValue.ToString());
            //   var dest = (from x in db.tbl_route join y in db.tbl_station on x.route_destination equals y.station_id where x.route_source == source select y).ToList();
            //   bus_arvl.DataSource = dest;
            bus_arvl.DataTextField  = "station_name";
            bus_arvl.DataValueField = "station_id";
            bus_arvl.DataBind();
        }
    }
Esempio n. 19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bus_dbEntities db  = new bus_dbEntities();
            var            lgs = (from x in db.tbl_schedule
                                  join y in db.tbl_route on x.fk_route equals y.route_id
                                  join a in db.tbl_station on y.route_source equals a.station_id
                                  join b in db.tbl_station on y.route_destination equals b.station_id
                                  select new { ID = x.schedule_id, Source = a.station_name, Destination = b.station_name, Timning = x.schedule_time }).ToList();
            var stations = (from x in db.tbl_station select x).ToList();
            var bus      = (from x in db.tbl_bus select x).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
            Schedule_bus.DataSource     = bus;
            Schedule_bus.DataTextField  = "bus_name";
            Schedule_bus.DataValueField = "bus_id";
            Schedule_bus.DataBind();


            Schedule_Source.DataSource     = stations;
            Schedule_Source.DataTextField  = "station_name";
            Schedule_Source.DataValueField = "station_id";
            Schedule_Source.DataBind();
            Schedule_Source.SelectedIndex = 0;

            int source = int.Parse(Schedule_Source.SelectedValue.ToString());
            var dest   = (from x in db.tbl_route join y in db.tbl_station on x.route_destination equals y.station_id where x.route_source == source select y).ToList();
            Schedule_Destination.DataSource     = dest;
            Schedule_Destination.DataTextField  = "station_name";
            Schedule_Destination.DataValueField = "station_id";
            Schedule_Destination.DataBind();
            int destination = int.Parse(Schedule_Destination.SelectedValue.ToString());
            var timming     = (from x in db.tbl_time select x).ToList();
            Schedule_timming.DataSource     = timming;
            Schedule_timming.DataTextField  = "time_value";
            Schedule_timming.DataValueField = "time_id";
            Schedule_timming.DataBind();
        }
    }
Esempio n. 20
0
    protected void btn_add_Station_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(time_name.Value.ToString()))
        {
            bus_dbEntities db = new bus_dbEntities();
            //Create new instance and assign values to columns
            tbl_time time = new tbl_time();
            time.time_value = TimeSpan.Parse(time_name.Value.ToString());
            //Add instance in db
            db.tbl_time.Add(time);
            db.SaveChanges();

            List <tbl_time> lgs = (from x in db.tbl_time select x).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
        }
        else
        {
            //Show alert
            ScriptManager.RegisterStartupScript(this, GetType(), "errorAlert", "alert('Please Select a proper Timming');", true);
        }
    }
Esempio n. 21
0
    protected void btn_add_Station_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(Station_name.Value.ToString()))
        {
            bus_dbEntities db = new bus_dbEntities();
            //Create new instance and assign values to columns
            tbl_station station = new tbl_station {
                station_name = Station_name.Value.ToString()
            };

            //Add instance in db
            db.tbl_station.Add(station);
            db.SaveChanges();

            List <tbl_station> lgs = (from x in db.tbl_station select x).ToList();
            grid1.DataSource = lgs;
            grid1.DataBind();
        }
        else
        {
            //Show alert
            ScriptManager.RegisterStartupScript(this, GetType(), "errorAlert", "alert('Please Enter station name');", true);
        }
    }
Esempio n. 22
0
    protected void btn_signup_Click(object sender, EventArgs e)
    {
        nameErr.Visible         = false;
        contactErr.Visible      = false;
        cnicErr.Visible         = false;
        usernameErr.Visible     = false;
        passwordErr.Visible     = false;
        signupErrorMsg.Visible  = false;
        signupErrorMsg2.Visible = false;
        signupErrorMsg3.Visible = false;
        String name = s_name.Value.ToString();

        if (String.IsNullOrEmpty(name))
        {
            nameErr.Visible = true;
        }
        String contact = s_contact.Value.ToString();

        if (String.IsNullOrEmpty(contact))
        {
            contactErr.Visible = true;
        }
        String cnic = s_cnic.Value.ToString();

        if (String.IsNullOrEmpty(cnic))
        {
            cnicErr.Visible = true;
        }
        String email   = s_email.Value.ToString();
        String address = s_address.Value.ToString();
        String user    = s_user.Value.ToString();

        if (String.IsNullOrEmpty(user))
        {
            usernameErr.Visible = true;
        }
        String pass = s_password.Value.ToString();

        if (String.IsNullOrEmpty(pass))
        {
            passwordErr.Visible = true;
        }
        if (!String.IsNullOrEmpty(name) && !String.IsNullOrEmpty(contact) && !String.IsNullOrEmpty(cnic) && !String.IsNullOrEmpty(user) && !String.IsNullOrEmpty(pass))
        {
            bus_dbEntities  db      = new bus_dbEntities();
            List <tbl_user> usrList = (from x in db.tbl_user where x.user_cnic == cnic select x).ToList();
            if (usrList.Count > 0)
            {
                signupErrorMsg3.Visible = true;
            }
            else
            {
                usrList = (from x in db.tbl_user where x.user_duser == user select x).ToList();

                if (usrList.Count > 0)
                {
                    signupErrorMsg2.Visible = true;
                }
                else
                {
                    tbl_user usr = new tbl_user();
                    usr.user_name      = name;
                    usr.user_contact   = contact;
                    usr.user_cnic      = cnic;
                    usr.user_email     = email;
                    usr.user_status    = "not verified";
                    usr.user_address   = address;
                    usr.user_duser     = user;
                    usr.user_dpassword = pass;
                    db.tbl_user.Add(usr);
                    db.SaveChanges();
                    ScriptManager.RegisterStartupScript(this, GetType(), "ok", "alert('Data Sent for Verification From Admin');", true);
                    s_name.Value     = "";
                    s_contact.Value  = "";
                    s_cnic.Value     = "";
                    s_email.Value    = "";
                    s_address.Value  = "";
                    s_user.Value     = "";
                    s_password.Value = "";
                }
            }
        }
        else
        {
            signupErrorMsg.Visible = true;
        }
    }
Esempio n. 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.Cookies["login_data"] != null)
        {
            if (!IsPostBack)
            {
                bus_dbEntities db = new bus_dbEntities();

                String user_id  = Request.Cookies["login_data"]["userId"].ToString();
                int    uid      = int.Parse(user_id);
                var    userData = (from x in db.tbl_user where x.user_id == uid select x).ToList()[0];
                c_cnic.Value    = userData.user_cnic;
                c_name.Value    = userData.user_name;
                c_contact.Value = userData.user_contact;


                var stations = (from x in db.tbl_station select x).ToList();

                b_dept.DataSource     = stations;
                b_dept.DataTextField  = "station_name";
                b_dept.DataValueField = "station_id";
                b_dept.DataBind();
                b_dept.SelectedIndex = 0;

                int source = int.Parse(b_dept.SelectedValue.ToString());
                var dest   = (from x in db.tbl_route join y in db.tbl_station on x.route_destination equals y.station_id where x.route_source == source select y).ToList();
                b_arrv.DataSource     = dest;
                b_arrv.DataTextField  = "station_name";
                b_arrv.DataValueField = "station_id";
                b_arrv.DataBind();
                int destination = int.Parse(b_arrv.SelectedValue.ToString());

                var buses = (from x in db.tbl_schedule
                             join y in db.tbl_bus on x.fk_bus equals y.bus_id
                             join z in db.tbl_route on x.fk_route equals z.route_id
                             where z.route_source == source && z.route_destination == destination
                             select y).Distinct().ToList();
                b_bus.DataSource     = buses;
                b_bus.DataTextField  = "bus_name";
                b_bus.DataValueField = "bus_id";
                b_bus.DataBind();

                int bus     = int.Parse(b_bus.SelectedValue.ToString());
                var timming = (from x in db.tbl_schedule
                               join y in db.tbl_bus on x.fk_bus equals y.bus_id
                               join z in db.tbl_route on x.fk_route equals z.route_id
                               join a in db.tbl_station on z.route_source equals a.station_id
                               join b in db.tbl_station on z.route_destination equals b.station_id
                               where a.station_id == source && b.station_id == destination && y.bus_id == bus
                               select x.schedule_time).ToList();
                b_time.DataSource = timming;
                b_time.DataBind();

                if (Request.Cookies["bookingData"] != null)
                {
                    int id       = int.Parse(Request.Cookies["bookingData"]["scheduleid"].ToString());
                    var d_source = (from x in db.tbl_schedule
                                    join y in db.tbl_bus on x.fk_bus equals y.bus_id
                                    join z in db.tbl_route on x.fk_route equals z.route_id
                                    join a in db.tbl_station on z.route_source equals a.station_id
                                    join b in db.tbl_station on z.route_destination equals b.station_id
                                    where x.schedule_id == id
                                    select a.station_id).ToList()[0];
                    source = int.Parse(d_source.ToString());
                    b_dept.ClearSelection();
                    b_dept.Items.FindByValue(d_source.ToString()).Selected = true;
                    dest = (from x in db.tbl_route join y in db.tbl_station on x.route_destination equals y.station_id where x.route_source == source select y).ToList();
                    b_arrv.DataSource     = dest;
                    b_arrv.DataTextField  = "station_name";
                    b_arrv.DataValueField = "station_id";
                    b_arrv.DataBind();

                    var d_dest = (from x in db.tbl_schedule
                                  join y in db.tbl_bus on x.fk_bus equals y.bus_id
                                  join z in db.tbl_route on x.fk_route equals z.route_id
                                  join a in db.tbl_station on z.route_source equals a.station_id
                                  join b in db.tbl_station on z.route_destination equals b.station_id
                                  where x.schedule_id == id
                                  select b.station_id).ToList()[0];
                    b_arrv.ClearSelection();
                    b_arrv.Items.FindByValue(d_dest.ToString()).Selected = true;
                    destination = int.Parse(d_dest.ToString());

                    buses = (from x in db.tbl_schedule
                             join y in db.tbl_bus on x.fk_bus equals y.bus_id
                             join z in db.tbl_route on x.fk_route equals z.route_id
                             where z.route_source == source && z.route_destination == destination
                             select y).ToList();
                    b_bus.DataSource     = buses;
                    b_bus.DataTextField  = "bus_name";
                    b_bus.DataValueField = "bus_id";
                    b_bus.DataBind();

                    var d_bus = (from x in db.tbl_schedule
                                 join y in db.tbl_bus on x.fk_bus equals y.bus_id
                                 join z in db.tbl_route on x.fk_route equals z.route_id
                                 join a in db.tbl_station on z.route_source equals a.station_id
                                 join b in db.tbl_station on z.route_destination equals b.station_id
                                 where x.schedule_id == id
                                 select y.bus_id).ToList()[0];
                    b_bus.ClearSelection();
                    b_bus.Items.FindByValue(d_bus.ToString()).Selected = true;
                    bus     = int.Parse(b_bus.SelectedValue.ToString());
                    timming = (from x in db.tbl_schedule
                               join y in db.tbl_bus on x.fk_bus equals y.bus_id
                               join z in db.tbl_route on x.fk_route equals z.route_id
                               join a in db.tbl_station on z.route_source equals a.station_id
                               join b in db.tbl_station on z.route_destination equals b.station_id
                               where a.station_id == source && b.station_id == destination && y.bus_id == bus
                               select x.schedule_time).ToList();
                    b_time.DataSource = timming;
                    b_time.DataBind();
                    var d_time = (from x in db.tbl_schedule
                                  join y in db.tbl_bus on x.fk_bus equals y.bus_id
                                  join z in db.tbl_route on x.fk_route equals z.route_id
                                  join a in db.tbl_station on z.route_source equals a.station_id
                                  join b in db.tbl_station on z.route_destination equals b.station_id
                                  where x.schedule_id == id
                                  select x.schedule_time).ToList()[0];
                    b_time.ClearSelection();
                    b_time.Items.FindByText(d_time.ToString()).Selected = true;
                }
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }