224 lines
7.2 KiB
C#
224 lines
7.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace FPJ0000.JobReport_
|
|
{
|
|
public partial class rJobReportOT : Form
|
|
{
|
|
public rJobReportOT()
|
|
{
|
|
InitializeComponent();
|
|
//this.WindowState = FormWindowState.Maximized;
|
|
}
|
|
|
|
private void rJobReport_Load(object sender, EventArgs e)
|
|
{
|
|
this.tbProcess.Items.Clear();
|
|
tbProcess.Items.Add("전체");
|
|
var taProcess = new dsReportTableAdapters.ProcessListTableAdapter();
|
|
var dtProcessList = taProcess.GetData(FCOMMON.info.Login.gcode);
|
|
foreach (dsReport.ProcessListRow dr in dtProcessList.Rows)
|
|
tbProcess.Items.Add(dr.processs);
|
|
|
|
//this.tbProcess.Text = FCOMMON.info.Login.process;
|
|
if (tbProcess.SelectedIndex < 0) tbProcess.SelectedIndex = 0;
|
|
|
|
this.tbSd.Text = DateTime.Now.Year.ToString() + "-01";
|
|
this.tbEd.Text = DateTime.Now.Year.ToString() + "-12";
|
|
this.Show();
|
|
Application.DoEvents();
|
|
|
|
refrehData();
|
|
}
|
|
|
|
void refrehData()
|
|
{
|
|
////휴일데이터가 들어가 있음.
|
|
//var taH = new dsReportTableAdapters.HolidayLIstTableAdapter();
|
|
//taH.Fill(this.dsReport.HolidayLIst, tbMon.Text + "%");
|
|
|
|
string prcname = tbProcess.SelectedIndex < 1 ? "%" : tbProcess.Text.Trim();
|
|
this.ta.FillByOt2(this.dsReport.jobReport, FCOMMON.info.Login.gcode, prcname, tbSd.Text, tbEd.Text);
|
|
|
|
|
|
//그리드뷰 생성
|
|
this.dataGridView1.AllowUserToAddRows = false;
|
|
this.dataGridView1.AllowUserToDeleteRows = false;
|
|
this.dataGridView1.Rows.Clear();
|
|
this.dataGridView1.Columns.Clear();
|
|
this.dataGridView1.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
|
this.dataGridView1.ColumnHeadersHeight = 35;
|
|
this.dataGridView1.Columns.Add("공정", "공정");
|
|
this.dataGridView1.Columns.Add("이름", "이름");
|
|
this.dataGridView1.Columns.Add("사번", "사번");
|
|
|
|
|
|
//이름/년도데이터추가
|
|
var ymlist = dsReport.jobReport.OrderBy(t => t.yymm).GroupBy(t => t.yymm);
|
|
foreach (var ym in ymlist)
|
|
{
|
|
var drYm = ym.FirstOrDefault();
|
|
var basehr = int.Parse(drYm.yymm.Substring(drYm.yymm.IndexOf('(')).Replace("(", "").Replace(")", ""));
|
|
this.dataGridView1.Columns.Add(drYm.yymm, drYm.yymm.Substring(0, 7) + "\n휴일");// + "\r\n(" + basehr.ToString() + ")");
|
|
this.dataGridView1.Columns.Add(drYm.yymm, $"({basehr})\n연장");
|
|
this.dataGridView1.Columns[this.dataGridView1.Columns.Count - 2].Tag = basehr;
|
|
this.dataGridView1.Columns[this.dataGridView1.Columns.Count - 1].Tag = basehr;
|
|
}
|
|
this.dataGridView1.Columns.Add("subtotal", "합계\n휴일");
|
|
this.dataGridView1.Columns.Add("subtotal", "합계\n연장");
|
|
|
|
//이름으로 정렬해서 데이터를 가져온다
|
|
var namelist = this.dsReport.jobReport.OrderBy(t => t.UserProcess + t.uname).GroupBy(t => t.uname);
|
|
foreach (var uname in namelist)
|
|
{
|
|
var drName = uname.FirstOrDefault();
|
|
|
|
List<string> rowdata = new List<string>();
|
|
rowdata.Add(drName.UserProcess);
|
|
rowdata.Add(drName.uname);
|
|
rowdata.Add(drName.uid);
|
|
|
|
if (drName.uid.Equals("221597"))
|
|
{
|
|
|
|
}
|
|
|
|
double User_sumhl = 0;
|
|
double User_sumot = 0;
|
|
|
|
List<Boolean> high = new List<bool>();
|
|
List<Boolean> low = new List<bool>();
|
|
for (int i = 3; i < this.dataGridView1.ColumnCount; i += 2)
|
|
{
|
|
var col = dataGridView1.Columns[i];
|
|
var coltitle = col.HeaderText;
|
|
if (col.Tag == null) continue;
|
|
var basehr = int.Parse(col.Tag.ToString());
|
|
|
|
var userDatas = dsReport.jobReport.Where(t => t.uid == drName.uid && t.yymm == col.Name);
|
|
if (userDatas == null || userDatas.Count() == 0)
|
|
{
|
|
//이달에는 데이터가없다
|
|
rowdata.Add(null); //휴일
|
|
rowdata.Add(null); //연장
|
|
high.Add(false);
|
|
low.Add(false);
|
|
}
|
|
else
|
|
{
|
|
////모든데이터를 확인해서 휴일이랑 데이터를 분리해야한다.
|
|
//var sumhr = 0f;
|
|
//var sumot = 0f;
|
|
//var sumholy = 0f;
|
|
//foreach(dsReport.jobReportRow item in userDatas)
|
|
//{
|
|
// dsReport.HolidayLIst.Where(t => t.pdate == item.yymm);
|
|
//}
|
|
|
|
var sumhr = userDatas.Sum(t => t.hrs);
|
|
var sumot = userDatas.Sum(t => t.ot2);
|
|
var sumhl = userDatas.Sum(t => t.holyot2);
|
|
|
|
User_sumhl += sumhl;
|
|
User_sumot += sumot;
|
|
|
|
if (sumhl == 0.0) rowdata.Add(null);
|
|
else rowdata.Add($"{sumhl}");
|
|
|
|
if (sumot == 0.0) rowdata.Add(null);
|
|
else rowdata.Add($"{sumot}");
|
|
|
|
if (sumhr > basehr) high.Add(true);
|
|
else high.Add(false);
|
|
|
|
if (sumhr < basehr) low.Add(true);
|
|
else low.Add(false);
|
|
}
|
|
}
|
|
|
|
|
|
rowdata.Add($"{User_sumhl}"); //합게
|
|
rowdata.Add($"{User_sumot}"); //합게
|
|
dataGridView1.Rows.Add(rowdata.ToArray());
|
|
|
|
//이번에 추가한 줄의 셀 컬러를 지정한다
|
|
var currentrow = dataGridView1.Rows.Count - 1;
|
|
for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
|
|
{
|
|
var col = this.dataGridView1.Columns[i];
|
|
if (col.Tag == null)
|
|
{
|
|
dataGridView1.Rows[currentrow].Cells[i].Style.ForeColor = Color.Black;
|
|
dataGridView1.Rows[currentrow].Cells[i].Style.BackColor = Color.WhiteSmoke;
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
if (col.HeaderText.Contains("연장"))
|
|
dataGridView1.Rows[currentrow].Cells[i].Style.BackColor = Color.Linen;// 155,82,93);
|
|
else
|
|
dataGridView1.Rows[currentrow].Cells[i].Style.BackColor = Color.White;
|
|
}
|
|
|
|
var idx = i - 2;
|
|
if (idx < high.Count)
|
|
{
|
|
if (high[idx]) dataGridView1.Rows[currentrow].Cells[i].Style.ForeColor = Color.Red;
|
|
else if (low[i - 2]) dataGridView1.Rows[currentrow].Cells[i].Style.ForeColor = Color.Blue;
|
|
else dataGridView1.Rows[currentrow].Cells[i].Style.ForeColor = Color.Black;
|
|
}
|
|
else dataGridView1.Rows[currentrow].Cells[i].Style.ForeColor = Color.Black;
|
|
}
|
|
}
|
|
|
|
//총계추가
|
|
|
|
|
|
List<object> rowdata2 = new List<object>();
|
|
rowdata2.Add("합계");
|
|
rowdata2.Add(dataGridView1.Rows.Count);
|
|
rowdata2.Add(null);
|
|
for (int i = 0; i < this.dataGridView1.ColumnCount; i++)
|
|
{
|
|
var col = this.dataGridView1.Columns[i];
|
|
if (col.Tag == null && col.HeaderText.StartsWith("합계") == false) continue;
|
|
|
|
var sum = 0.0;
|
|
for (int r = 0; r < this.dataGridView1.RowCount; r++)
|
|
{
|
|
var cell = dataGridView1.Rows[r].Cells[i];
|
|
if (cell.Value != null) sum += double.Parse(cell.Value.ToString());
|
|
}
|
|
if (sum != 0.0) rowdata2.Add(sum);
|
|
else rowdata2.Add(null);
|
|
}
|
|
dataGridView1.Rows.Add(rowdata2.ToArray());
|
|
dataGridView1.Rows[dataGridView1.Rows.Count - 1].DefaultCellStyle.BackColor = Color.LightGray;
|
|
|
|
this.dataGridView1.AutoResizeColumns();
|
|
|
|
}
|
|
|
|
private void btRefresh_Click(object sender, EventArgs e)
|
|
{
|
|
refrehData();
|
|
}
|
|
|
|
private void tbProcess_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
if (tbProcess.SelectedIndex >= 0) refrehData();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
dataGridView1.ExportData(string.Empty);
|
|
}
|
|
}
|
|
}
|