Дипломная работа: Автоматизация учета рабочего времени сотрудников в ТОО "Профессиональные охранные системы"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
122
InitializeComponent();
var states = DB.Workers.Select(p => new { p.WorkerId, Fullname = p.Name +
" ID = " + p.WorkerId });
var pr1Q1 = states.ToList();
comboBox1.DataSource = pr1Q1;
comboBox1.DisplayMember = "Fullname";
comboBox1.ValueMember = "WorkerId";
}
private void label1_Click(object sender, EventArgs e)
{
var selectTimeWorker = DB.Workers.Join(DB.Visits, w => w.WorkerId, v =>
v.WorkerId, (w, v) => new
{
Код_работника=w.WorkerId,
Имя = w.Name,
Фамилия = w.Surname,
Телефон = w.Phone,
Дата = v.Date,
Время_прихода = v.Time_in,
Время_ухода = v.Time_out
}).Where(wh=>wh.Код_работника==(int)comboBox1.SelectedValue &&
wh.Дата.Month == DateTime.Today.Month);
var writeGrid = selectTimeWorker.ToList();
dataGridView1.DataSource = writeGrid;
}
}
}
using System;
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 WorkersTimes
{
public partial class Vizit : Form
{
Model1 DB = new Model1();
public Vizit()
{
InitializeComponent();
var states = DB.Workers.Select(p => new { p.WorkerId,Fullname= p.Name + "
ID = " + p.WorkerId });
var pr1Q1 = states.Take(300).ToList();
comboBox1.DataSource = pr1Q1;
comboBox1.DisplayMember = "Fullname";
comboBox1.ValueMember = "WorkerId";
}
private void label4_Click(object sender, EventArgs e)
{
var addVizit = new Visits
{
Date = DateTime.Today,
WorkerId = int.Parse(comboBox1.SelectedValue.ToString()),
Time_in = TimeSpan.Parse( dateTimePicker1.Text),
Time_out = TimeSpan.Parse(dateTimePicker2.Text),
123
};
DB.Visits.Add(addVizit);
DB.SaveChanges();
MessageBox.Show("Визит добавлен!!!");
}
}
}
using System;
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 WorkersTimes
{
public partial class TimeLog : Form
{
Model1 DB = new Model1();
public TimeLog()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
if (comboBox1.Text == "По отделу")
{
var selectDepartament = from d in DB.Departments
join w in DB.Workers on d.WorkerId equals
w.WorkerId
join v in DB.Visits on w.WorkerId equals
v.WorkerId
select new
{
Название_отдела = d.Name,
// Количество_часов =
Math.Abs(v.Time_out.Value.Hours - v.Time_in.Value.Hours)
Работник = w.Name+"; "+w.Surname,
Дата = v.Date
};
var writeGrid = selectDepartament.ToList();
dataGridView1.DataSource = writeGrid;
}
else if(comboBox1.Text == "По бригаде")
{
var selectDepartament = from d in DB.Departments
join b in DB.Brigades on d.DepartmentId equals
b.DepartmentId
join w in DB.Departments on b.DepartmentId
equals w.DepartmentId
join wo in DB.Workers on w.WorkerId equals
wo.WorkerId
join v in DB.Visits on wo.WorkerId equals
v.WorkerId
124
select new
{
Название_бригады = b.Name,
Работник = wo.Name + "; " + wo.Surname,
Дата = v.Date
};
var writeGrid = selectDepartament.ToList();
dataGridView1.DataSource = writeGrid;
}
else
{
MessageBox.Show("Некорректный запрос!!!!!!!!");
}
}
private void label2_Click(object sender, EventArgs e)
{
try
{
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Of-
fice.Interop.Excel.Application();
excel.Visible = true;
Microsoft.Office.Interop.Excel.Workbook workbook = excel.Work-
books.Add(System.Reflection.Missing.Value);
Microsoft.Office.Interop.Excel.Worksheet sheet1 = (Microsoft.Of-
fice.Interop.Excel.Worksheet)workbook.Sheets[1];
int StartCol = 1;
int StartRow = 1;
int j = 0, i = 0;
//Write Headers
for (j = 0; j < dataGridView1.Columns.Count; j++)
{
Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Of-
fice.Interop.Excel.Range)sheet1.Cells[StartRow, StartCol + j];
myRange.Value2 = dataGridView1.Columns[j].HeaderText;
}
StartRow++;
//Write datagridview content
for (i = 0; i < dataGridView1.Rows.Count; i++)
{
for (j = 0; j < dataGridView1.Columns.Count; j++)
{
try
{
Microsoft.Office.Interop.Excel.Range myRange = (Mi-
crosoft.Office.Interop.Excel.Range)sheet1.Cells[StartRow + i, StartCol + j];
myRange.Value2 = dataGridView1[j, i].Value == null ? "" :
dataGridView1[j, i].Value;
}
catch
{
;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
125
}
}
}
}
using System;
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 WorkersTimes
{
public partial class Salary : Form
{
Model1 DB = new Model1();
public Salary()
{
InitializeComponent();
var states = DB.Workers.Select(p => new { p.WorkerId, Fullname = p.Name +
" ID = " + p.WorkerId });
var pr1Q1 = states.ToList();
comboBox2.DataSource = pr1Q1;
comboBox2.DisplayMember = "Fullname";
comboBox2.ValueMember = "WorkerId";
}
private void label5_Click(object sender, EventArgs e)
{
var selectTimeWorker = DB.Workers.Join(DB.Visits, w => w.WorkerId, v =>
v.WorkerId, (w, v) => new
{
Код_работника = w.WorkerId,
Имя = w.Name,
Фамилия = w.Surname,
Телефон = w.Phone,
Зарплата = w.Salary
}).Where(wh => wh.Код_работника == (int)comboBox2.SelectedValue);
var writeGrid = selectTimeWorker.ToList();
dataGridView1.DataSource = writeGrid;
}
private void label2_Click(object sender, EventArgs e)
{
try
{
Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Of-
fice.Interop.Excel.Application();
excel.Visible = true;
Microsoft.Office.Interop.Excel.Workbook workbook = excel.Work-
books.Add(System.Reflection.Missing.Value);
Microsoft.Office.Interop.Excel.Worksheet sheet1 = (Microsoft.Of-
fice.Interop.Excel.Worksheet)workbook.Sheets[1];
int StartCol = 1;
int StartRow = 1;
int j = 0, i = 0;
//Write Headers
for (j = 0; j < dataGridView1.Columns.Count; j++)
126
{
Microsoft.Office.Interop.Excel.Range myRange = (Microsoft.Of-
fice.Interop.Excel.Range)sheet1.Cells[StartRow, StartCol + j];
myRange.Value2 = dataGridView1.Columns[j].HeaderText;
}
StartRow++;
//Write datagridview content
for (i = 0; i < dataGridView1.Rows.Count; i++)
{
for (j = 0; j < dataGridView1.Columns.Count; j++)
{
try
{
Microsoft.Office.Interop.Excel.Range myRange = (Mi-
crosoft.Office.Interop.Excel.Range)sheet1.Cells[StartRow + i, StartCol + j];
myRange.Value2 = dataGridView1[j, i].Value == null ? "" :
dataGridView1[j, i].Value;
}
catch
{
;
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
using System;
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 WorkersTimes
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
private void label5_Click(object sender, EventArgs e)
{
Vizit f = new Vizit();
f.Show();
}
private void label1_Click(object sender, EventArgs e)
{
WorkTime f = new WorkTime();
f.Show();
}
Источник: https://baza.diplomsite.ru/previewfile/2420