using MySql.Data.MySqlClient; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace EMSystem.Forms { public partial class EmpListForm : Form { // constructor public EmpListForm() { InitializeComponent(); } // when loading employee list form private void EmpListForm_Load(object sender, EventArgs e) { //fills datagridview with data from datasource this.employeelistTableAdapter.Fill(this.emsDataSet.employeelist); } // delete row from employee table list table private void delBtn_Click(object sender, EventArgs e) { foreach (DataGridViewRow item in this.empListGridView.SelectedRows) { // removes at place where you have clicked with your mouse empListGridView.Rows.RemoveAt(item.Index); } } // save button functionality private void saveBtn_Click(object sender, EventArgs e) { // instantly updates data source employeelistTableAdapter.Update(emsDataSet); // popup messagebox to show that everything has worked MessageBox.Show("Employee List Updated", "Update", MessageBoxButtons.OK, MessageBoxIcon.Information); } // print button functionality private void printBtn_Click(object sender, EventArgs e) { // calls function printDoc to print the employee list printDoc.Print(); } // print documents settings/properties private void printDoc_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Bitmap bm = new Bitmap (this.empListGridView.Width, this.empListGridView.Height); empListGridView.DrawToBitmap(bm, new Rectangle(0, 0, this.empListGridView.Width, this.empListGridView.Height)); e.Graphics.DrawImage(bm, 0, 0); } } }