Example #1
0
        public void LoadPartDS(string k)
        {
            dataGridView1.AutoGenerateColumns = false;
            var DS = (from s in SV.tbl_SinhVien
                      join d in SV.tbl_Diem
                      on s.MSSV equals d.MSSV into temp1
                      from t in temp1.DefaultIfEmpty()
                      join m in SV.tbl_DMMonHoc
                      on t.MaMH equals m.MaMH into temp2
                      from p in temp2.DefaultIfEmpty()
                      where s.MaKhoa == k
                      orderby s.MSSV
                      select new
            {
                s.MSSV,
                s.Ho,
                s.Ten,
                s.MaKhoa,
                t.MaMH,
                p.TenMH,
                t.Diem,
                s.KetQuaTN,
                s.DTB,
                s.XepLoaiTN,
            });
            DataTable dt = ConvertDatatable.LINQToDataTable(DS);

            dataGridView1.DataSource = null;
            dataGridView1.Rows.Clear();
            dataGridView1.DataSource = dt;
            label1.Text = dataGridView1.RowCount.ToString();
        }
Example #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            var query = from BangSinhVien in SV.tbl_SinhVien
                        join BangKhoa in SV.tbl_Khoa
                        on BangSinhVien.MaKhoa equals BangKhoa.MaKhoa
                        select new
            {
                BangSinhVien.MSSV,
                BangSinhVien.Ho,
                BangSinhVien.Ten,
                BangSinhVien.GioiTinh,
                BangSinhVien.NTNS,
                BangSinhVien.NoiSinh,
                BangSinhVien.MaKhoa,
                BangKhoa.TenKhoa,
                BangSinhVien.KetQuaTN,
                BangSinhVien.DTB,
                BangSinhVien.XepLoaiTN
            };
            DataTable dt = ConvertDatatable.LINQToDataTable(query);

            saveFileDialog1.FileName = "DanhSachTemp";
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                string FolderPath = saveFileDialog1.FileName;
                using (XLWorkbook wb = new XLWorkbook())
                {
                    //Ten sheet
                    wb.Worksheets.Add(dt, "Temp");
                    //Duong dan chua ten file excel
                    wb.SaveAs(FolderPath + ".xlsx");
                }
                MessageBox.Show("Saved succesfully at " + FolderPath);
            }
        }
Example #3
0
        private void Report_Load(object sender, EventArgs e)
        {
            SinhVienEntities1 SV = new SinhVienEntities1();
            DataTable         dt;

            if (Login.MaKhoa == "QT")
            {
                var DS = (from s in SV.tbl_SinhVien
                          select s).ToList();
                dt = ConvertDatatable.LINQToDataTable(DS);
            }
            else
            {
                var DS = (from s in SV.tbl_SinhVien
                          where s.MaKhoa == Login.MaKhoa
                          select s).ToList();
                dt = ConvertDatatable.LINQToDataTable(DS);
            }

            PageSettings pg = new PageSettings();

            pg.Margins           = new Margins(0, 0, 0, 0);
            pg.PaperSize         = new PaperSize("A4", 1169, 827);
            pg.PaperSize.RawKind = (int)PaperKind.A4;

            reportViewer1.LocalReport.DataSources.Clear();
            ReportDataSource rpds = new ReportDataSource("SinhVienReport", dt);

            reportViewer1.ProcessingMode = ProcessingMode.Local;
            reportViewer1.LocalReport.EnableExternalImages = true;
            reportViewer1.LocalReport.DataSources.Add(rpds);

            ReportParameter[] parameters = new ReportParameter[1];    // So luong parameters
            parameters[0] = new ReportParameter("Signature", "WhiteK");
            this.reportViewer1.LocalReport.SetParameters(parameters);

            this.reportViewer1.SetPageSettings(pg);
            this.reportViewer1.SetDisplayMode(DisplayMode.PrintLayout);
            this.reportViewer1.RefreshReport();
        }
Example #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (Login.MaKhoa == "QT")
     {
         if (comboBox2.SelectedValue.ToString() == "QT")
         {
             var DS = (from s in SV.tbl_SinhVien
                       join d in SV.tbl_Diem
                       on s.MSSV equals d.MSSV into temp1
                       from t in temp1.DefaultIfEmpty()
                       join m in SV.tbl_DMMonHoc
                       on t.MaMH equals m.MaMH into temp2
                       from p in temp2.DefaultIfEmpty()
                       orderby s.MSSV
                       select new
             {
                 s.MSSV,
                 s.Ho,
                 s.Ten,
                 s.MaKhoa,
                 t.MaMH,
                 p.TenMH,
                 t.Diem,
                 s.KetQuaTN,
                 s.DTB,
                 s.XepLoaiTN,
             });
             DataTable dt = ConvertDatatable.LINQToDataTable(DS);
             saveFileDialog1.FileName = "DanhSachTemp";
             if (saveFileDialog1.ShowDialog() == DialogResult.OK)
             {
                 string FolderPath = saveFileDialog1.FileName;
                 using (XLWorkbook wb = new XLWorkbook())
                 {
                     //Ten sheet
                     wb.Worksheets.Add(dt, "Temp");
                     //Duong dan chua ten file excel
                     wb.SaveAs(FolderPath + ".xlsx");
                 }
                 MessageBox.Show("Saved succesfully at " + FolderPath);
             }
         }
         else
         {
             var DS = (from s in SV.tbl_SinhVien
                       join d in SV.tbl_Diem
                       on s.MSSV equals d.MSSV into temp1
                       from t in temp1.DefaultIfEmpty()
                       join m in SV.tbl_DMMonHoc
                       on t.MaMH equals m.MaMH into temp2
                       from p in temp2.DefaultIfEmpty()
                       where s.MaKhoa == comboBox2.SelectedValue.ToString()
                       orderby s.MSSV
                       select new
             {
                 s.MSSV,
                 s.Ho,
                 s.Ten,
                 s.MaKhoa,
                 t.MaMH,
                 p.TenMH,
                 t.Diem,
                 s.KetQuaTN,
                 s.DTB,
                 s.XepLoaiTN,
             });
             DataTable dt = ConvertDatatable.LINQToDataTable(DS);
             saveFileDialog1.FileName = "DanhSachTemp";
             if (saveFileDialog1.ShowDialog() == DialogResult.OK)
             {
                 string FolderPath = saveFileDialog1.FileName;
                 using (XLWorkbook wb = new XLWorkbook())
                 {
                     //Ten sheet
                     wb.Worksheets.Add(dt, "Temp");
                     //Duong dan chua ten file excel
                     wb.SaveAs(FolderPath + ".xlsx");
                 }
                 MessageBox.Show("Saved succesfully at " + FolderPath);
             }
         }
     }
     else
     {
         var DS = (from s in SV.tbl_SinhVien
                   join d in SV.tbl_Diem
                   on s.MSSV equals d.MSSV into temp1
                   from t in temp1.DefaultIfEmpty()
                   join m in SV.tbl_DMMonHoc
                   on t.MaMH equals m.MaMH into temp2
                   from p in temp2.DefaultIfEmpty()
                   where s.MaKhoa == Login.MaKhoa
                   orderby s.MSSV
                   select new
         {
             s.MSSV,
             s.Ho,
             s.Ten,
             s.MaKhoa,
             t.MaMH,
             p.TenMH,
             t.Diem,
             s.KetQuaTN,
             s.DTB,
             s.XepLoaiTN,
         });
         DataTable dt = ConvertDatatable.LINQToDataTable(DS);
         saveFileDialog1.FileName = "DanhSachTemp";
         if (saveFileDialog1.ShowDialog() == DialogResult.OK)
         {
             string FolderPath = saveFileDialog1.FileName;
             using (XLWorkbook wb = new XLWorkbook())
             {
                 //Ten sheet
                 wb.Worksheets.Add(dt, "Temp");
                 //Duong dan chua ten file excel
                 wb.SaveAs(FolderPath + ".xlsx");
             }
             MessageBox.Show("Saved succesfully at " + FolderPath);
         }
     }
 }