Пример #1
0
        // all students report in PDF
        private void button2_Click_1(object sender, EventArgs e)
        {
            int UserId = 0;

            connection.Open();
            sql     = "SELECT sum ([Grade])as TotalGrade,UserId FROM LearnMath.dbo.StudentPlay group by UserId";
            command = new SqlCommand(sql, connection);
            SqlDataAdapter da = new SqlDataAdapter(command);

            dataReader = command.ExecuteReader();
            IdSerchTxt.Clear();
            Document Doc = new Document();

            PdfWriter.GetInstance(Doc, new FileStream("C:/Users/felix/Desktop/reportForAll.pdf", FileMode.Create));
            Doc.Open();
            while (dataReader.Read())
            {
                totalGrade = int.Parse(dataReader.GetValue(0).ToString());
                UserId     = int.Parse(dataReader.GetValue(1).ToString());
                Paragraph p1 = new Paragraph("User Id " + UserId + "  Total Grade " + totalGrade.ToString());
                Doc.Add(p1);
            }
            connection.Close();
            Doc.Close();
            OpenFileDialog op = new OpenFileDialog();

            op.FileName = "C:/Users/felix/Desktop/reportForAll.pdf";
        }
Пример #2
0
        //report in PDf for one student and one game
        private void ShowReport_Click(object sender, EventArgs e)
        {
            int    UserId     = 0;
            int    GmameIndex = 0;
            int    level      = 0;
            string GameName   = null;

            if (!(comboBox1.Items.Contains("some value")))
            {
                try
                {
                    GameName = comboBox1.SelectedItem.ToString();
                }
                catch
                {
                }
                switch (GameName)
                {
                case "הכרת ספרות":
                    GmameIndex = 1;
                    break;

                case "מנייה":
                    GmameIndex = 2;
                    break;

                case "התאמת ספרות לכמות":
                    GmameIndex = 3;
                    break;

                case "רצף מספרים":
                    GmameIndex = 4;
                    break;

                case "משחק הזיכרון":
                    GmameIndex = 5;
                    break;

                case "חיבור וחיסור":
                    GmameIndex = 6;
                    break;

                default:
                    GmameIndex = 0;
                    break;
                }
            }
            if (IdSerchTxt.Text == "" || GmameIndex == 0)
            {
                MessageBox.Show("אנא בחר את כל הפרטים");
            }
            else
            {
                connection.Open();
                sql     = "SELECT UserId,GameCode,Grade FROM LearnMath.dbo.[StudentPlay] where StudentPlay.UserId ='" + IdSerchTxt.Text + "' and StudentPlay.GameCode='" + GmameIndex + "' ";
                command = new SqlCommand(sql, connection);
                SqlDataAdapter da = new SqlDataAdapter(command);
                dataReader = command.ExecuteReader();
                if (!(dataReader.HasRows))
                {
                    MessageBox.Show("תלמיד לא נמצא");
                    IdSerchTxt.Clear();
                }
                else
                {
                    while (dataReader.Read())
                    {
                        UserId      = int.Parse(dataReader.GetValue(0).ToString());
                        totalGrade += int.Parse(dataReader.GetValue(2).ToString());
                    }
                    connection.Close();
                    IdSerchTxt.Clear();
                    Document Doc = new Document();
                    PdfWriter.GetInstance(Doc, new FileStream("C:/Users/felix/Desktop/repoetPerStudent.pdf", FileMode.Create));
                    Doc.Open();
                    Paragraph p1 = new Paragraph(totalGrade.ToString());
                    Doc.Add(p1);
                    Doc.Close();
                    OpenFileDialog op = new OpenFileDialog();
                    op.FileName = "C:/Users/felix/Desktop/repoetPerStudent.pdf";
                }
            }
        }