Ejemplo n.º 1
0
    protected void btnNext_Click(object sender, EventArgs e)
    {
        StudentInformation.Visible = false;
        ContactInformation.Visible = true;
        DBoperations DB = new DBoperations();

        string First    = FirstName_Form.Text;
        string Last     = LastName_Form.Text;
        string Email    = Email_Form.Text;
        string UserName = UserName_Form.Text;
        string Major    = Major_Form.SelectedValue;
        int    Maj      = Convert.ToInt32(Major);
        string Phone    = Phone_Form.Text;
        string UID      = SUID_Form.Text;

        Boolean Student = DB.SecureVerifyStudent(UserName);

        if (Student == false)
        {
            DB.CreateStudent(First, Last, Email, UserName, Maj, 1, UID, Phone);
        }
        DB = null;
        //Advisors
        string        cs  = WebConfigurationManager.ConnectionStrings["localConnection"].ConnectionString;
        SqlConnection con = new SqlConnection(cs);

        try
        {
            ListItem newItem = new ListItem();
            newItem.Text  = "Select Advisor";
            newItem.Value = "0";
            Advisor_Form.Items.Add(newItem);

            string     selectSQL = "Select AID ,AdvFName, AdvLName From KBS_ADVISORS";
            SqlCommand comd      = new SqlCommand(selectSQL, con);
            con.Open();
            SqlDataReader reads = comd.ExecuteReader();

            while (reads.Read())
            {
                ListItem NewItem = new ListItem();
                string   first   = reads["AdvFName"].ToString();
                string   last    = reads["AdvLName"].ToString();
                string   full    = first + " " + last;
                NewItem.Text  = full;
                NewItem.Value = reads["AID"].ToString();
                Advisor_Form.Items.Add(NewItem);
            }
            reads.Close();
            con.Close();
        }
        catch (Exception err)
        {
            err.ToString();
        }
        finally
        {
            con.Close();
        }


        try
        {
            string     selectSQL = "Select RID, ReaDesc FROM VW_KBS_REASONS";
            SqlCommand com       = new SqlCommand(selectSQL, con);
            con.Open();
            SqlDataReader reader = com.ExecuteReader();

            while (reader.Read())
            {
                ListItem NewItem = new ListItem();
                NewItem.Text  = reader["ReaDesc"].ToString();
                NewItem.Value = reader["RID"].ToString();
                Reason_Form.Items.Add(NewItem);
            }
            reader.Close();
            con.Close();
        }
        catch (Exception err)
        {
            err.ToString();
        }
        finally
        {
            con.Close();
        }
    }