using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using Word = [Link];
namespace WindowsFormsApp1
public partial class printSaveForm : Form
public printSaveForm()
InitializeComponent();
private void printSaveForm_Load(object sender, EventArgs e)
radioButton_all.Checked = true;
radioButton_no.Checked = true;
string strSQL = "SELECT * FROM student";
string strCon = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=QL_login;Integrated
Security=True";
SqlConnection con = new SqlConnection();
[Link] = strCon;
dataGridView_information.[Link] = 80;
DataGridViewImageColumn picCol = new DataGridViewImageColumn();
try
[Link]();
SqlDataAdapter adapter = new SqlDataAdapter(strSQL, con);
DataSet ds = new DataSet("Student");
[Link](ds, "Student");
DataTable table = [Link]["Student"];
dataGridView_information.DataSource = table;
picCol = (DataGridViewImageColumn)dataGridView_information.Columns[7];
[Link] = [Link];
dataGridView_information.AllowUserToAddRows = false;
[Link]();
catch (Exception ex)
[Link]("Error", [Link]);
if ([Link] != [Link])
[Link]();
finally
[Link]();
private void radioButton_male_CheckedChanged(object sender, EventArgs e)
private void radioButton_female_CheckedChanged(object sender, EventArgs e)
private void radioButton_yes_CheckedChanged(object sender, EventArgs e)
}
private void radioButton_no_CheckedChanged(object sender, EventArgs e)
private void button_check_Click(object sender, EventArgs e)
string strSQL = "SELECT * FROM student";
if (radioButton_no.Checked == true)
if (radioButton_male.Checked == true)
strSQL += " WHERE gender = 'male'";
else
strSQL += " WHERE gender = 'female'";
if (radioButton_yes.Checked == true)
DateTime start = dateTimePicker_start.Value;
DateTime end = dateTimePicker_end.Value;
if (radioButton_all.Checked == true)
strSQL += " WHERE Bdate BETWEEN '" + [Link]() + "' AND '" + [Link]() + "'";
if (radioButton_male.Checked == true)
strSQL += " WHERE gender = 'male' AND Bdate BETWEEN '" + [Link]() + "' AND '" +
[Link]() + "'";
if (radioButton_female.Checked == true)
strSQL += " WHERE gender = 'female' AND Bdate BETWEEN '" + [Link]() + "' AND '" +
[Link]() + "'";
string strCon = @"Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=QL_login;Integrated
Security=True";
SqlConnection con = new SqlConnection();
[Link] = strCon;
dataGridView_information.[Link] = 80;
DataGridViewImageColumn picCol = new DataGridViewImageColumn();
try
[Link]();
SqlDataAdapter adapter = new SqlDataAdapter(strSQL, con);
DataSet ds = new DataSet("Student");
[Link](ds, "Student");
DataTable table = [Link]["Student"];
dataGridView_information.DataSource = table;
picCol = (DataGridViewImageColumn)dataGridView_information.Columns[7];
[Link] = [Link];
dataGridView_information.AllowUserToAddRows = false;
[Link]();
catch (Exception ex)
{
[Link]("Error", [Link]);
if ([Link] != [Link])
[Link]();
finally
[Link]();
public void Export_Data_To_Word(DataGridView DGV, string filename)
if (dataGridView_information.[Link] != 0)
int RowCount = dataGridView_information.[Link];
int ColumnCount = dataGridView_information.[Link];
[Link] oDoc = new [Link]();
[Link] = true;
[Link] = [Link];
//dynamic oRange = [Link];
string oTemp = "";
Object oMissing = [Link];
for (int r = 0; r <= RowCount - 1; r++)
oTemp = "";
for (int c = 0; c < ColumnCount - 1; c++)
{
oTemp = oTemp + dataGridView_information.Rows[r].Cells[c].Value + "\t";
var oPara1 = [Link](ref oMissing);
[Link] = oTemp;
[Link]();
byte[] imgbyte = (byte[])dataGridView_information.Rows[r].Cells[7].Value;
MemoryStream ms = new MemoryStream(imgbyte);
[Link] sparePicture = [Link](ms);
[Link] finalPic = ([Link])(new Bitmap(sparePicture, new
Size(90, 90)));
[Link](finalPic);
var oPara2 = [Link](ref oMissing);
[Link]();
[Link]();
//oTemp += "\n";
//save the file
oDoc.SaveAs2(filename);
private void button_Save_Click(object sender, EventArgs e)
SaveFileDialog sfd = new SaveFileDialog();
[Link] = "Word Documents (.docx)|.docx";
[Link] = "[Link]";
if ([Link]() == [Link])
Export_Data_To_Word(dataGridView_information, [Link]);
private void button_print_Click(object sender, EventArgs e)
PrintDialog printDlg = new PrintDialog();
PrintDocument printDoc = new PrintDocument();
[Link] = "Print Document";
[Link] = printDoc;
[Link] = true;
[Link] = true;
if ([Link]() == [Link])
[Link]();
private void button1_Click(object sender, EventArgs e)
if (dataGridView_information.[Link] > 0)
SaveFileDialog sfd = new SaveFileDialog();
[Link] = "PDF (*.pdf)|*.pdf";
[Link] = "[Link]";
bool fileError = false;
if ([Link]() == [Link])
if ([Link]([Link]))
try
[Link]([Link]);
catch (IOException ex)
fileError = true;
[Link]("It wasn't possible to write the data to the disk." + [Link]);
if (!fileError)
try
PdfPTable pdfTable = new PdfPTable(dataGridView_information.[Link]);
[Link] = 3;
[Link] = 100;
[Link] = Element.ALIGN_LEFT;
foreach (DataGridViewColumn column in dataGridView_information.Columns)
PdfPCell cell = new PdfPCell(new Phrase([Link]));
[Link](cell);
}
foreach (DataGridViewRow row in dataGridView_information.Rows)
string id = [Link][0].[Link]();
[Link](id);
string Fname = [Link][1].[Link]();
[Link](Fname);
string Lname = [Link][2].[Link]();
[Link](Lname);
string Bdate = [Link][3].[Link]();
[Link](Bdate);
string gender = [Link][4].[Link]();
[Link](gender);
string phone = [Link][5].[Link]();
[Link](phone);
string address = [Link][6].[Link]();
[Link](address);
byte[] imageByte = (byte[])[Link][7].Value;
[Link] Image = [Link](imageByte);
[Link](Image);
using (FileStream stream = new FileStream([Link], [Link]))
Document pdfDoc = new Document(PageSize.A4, 10f, 20f, 20f, 10f);
[Link](pdfDoc, stream);
[Link]();
[Link](pdfTable);
[Link]();
[Link]();
[Link]("Data Exported Successfully !!!", "Info");
catch (Exception ex)
[Link]("Error :" + [Link]);
else
[Link]("No Record To Export !!!", "Info");