Ejemplo n.º 1
0
        private void Students_Loaded(object sender, RoutedEventArgs e)
        {
            DataSet1            ds  = new DataSet1();
            StudentTableAdapter sta = new StudentTableAdapter();

            sta.Fill(ds.Student); //Заполняем datagrid
            Students1.ItemsSource = ds.Student;
        }
Ejemplo n.º 2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            numberOfGroups = Int32.Parse(textBox1.Text);
            textBox1.Text  = "";
            var adapter = new StudentTableAdapter();
            var rows    = adapter.GetData();

            List <Students> students = new List <Students>();

            foreach (var row in rows)
            {
                Students student = new Students();
                student.firstname = row.First_Name;
                student.lastname  = row.Last_Name;
                students.Add(student);
            }

            List <List <Students> > groups = new List <List <Students> >();

            for (int g = 0; g < numberOfGroups; g++)
            {
                groups.Add(new List <Students>());
            }

            Random random;

            while (students.Count > 0)
            {
                for (int n = 0; n < numberOfGroups; n++)
                {
                    random = new Random();
                    int rand = random.Next(0, students.Count);
                    //Console.WriteLine(students[n].firstname);
                    groups[n].Add(students[rand]);
                    students.RemoveAt(rand);
                }
            }

            int i = 1;

            foreach (var group in groups)
            {
                listBox1.Items.Add("Group #" + i);
                foreach (var person in group)
                {
                    listBox1.Items.Add(person.firstname + " " + person.lastname);
                }
                listBox1.Items.Add("\n");
                i++;
            }
        }
Ejemplo n.º 3
0
    protected void btnTrack_Click(object sender, EventArgs e)
    {
        try
        {
            lblStatus.Visible = true;
            StudentTableAdapter sta = new StudentTableAdapter();
            string status           = sta.getAppStatus(int.Parse(txtTrack.Text));

            if (status == null)
            {
                lblStatus.Text = "The tracking number " + txtTrack.Text + " is not registered with us. Please try to register first!!!";
            }
            else
            {
                lblStatus.Text = "Your current status of application is: " + status;
            }
        }
        catch
        {
            lblStatus.Text = "Could not retrieve the application status at this time. Please try again later!!!";
        }
    }
    protected void btnSubmitReco_Click(object sender, EventArgs e)
    {
        try
        {
            string[] words = txtRecommendation.Text.Split(',', ' ', '.');

            if (words.Length > 750)
            {
                lblRecoText.Text = "*You can enter only 750 words";
            }

            else
            {
                if (status == false)
                {
                    status = true;
                }

                rta.UpdateStatus(status, recoPath, int.Parse(recoID), int.Parse(appID));

                using (StreamWriter writer = new StreamWriter(recoPath, true)) //// true to append data to the file
                {
                    writer.WriteLine(txtRecommendation.Text);
                }

                StudentTableAdapter sta = new StudentTableAdapter();
                stFirstName = sta.GetFirstName(int.Parse(appID));
                stLastName  = sta.GetLastName(int.Parse(appID));
                string url = string.Format("recoSuccess.aspx?name={0}", Server.UrlEncode(stFirstName + " " + stLastName));
                Response.Redirect(url, false);
            }
        }
        catch (Exception ex)
        {
            Response.Redirect("Exception.aspx");
        }
    }
Ejemplo n.º 5
0
 public void UpdateStudent(SchoolDataSet.StudentRow student)
 {
     var studentTableAdapter = new StudentTableAdapter();
     studentTableAdapter.UpdateStudent(
         student.PersonID,
         student.LastName,
         student.FirstName,
         student.EnrollmentDate
     );
 }
Ejemplo n.º 6
0
 public SchoolDataSet.StudentRow GetStudent(int id)
 {
     var studentTableAdapter = new StudentTableAdapter();
     return studentTableAdapter.GetStudentById(id).First();
 }
Ejemplo n.º 7
0
 public System.Collections.IEnumerable GetAllStudents()
 {
     var studentTableAdapter = new StudentTableAdapter();
     return studentTableAdapter.GetAllStudents();
 }
Ejemplo n.º 8
0
        private void subButton_Click(object sender, EventArgs e)
        {
            if (checkBox.GetItemChecked(0))
            {
                MessageBox.Show("Generating groups based on the number of students!");
                checkBox.SetSelected(0, false);
            }

            else if (checkBox.GetItemChecked(1))
            {
                MessageBox.Show("Generating groups based on the number of groups!");
                checkBox.SetSelected(1, false);
                int numberOfGroups = Int32.Parse(numLbl.Text);
                numLbl.Text = "";
                var adapter = new StudentTableAdapter();
                var rows    = adapter.GetData();

                List <Students> students = new List <Students>();

                foreach (var row in rows)
                {
                    int             n       = 0;
                    List <Students> student = new List <Students>();
                    student.Add(new Students()
                    {
                        firstname = row.First_Name, lastname = row.Last_Name
                    });
                    //student[n].firstname = row.First_Name;
                    //student[n].lastname = row.Last_Name;
                    students.Add(student[n]);
                    n++;
                }

                List <List <Students> > groups = new List <List <Students> >();

                for (int g = 0; g < numberOfGroups; g++)
                {
                    groups.Add(new List <Students>());
                }

                Random random;
                while (students.Count > 0)
                {
                    for (int n = 0; n < numberOfGroups; n++)
                    {
                        random = new Random();
                        int rand = random.Next(0, students.Count);
                        //Console.WriteLine(students[n].firstname);
                        groups.ElementAt(n).Add(students[rand]);
                        students.RemoveAt(rand);
                    }
                }

                int i = 1;
                foreach (var group in groups)
                {
                    listBox1.Items.Add("Group #" + i);
                    foreach (var person in group)
                    {
                        listBox1.Items.Add(person.firstname + " " + person.lastname);
                    }
                    listBox1.Items.Add("\n");
                    i++;
                }
            }
        }
    protected void ApplicationWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        try
        {
            StudentTableAdapter sta = new StudentTableAdapter();
            newAppID = Convert.ToInt32(sta.NextAppID()) + 1;
            string ext = Path.GetExtension(Resume.PostedFile.FileName).ToLower();
            resumePath = Server.MapPath("App_Data\\Applications\\" + newAppID.ToString());
            System.IO.Directory.CreateDirectory(resumePath);
            resumePath += "\\" + LastName.Text + "_" + FirstName.Text + ext;
            Resume.SaveAs(resumePath);

            if (Resume.HasFile)
            {
                bool isValid = false;

                if (Resume.PostedFile.ContentLength / 1024 < 500)
                {
                    switch (ext)
                    {
                    case ".pdf":
                        isValid = IsPDF(resumePath);
                        break;

                    case ".doc":
                        isValid = IsDoc(resumePath);
                        break;

                    case ".docx":
                        isValid = IsDoc(resumePath);
                        break;
                    }

                    if (isValid)
                    {
                        //resumePath += "\\" + LastName.Text + "_" + FirstName.Text + ext;
                        //Resume.SaveAs(resumePath);
                    }
                    else
                    {
                        Response.Write("<script>alert('The file entered is not in valid format. Please try again!!!')</script>");
                        return;
                    }
                }
                else
                {
                    Response.Write("<script>alert('The file entered is not in valid format. Please try again!!!')</script>");
                    return;
                }
            }
            else
            {
                Response.Write("<script>alert('The file entered is not in valid format. Please try again!!!')</script>");
                return;
            }

            sta.InsertQuery(USCID.Text, FirstName.Text, LastName.Text, Email.Text, resumePath, Major.SelectedValue.ToString());
            string           randomString = System.Guid.NewGuid().ToString().Replace("-", string.Empty);
            RecoTableAdapter rta          = new RecoTableAdapter();
            rta.InsertQuery(R1Name.Text, R1Email.Text, randomString, false, newAppID);
            SendEmail(R1Email.Text, "Scholarship Application Recommendation Request",
                      "Dear Mr. " + R1Name.Text + "," + System.Environment.NewLine +
                      "We are contacting you because Mr. " + FirstName.Text + " " + LastName.Text + " has applied for scholarship to our department and you have been indicated as a recommender." + System.Environment.NewLine +
                      "You are requested to recommend the applicant using the following link: " + Request.Url.GetLeftPart(UriPartial.Authority) + Page.ResolveUrl("recommend.aspx?id=" + randomString) +
                      System.Environment.NewLine +
                      "Thank you" + System.Environment.NewLine +
                      Major.SelectedItem.Text + " Department");

            randomString = System.Guid.NewGuid().ToString().Replace("-", string.Empty);
            rta.InsertQuery(R2Name.Text, R2Email.Text, randomString, false, newAppID);
            SendEmail(R2Email.Text, "Scholarship Application Recommendation Request",
                      "Dear Mr. " + R2Name.Text + "," + System.Environment.NewLine +
                      "We are contacting you because Mr. " + FirstName.Text + " " + LastName.Text + " has applied for scholarship to our department and you have been indicated as a recommender." + System.Environment.NewLine +
                      "You are requested to recommend the applicant using the following link: " + Request.Url.GetLeftPart(UriPartial.Authority) + Page.ResolveUrl("recommend.aspx?id=" + randomString) +
                      System.Environment.NewLine +
                      "Thank you" + System.Environment.NewLine +
                      Major.SelectedItem.Text + " Department");

            SendEmail(Email.Text, "Scholarship Application Submitted",
                      "Dear Mr. " + LastName.Text + "," + System.Environment.NewLine +
                      "You have successfully applied for scholarship to " + Major.SelectedItem.Text + " Department" + System.Environment.NewLine +
                      "Your application is under review. You will be notified once final decision is made." + System.Environment.NewLine +
                      "You can check your status at " + Request.Url.GetLeftPart(UriPartial.Authority) + Page.ResolveUrl("trackStatus.aspx") + ". " +
                      "Your ApplicationID is: " + newAppID + System.Environment.NewLine +
                      System.Environment.NewLine +
                      "Thank you" + System.Environment.NewLine +
                      Major.SelectedItem.Text + " Department");
        }
        catch (Exception exception)
        {
            Response.Write(exception.ToString());
            //Response.Write("<script>alert('Error saving data. Try again.')</script>");
            //Response.Redirect(Page.Request.Url.ToString(), true);
        }
    }