示例#1
0
    protected void btn_submit_Click(object sender, EventArgs e)
    {
        tbl_schedule sch = new tbl_schedule();

        sch.sch_day  = ddl_day.SelectedValue;
        sch.sch_date = Calendar_date.SelectedDate.ToString();


        if (ddl_day.SelectedValue == "SUNDAY")
        {
            sch.sch_time = ddl_sun.SelectedValue;
        }

        if (ddl_day.SelectedValue == "MONDAY")
        {
            sch.sch_time = ddl_mon.SelectedValue;
        }

        if (ddl_day.SelectedValue == "TUESDAY")
        {
            sch.sch_time = ddl_tue.SelectedValue;
        }
        if (ddl_day.SelectedValue == "WEDNESDAY")
        {
            sch.sch_time = ddl_wed.SelectedValue;
        }
        if (ddl_day.SelectedValue == "THURSDAY")
        {
            sch.sch_time = ddl_thu.SelectedValue;
        }

        if (ddl_day.SelectedValue == "FRIDAY")
        {
            sch.sch_time = ddl_fri.SelectedValue;
        }

        if (ddl_day.SelectedValue == "SATURDAY")
        {
            sch.sch_time = ddl_sat.SelectedValue;
        }

        sch.sch_class      = ddl_class.SelectedValue;
        sch.sch_class_name = ddl_class_name.SelectedValue;
        sch.sch_subject    = txt_sub.Text;
        sch.sch_prof       = txt_prof.Text;

        db.tbl_schedules.InsertOnSubmit(sch);
        db.SubmitChanges();

        Response.Write("<script> alert('Your Schedule added Successfully ')</script>");

        GridView1.Visible = true;
    }
示例#2
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();
    }
 partial void Deletetbl_schedule(tbl_schedule instance);
 partial void Updatetbl_schedule(tbl_schedule instance);
 partial void Inserttbl_schedule(tbl_schedule instance);