protected void btnRemoveSelected_Click(object sender, EventArgs e)
    {
        string strOfficeHoursSelected = "";

        TableRow[] trRows = new TableRow[tblHoursSelected.Rows.Count];
        tblHoursSelected.Rows.CopyTo(trRows, 0);

        foreach (TableRow tr in trRows)
        {
            if (tr is DisplayRow)
            {
                DisplayRow dr = (DisplayRow)tr;
                if (dr.isSelected())
                {
                    strOfficeHoursSelected += ",'" + dr.getId() + "'";
                }
            }
        }

        if (strOfficeHoursSelected.Length > 0)
        {
            SqlConnection dbConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["AWS_SQL"].ConnectionString);
            dbConnection.Open();

            string advCheck = "update officehours " +
                              "set studentId = NULL, " +
                              "note = NULL " +
                              "where officehoursid in (" + strOfficeHoursSelected.Substring(1) + ")";
            SqlCommand updateHours = new SqlCommand(advCheck, dbConnection);
            updateHours.ExecuteNonQuery();

            dbConnection.Close();
            Response.Redirect("appointment.aspx");
        }
    }
예제 #2
0
    protected void btnSelectAll_Click(object sender, EventArgs e)
    {
        bool blnChanged = false;

        foreach (TableRow tr in tblHours.Rows)
        {
            if (tr is DisplayRow)
            {
                DisplayRow dr = (DisplayRow)tr;
                if (!dr.isSelected())
                {
                    dr.select(true);
                    blnChanged = true;
                }
            }
        }
        if (!blnChanged)
        {
            foreach (TableRow tr in tblHours.Rows)
            {
                if (tr is DisplayRow)
                {
                    DisplayRow dr = (DisplayRow)tr;
                    dr.select(false);
                }
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string strOfficeHoursSelected = "";

        TableRow[] trRows = new TableRow[tblHours.Rows.Count];
        tblHours.Rows.CopyTo(trRows, 0);
        int       counter = 0;
        string    office  = "";
        ArrayList lstDT   = new ArrayList();

        foreach (TableRow tr in trRows)
        {
            litAlert.Text += 1;
            litAlert.Text += "Rows: " + tblHours.Rows.Count;
            if (tr is DisplayRow)
            {
                litAlert.Text += 2;
                DisplayRow dr = (DisplayRow)tr;
                if (dr.isSelected())
                {
                    counter += 1;
                    lstDT.Add(dr.getDate());
                    office = dr.office;
                    strOfficeHoursSelected += ",'" + dr.getId().ToString() + "'";
                }
            }
        }

        if (strOfficeHoursSelected.Length > 0 && blocks_reserved + counter < 3)
        {
            SqlConnection dbConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["AWS_SQL"].ConnectionString);
            dbConnection.Open();

            string advCheck = "update officehours " +
                              "set studentId = '" + (int)Session["id"] + "', " +
                              "note = '" + txtNote.Text + "' " +
                              "where officehoursid in (" + strOfficeHoursSelected.Substring(1) + ")";
            SqlCommand updateHours = new SqlCommand(advCheck, dbConnection);
            updateHours.ExecuteNonQuery();

            dbConnection.Close();
            litAlert.Text = advCheck;
            email((string)Session["email"], "You have reserved an advising apointment!", office, lstDT.ToArray());
            Response.Redirect("appointment.aspx");
        }
        else
        {
            litAlert.Text = "Please select up to two time slots for advising. You have " + (2 - blocks_reserved).ToString() + " left. ";
            if (blocks_reserved > 0)
            {
                litAlert.Text += "If you want to reserve a different time slot from what you've already selected, please remove those times from the first table. ";
            }
        }
    }
예제 #4
0
    protected void btnDeleteSelected_Click(object sender, EventArgs e)
    {
        SqlConnection dbConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["AWS_SQL"].ConnectionString);

        dbConnection.Open();

        foreach (TableRow tr in tblHours.Rows)
        {
            if (tr is DisplayRow)
            {
                DisplayRow dr = (DisplayRow)tr;
                if (dr.isSelected())
                {
                    string     delete      = "DELETE officeHours WHERE officeHoursId = '" + dr.getId() + "'";
                    SqlCommand deleteHours = new SqlCommand(delete, dbConnection);
                    deleteHours.ExecuteNonQuery();
                }
            }
        }

        dbConnection.Close();
        Response.Redirect("hours.aspx");
    }