示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                if (Session["SSTripID"] != null)
                {
                    string  tripID  = Session["SSTripID"].ToString();
                    trip    tripOjb = new trip();
                    tripDAO tripDAO = new tripDAO();
                    //tripOjb = tripDAO.getTripById(1);

                    tripOjb = tripDAO.getTrip(tripID);
                    imgTripDetails.ImageUrl = tripOjb.Image;
                    lblCn.Text   = tripOjb.Country;
                    lblDesc.Text = tripOjb.Description;
                    lblSD.Text   = tripOjb.StartDate.ToShortDateString();
                    lblED.Text   = tripOjb.EndDate.ToShortDateString();
                    lblPrc.Text  = tripOjb.ETripPrice.ToString();
                }
                else
                {
                    Response.Redirect("TripStudentView.aspx");
                }
                string    DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                StudList  studList  = new StudList();
                DataSet   ds        = new DataSet();
                DataTable tripData  = new DataTable();

                StudListDAO StudDao = new StudListDAO();
                studList = StudDao.getRegbyStudAdmin(Session["Username"].ToString());

                StringBuilder sqlStr = new StringBuilder();
                sqlStr.AppendLine("SELECT * FROM RegisteredStudent");
                sqlStr.AppendLine("INNER JOIN Trip");
                sqlStr.AppendLine("ON RegisteredStudent.TripID = Trip.TripID");
                sqlStr.AppendLine("where RegisteredStudent.TripID = @paraTripID AND RegisteredStudent.StudentAdmin = @paraStudentAdmin");

                SqlConnection  myConn = new SqlConnection(DBConnect);
                SqlDataAdapter da     = new SqlDataAdapter(sqlStr.ToString(), myConn);


                da.SelectCommand.Parameters.AddWithValue("@paraTripID", Request.QueryString["id"].ToString());
                da.SelectCommand.Parameters.AddWithValue("@paraStudentAdmin", studList.studentAdmin);
                da.Fill(ds, "studList");

                int rec_cnt = ds.Tables["studList"].Rows.Count;
                if (rec_cnt > 0)
                {
                    btnRegister.CssClass = "btn btn-primary disabled float-right";
                    btnRegister.Enabled  = false;
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                if (Session["SSProgCode"] != null)
                {
                    trip    tripList = new trip();
                    tripDAO newTrip  = new tripDAO();
                    lblProgCode.Text   = Session["SSProgCode"].ToString();
                    tripList           = newTrip.getTrip(Session["SSProgCode"].ToString());
                    tbStartDateUD.Text = tripList.StartDate.ToString();
                    tbEndDateUD.Text   = tripList.EndDate.ToString();
                    //tbCountryUD.Text = Session["SSCountry"].ToString();
                    ddlCountryUD.SelectedValue = tripList.Country.ToString();
                    //tbIDUD.Text = Session["SSLeadStaffID"].ToString();
                    //Request.Form["taDescUP"] = Session["SSDescription"].ToString();
                    tbMaxStudUD.Text = tripList.MaxStudent.ToString();
                    tbPriceUD.Text   = tripList.ETripPrice.ToString();
                    //tbCountryUD.Text = Session["SSStaffIC"].ToString();
                }
                else
                {
                    Response.Redirect("TripManagement.aspx");
                }

                string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
                SqlConnection myConn    = new SqlConnection(DBConnect);
                DataTable     dtStaffUD = new DataTable();

                StringBuilder sqlStr = new StringBuilder();
                sqlStr.AppendLine("SELECT StaffName, StaffID FROM Staff");

                SqlDataAdapter da = new SqlDataAdapter(sqlStr.ToString(), myConn);
                da.Fill(dtStaffUD);

                ddlStaffUD.Items.Clear();
                ddlStaffUD.Items.Insert(0, new ListItem("--Select--", "0"));
                ddlStaffUD.AppendDataBoundItems = true;

                ddlStaffUD.DataTextField  = "StaffName";
                ddlStaffUD.DataValueField = "StaffID";
                ddlStaffUD.DataSource     = dtStaffUD;
                ddlStaffUD.DataBind();
            }
        }