protected void tripDelete_Click(object sender, EventArgs e) { string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection myConn = new SqlConnection(DBConnect); LinkButton tripDelete = sender as LinkButton; GridViewRow row = tripDelete.NamingContainer as GridViewRow; //string ProgCode = Convert.ToString(GridViewTrip.DataKeys[row.RowIndex].Value.ToString()); string ProgCode = row.Cells[0].Text; int result; myConn.Open(); SqlCommand cmd = new SqlCommand("DELETE FROM Trip WHERE TripID ='" + ProgCode + "'", myConn); result = cmd.ExecuteNonQuery(); myConn.Close(); if (result == 1) { trip tripOjb = new trip(); tripDAO tripDAO = new tripDAO(); List <trip> tripList = new List <trip>(); tripList = tripDAO.getTripInfo(); GridViewImmTrip.DataSource = tripList; GridViewImmTrip.DataBind(); } //Response.Redirect("Tripmanagement.aspx"); }
//private void show_img() //{ // DirectoryInfo d = new DirectoryInfo(MapPath("~/tripImg/")); // FileInfo[] r = d.GetFiles(); // DataTable dt = new DataTable(); // dt.Columns.Add("path"); // DataRow row = dt.NewRow(); // /*int lastPos = r.Length - 1;*/ // row["path"] = "~/tripImg/" + r[0].Name; // dt.Rows.Add(row); // DataList1.DataSource = dt; // DataList1.DataBind(); //} protected void btnSubmit_Click(object sender, EventArgs e) { if (Page.IsValid) { string TripID = Convert.ToString(tbProgCode.Text.ToString()); DateTime StartDate = Convert.ToDateTime(tbProgYear.Text.ToString()); DateTime EndDate = Convert.ToDateTime(tbEndDate.Text.ToString()); TimeSpan Diff = EndDate - StartDate; int Duration = Convert.ToInt16(Diff.Days.ToString()); string Country = ddlCountry.SelectedValue.ToString(); string Description = Request.Form["taDesc"].ToString(); int MaxStudent = Convert.ToInt16(tbMaxStud.Text.ToString()); double ETripPrice = Convert.ToDouble(tbPrice.Text.ToString()); string TripType = ddlTripType.SelectedValue.ToString(); //int StaffID = Convert.ToInt16(tbLeadStaff.Text.ToString()); //int StaffID = Convert.ToInt16(ddlStaff.SelectedValue.ToString()); //string Image = "~/tripImg/" + Guid.NewGuid().ToString() + "" + Path.GetExtension(imgUpload.FileName); string str = imgUpload.FileName; imgUpload.PostedFile.SaveAs(Server.MapPath("~/tripImg/" + str)); string Image = Convert.ToString("tripImg/" + str.ToString()); if (ddlStaff.SelectedValue == "0") { lblStaff.Text = "Please select a staff"; lblStaff.ForeColor = System.Drawing.Color.Red; } else { int StaffID = Convert.ToInt16(ddlStaff.SelectedValue.ToString()); if (StartDate < DateTime.Now.Date) { lblValid.Text = "Invalid Start Date!"; tbProgYear.Focus(); } else if (EndDate < DateTime.Now.Date) { lblValid.Text = "Invalid End Date!"; tbEndDate.Focus(); } else { tripDAO newTrip = new tripDAO(); newTrip.InsertTrip(TripID, StartDate, EndDate, Duration, Country, Description, MaxStudent, ETripPrice, StaffID, Image, TripType); Response.Redirect("TripManagement.aspx"); } } } else { lblValid.Text = "ProgCode Already Exist!"; tbProgCode.Focus(); } }
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; } } }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { trip tripOjb = new trip(); tripDAO tripDAO = new tripDAO(); List <trip> tripList = new List <trip>(); tripList = tripDAO.getTripStudyType(); TripList.DataSource = tripList; TripList.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { tripDAO tripDAO = new tripDAO(); List <trip> immTrip = new List <trip>(); immTrip = tripDAO.getImmersionTripInfo(); GridViewImmTrip.DataSource = immTrip; GridViewImmTrip.DataBind(); List <trip> immTripHist = new List <trip>(); immTripHist = tripDAO.getImmersionTripHist(); GridViewImmHist.DataSource = immTripHist; GridViewImmHist.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { tripDAO tripDAO = new tripDAO(); List <trip> studyTrip = new List <trip>(); studyTrip = tripDAO.getStudyTrip(); GridViewTrip.DataSource = studyTrip; GridViewTrip.DataBind(); List <trip> studyTripHist = new List <trip>(); studyTripHist = tripDAO.getStudyTripHist(); GridViewHist.DataSource = studyTripHist; GridViewHist.DataBind(); }
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(); } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { if (Session["SSTripID"] != null) { string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection myConn = new SqlConnection(DBConnect); string TripID = Session["SSTripID"].ToString(); SqlCommand cmd = new SqlCommand("SELECT TripID FROM RegisteredStudent WHERE TripID ='" + TripID + "'", myConn); myConn.Open(); SqlDataReader reader = cmd.ExecuteReader(); try { if (reader.HasRows) { tripDAO tripDAO = new tripDAO(); List <StudentReg> studList = new List <StudentReg>(); studList = tripDAO.getStudList(TripID); GVStudList.DataSource = studList; GVStudList.DataBind(); } else { lblNoStud.Text = "No such record exist!"; } myConn.Close(); } catch (Exception ex) { lblNoStud.Text = "idk what to put here"; } } else { lblNoStud.Text = "No such record exist!!!"; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { trip tripOjb = new trip(); tripDAO tripDAO = new tripDAO(); //tripOjb = tripDAO.getTripById(1); //Lbl_country.Text = tripOjb.Country; //Lbl_description.Text = tripOjb.Description; List <trip> tripList = new List <trip>(); tripList = tripDAO.getTripInfo(); GridViewTrip.DataSource = tripList; GridViewTrip.DataBind(); List <trip> tripHist = new List <trip>(); tripHist = tripDAO.getTripHist(); GridViewHist.DataSource = tripHist; GridViewHist.DataBind(); } if (Session["Username"] == null) { } }