public bulletin(string pdfdirectory, string id = "11671321", string semestre = "1", string annee = "2017/2018", string ecole = "amana") { this.semestre = semestre; this.id = id; this.annee = annee; bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); document = new Document(); PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(pdfdirectory, FileMode.Create)); document.Open(); writeline2(new string[] { "بيان النتائج الدراسية للدورة " + (semestre == "1" ? "الاولى" : "الثانية"), "الاكاديمية الجهوية للتربية و التكوين" }, 3, new int[] { 0, 1 }, 7); writeline2(new string[] { "Bulletin du " + (semestre == "1" ? "1 er" : "2 eme") + " semestre", "لجهة : طنجة تطوان" }, 3, new int[] { 0, 1 }, 7); writeline2(new string[] { "السنة الدراسية : " + annee, "نيابة : طنجة اصيلة" }, 3, new int[] { 0, 1 }, 10); writeline("مؤسسة : " + ecole, 3, 2, 10); iTextSharp.text.Image pic = iTextSharp.text.Image.GetInstance("C:\\Images\\img.png"); pic.SetAbsolutePosition(390, 770); document.Add(new Paragraph(" \n")); pic.ScalePercent(((540 / 3) / pic.Width) * 100); document.Add(pic); MySqlDataReader r = DBConnect.Gets("select nom_ar,prenom_ar,groupe.nom,annee.annee_scolaire,id_massar from etudiant,groupe,annee,etudiant_groupe where etudiant.id=" + id + " and etudiant_groupe.id_etudiant=etudiant.id AND etudiant_groupe.id_groupe=groupe.id and groupe.id_annee=annee.id and annee.annee_scolaire='" + annee + "' "); while (r.Read()) { writeline("المستوى : " + r[2].ToString().Substring(0, 1) + " ابتدائي", 1, 1, 20); writeline("القسم : " + r[2].ToString(), 1, 1, 20); writeline("اسم و رقم التلميذ : " + r[0].ToString() + " " + r[1].ToString() + " " + r[4].ToString(), 1, 1, 20); } document.Add(new Paragraph(" \n")); myfont = new Font(bf, 12, Font.NORMAL); add_table_topdf(); PdfPTable resultat = new PdfPTable(new float[] { 1, 1, 1, 2 }); string[] cols = { "المعدل العام", "الدورة الثانية", "الدورة الاولى", "" }; foreach (string c in cols) { PdfPCell cell = new PdfPCell(new Phrase(c, myfont)); cell.HorizontalAlignment = 1; cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL; resultat.AddCell(cell); } r = DBConnect.Gets("select semestre ,avg(note) from examiner , annee where id_etudiant=" + id + " and id_annee=annee.id and annee.annee_scolaire='" + annee + "' group by semestre order by semestre "); int y = 0; List <Double> ff = new List <Double>(); string s = ""; while (r.Read()) { s = r[0].ToString(); ff.Add(Math.Round(Double.Parse(r[1].ToString()), 2)); y++; } if (y == 2) { PdfPCell cell = new PdfPCell(new Phrase(Math.Round(ff.Average(), 2).ToString(), myfont)); cell.HorizontalAlignment = 1; cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL; resultat.AddCell(cell); PdfPCell cell1 = new PdfPCell(new Phrase(ff[1].ToString(), myfont)); cell1.HorizontalAlignment = 1; cell1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; resultat.AddCell(cell1); PdfPCell cell2 = new PdfPCell(new Phrase(ff[0].ToString(), myfont)); cell2.HorizontalAlignment = 1; cell2.RunDirection = PdfWriter.RUN_DIRECTION_RTL; resultat.AddCell(cell2); } else if (y == 1) { string no = ""; string no2 = ""; if (s == "2") { no = ff[0].ToString(); } else { no2 = ff[0].ToString(); } PdfPCell cell = new PdfPCell(new Phrase("", myfont)); cell.HorizontalAlignment = 1; cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL; resultat.AddCell(cell); PdfPCell cell1 = new PdfPCell(new Phrase(no, myfont)); cell1.HorizontalAlignment = 1; cell1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; resultat.AddCell(cell1); PdfPCell cell2 = new PdfPCell(new Phrase(no2, myfont)); cell2.HorizontalAlignment = 1; cell2.RunDirection = PdfWriter.RUN_DIRECTION_RTL; resultat.AddCell(cell2); } PdfPCell cell3 = new PdfPCell(new Phrase("معدل المراقبة المستمرة", myfont)); cell3.HorizontalAlignment = 1; cell3.RunDirection = PdfWriter.RUN_DIRECTION_RTL; resultat.AddCell(cell3); r.Close(); document.Add(new Paragraph(" \n")); resultat.WidthPercentage = 40; resultat.HorizontalAlignment = Element.ALIGN_RIGHT; PdfPTable absences = new PdfPTable(2); PdfPCell c1 = new PdfPCell(new Phrase("الغياب", myfont)); c1.HorizontalAlignment = 1; c1.Colspan = 2; c1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; absences.AddCell(c1); c1 = new PdfPCell(new Phrase("", myfont)); c1.HorizontalAlignment = 1; c1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; absences.AddCell(c1); c1 = new PdfPCell(new Phrase("مبرر", myfont)); c1.HorizontalAlignment = 1; c1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; absences.AddCell(c1); c1 = new PdfPCell(new Phrase("", myfont)); c1.HorizontalAlignment = 1; c1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; absences.AddCell(c1); c1 = new PdfPCell(new Phrase("غير مبرر", myfont)); c1.HorizontalAlignment = 1; c1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; absences.AddCell(c1); PdfPTable ch = new PdfPTable(new float[] { 4, 1, 4 }); ch.WidthPercentage = 100; c1 = new PdfPCell(absences); c1.HorizontalAlignment = Element.ALIGN_LEFT; c1.Border = PdfPCell.NO_BORDER; ch.AddCell(c1); c1 = new PdfPCell(new Phrase("", myfont)); c1.Border = PdfPCell.NO_BORDER; ch.AddCell(c1); c1 = new PdfPCell(resultat); c1.HorizontalAlignment = Element.ALIGN_RIGHT; c1.Border = PdfPCell.NO_BORDER; ch.AddCell(c1); ch.HorizontalAlignment = Element.ALIGN_BOTTOM; PdfPTable etat = new PdfPTable(new float[] { 1, 1, 1, 1, 2 }); c1 = new PdfPCell(new Phrase("قرار اللجنة", myfont)); c1.HorizontalAlignment = 1; c1.Colspan = 5; c1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; etat.AddCell(c1); string[] cols2 = { "توبيخ", "انذار", "تنويه", "تشجيع", "لوحة الشرف", " ", " ", " ", " ", " " }; foreach (string c in cols2) { PdfPCell cell = new PdfPCell(new Phrase(c, myfont)); cell.HorizontalAlignment = 1; cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL; etat.AddCell(cell); } PdfPTable notes = new PdfPTable(new float[] { 1, 1, 1 }); c1 = new PdfPCell(new Phrase("الملاحظات العامة", myfont)); c1.HorizontalAlignment = 1; c1.Colspan = 3; c1.RunDirection = PdfWriter.RUN_DIRECTION_RTL; notes.AddCell(c1); string[] cols3 = { "يفصل", "يكرر", "ينتقل", " ", " ", " " }; foreach (string c in cols3) { PdfPCell cell = new PdfPCell(new Phrase(c, myfont)); cell.HorizontalAlignment = 1; cell.RunDirection = PdfWriter.RUN_DIRECTION_RTL; notes.AddCell(cell); } document.Add(ch); document.Add(new Paragraph(" \n")); ch = new PdfPTable(new float[] { 4, 1, 4 }); ch.WidthPercentage = 100; c1 = new PdfPCell(notes); c1.HorizontalAlignment = Element.ALIGN_LEFT; c1.Border = PdfPCell.NO_BORDER; ch.AddCell(c1); c1 = new PdfPCell(new Phrase("", myfont)); c1.Border = PdfPCell.NO_BORDER; ch.AddCell(c1); c1 = new PdfPCell(etat); c1.HorizontalAlignment = Element.ALIGN_RIGHT; c1.Border = PdfPCell.NO_BORDER; ch.AddCell(c1); ch.HorizontalAlignment = Element.ALIGN_BOTTOM; document.Add(ch); document.Close(); }
private void Importer_b_Click(object sender, EventArgs e) { string query = ""; if (this.q == "notes") { rowsOfNotes(); ColumnsOfNotes(); string semestre = label16.Text; if (semestre.Contains("الأولى")) { semestre = "1"; } else { semestre = "2"; } string titre = label17.Text; if (titre.Contains("الأول")) { titre = "cc1"; } else if (titre.Contains("الثاني")) { titre = "cc2"; } else if (titre.Contains("الثالث")) { titre = "cc3"; } else if (titre.Contains("الرابع")) { titre = "cc4"; } else if (titre.Contains("الخامس")) { titre = "cc5"; } else { MessageBox.Show("veuillez respecter le format "); return; } string matiere = label18.Text;//due label of matiere is empty DBConnect.Post("insert ignore into matiere values (null,'" + matiere + "')"); string idMatiere = DBConnect.Get("select id from matiere where nom='" + matiere + "'"); this.id_annee = DBConnect.Get("select id from annee where annee_scolaire='" + label19.Text + "'"); MessageBox.Show(this.id_annee); this.id_groupe = DBConnect.Get(string.Format("select id from groupe where nom = '{0}' and id_annee = {1}", label14.Text, this.id_annee)); if (this.id_groupe == "") { MessageBox.Show("groupe introuvable"); return; } query += "insert ignore into examiner values "; DBConnect.Post("insert ignore into enseignant (nom, prenom) values ('" + label15.Text.Split(' ')[0] + "','" + label15.Text.Split(' ')[1] + "')"); DBConnect.Post("insert ignore into groupe_matiere_enseignant values (" + idMatiere + "," + id_groupe + ", (select id from enseignant where nom='" + label15.Text.Split(' ')[0] + "' and prenom='" + label15.Text.Split(' ')[1] + "'))"); MessageBox.Show(this.id_groupe); foreach (int row in this.notesrows) { foreach (int col in this.notescols) { query += string.Format(" ({0},{1},{2},{3},'{4}','{5}','{6}',{7}) ,", this.id_annee, this.id_groupe, dataGridView1.Rows[row].Cells[0].Value.ToString(), idMatiere, titre, semestre, dataGridView1.Columns[col].HeaderText, dataGridView1.Rows[row].Cells[col].Value.ToString()); } } query = query.Substring(0, query.Length - 1); try { DBConnect.Post(query); } catch (Exception exx) { MessageBox.Show(exx.Message); } } else if (this.q == "info") { MessageBox.Show("_" + label31.Text + "_"); this.id_annee = DBConnect.Get("select id from annee where annee_scolaire='" + label31.Text + "'"); DBConnect.Post(string.Format("insert ignore into groupe values(null,'{0}',{1},{2})", label33.Text, label33.Text.Substring(0, 1), this.id_annee)); this.id_groupe = DBConnect.Get(string.Format("select id from groupe where nom = '{0}' and id_annee = {1}", label33.Text, this.id_annee)); string query3 = "insert into etudiant_groupe values "; query += "INSERT ignore INTO etudiant values "; foreach (DataGridViewRow r in dataGridView1.Rows) { if (r.Cells[0].Value == null || r.Cells[0].Value.ToString().Trim().Length == 0) { continue; } query += " ( "; foreach (DataGridViewCell c in r.Cells) { if (c.ColumnIndex == 0) { query += c.Value.ToString() + ","; query3 += "(" + id_groupe + "," + c.Value.ToString() + "),"; } else { query += "'" + c.Value.ToString() + "',"; } } query = query.Substring(0, query.Length - 1); query += ") ,"; } query = query.Substring(0, query.Length - 1); query3 = query3.Substring(0, query3.Length - 1); DBConnect.Post(query); DBConnect.Post("delete from etudiant_groupe where id_groupe=" + this.id_groupe); DBConnect.Post(query3); } }