File name
Commit message
Commit date
File name
Commit message
Commit date
using ClientLib;
using ClientLib.CommonService2;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using PublicLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HANMI_STD
{
public partial class WorkdayReport : PublicLib.CommonMDI
{
private bool m_Loading;
private DataTable m_Data;
public WorkdayReport()
{
InitializeComponent();
m_Loading = true;
bandedGridView_Main.OptionsView.ShowColumnHeaders = false;
comboBoxEdit_YY.Properties.Items.Clear();
comboBoxEdit_YY.Properties.DropDownRows = 25;
int yy = 2009;
for (int i = 0; i < 100; i++)
{
yy++;
comboBoxEdit_YY.Properties.Items.Add(yy.ToString());
}
lookUpEdit_COMP_CD.EditValueChanged += (sender, e) =>
{
searchProc();
};
comboBoxEdit_YY.SelectedIndexChanged += (sender, e) =>
{
searchProc();
};
monthCalendar_Main.DateSelected += (sender, e) =>
{
setDateInfo(e.End);
};
simpleButton_Next.Click += (sender, e) =>
{
if (comboBoxEdit_YY.SelectedIndex < comboBoxEdit_YY.Properties.Items.Count - 1)
{
comboBoxEdit_YY.SelectedIndex++;
}
};
simpleButton_Prev.Click += (sender, e) =>
{
if (comboBoxEdit_YY.SelectedIndex > 0)
{
comboBoxEdit_YY.SelectedIndex--;
}
};
bandedGridView_Main.FormatConditions.Clear();
StyleFormatCondition sfc;
sfc = new StyleFormatCondition(FormatConditionEnum.Equal, bandedGridView_Main.Columns["DAY_GUBUN"], null, "토요일");
sfc.ApplyToRow = true;
sfc.Appearance.ForeColor = Color.Blue;
sfc.Appearance.Options.UseForeColor = true;
bandedGridView_Main.FormatConditions.Add(sfc);
sfc = new StyleFormatCondition(FormatConditionEnum.Equal, bandedGridView_Main.Columns["DAY_GUBUN"], null, "일요일");
sfc.ApplyToRow = true;
sfc.Appearance.ForeColor = Color.Red;
sfc.Appearance.Options.UseForeColor = true;
bandedGridView_Main.FormatConditions.Add(sfc);
sfc = new StyleFormatCondition(FormatConditionEnum.Equal, bandedGridView_Main.Columns["DAY_GUBUN"], null, "평일");
sfc.ApplyToRow = true;
sfc.Appearance.ForeColor = Color.Magenta;
sfc.Appearance.Options.UseForeColor = true;
bandedGridView_Main.FormatConditions.Add(sfc);
sfc = new StyleFormatCondition(FormatConditionEnum.Equal, bandedGridView_Main.Columns["SEQ_NO"], null, 1);
sfc.ApplyToRow = true;
sfc.Appearance.Font = new Font(this.Font, FontStyle.Bold);
sfc.Appearance.BackColor = Color.FromArgb(236, 255, 230);
sfc.Appearance.Options.UseFont = true;
bandedGridView_Main.FormatConditions.Add(sfc);
sfc = new StyleFormatCondition(FormatConditionEnum.Equal, bandedGridView_Main.Columns["SEQ_NO"], null, 4);
sfc.ApplyToRow = true;
sfc.Appearance.Font = new Font(this.Font, FontStyle.Bold);
sfc.Appearance.BackColor = Color.FromArgb(236, 255, 230);
sfc.Appearance.Options.UseFont = true;
bandedGridView_Main.FormatConditions.Add(sfc);
sfc = new StyleFormatCondition(FormatConditionEnum.Equal, bandedGridView_Main.Columns["SEQ_NO"], null, 8);
sfc.ApplyToRow = true;
sfc.Appearance.Font = new Font(this.Font, FontStyle.Bold);
sfc.Appearance.BackColor = Color.FromArgb(236, 255, 230);
sfc.Appearance.Options.UseFont = true;
bandedGridView_Main.FormatConditions.Add(sfc);
this.Shown += (sender, e) =>
{
try
{
SerializedSqlParam[] aParam = new SerializedSqlParam[] {
ClientClass.CreateSqlParameter("MENU_ID", SqlDbType.NVarChar, this.m_MenuID),
ClientClass.CreateSqlParameter("USR_ID", SqlDbType.NVarChar, ConstClass._USR_ID)
};
ResultData resultComp = ClientClass.GetData("GetCompanyListByMenuUser", aParam);
if (resultComp.isError)
{
throw new Exception(resultComp.ResultValue);
}
UtilClass.SetLookup(lookUpEdit_COMP_CD, resultComp.TableData, "COMP_CD", "COMP_NM", true);
m_Loading = false;
comboBoxEdit_YY.SelectedIndex = comboBoxEdit_YY.Properties.Items.IndexOf(DateTime.Now.ToString("yyyy"));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
this.Close();
}
};
}
private void setDateInfo(DateTime date)
{
textEdit_Day.Text = "";
textEdit_WeekCount.Text = "";
textEdit_Reason.Text = "";
if (m_Data == null)
{
return;
}
CalendarWeekRule calendarWeekRule = CultureInfo.CurrentCulture.DateTimeFormat.CalendarWeekRule;
DayOfWeek dayOfWeek = CultureInfo.CurrentCulture.DateTimeFormat.FirstDayOfWeek;
int weekCount = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date, calendarWeekRule, dayOfWeek);
string dd = date.ToString("yyyy-MM-dd");
textEdit_Day.Text = dd;
textEdit_WeekCount.Text = date.ToString("yyyy") + weekCount.ToString("00");
DataRow[] rows = m_Data.Select("WORK_DAY = '" + dd + "'");
if (rows != null && rows.Length > 0)
{
textEdit_Reason.Text = UtilClass.toStr(rows[0]["HOL_NM"]);
}
}
public override void searchProc()
{
try
{
if (UtilClass.isNull(lookUpEdit_COMP_CD.EditValue) || m_Loading)
{
return;
}
this.Cursor = Cursors.WaitCursor;
monthCalendar_Main.MinDate = Convert.ToDateTime("1900-01-01");
monthCalendar_Main.MaxDate = Convert.ToDateTime("2200-12-31");
textEdit_WorkdayCount.Text = "0";
textEdit_HolidayCount.Text = "0";
textEdit_Day.Text = "";
textEdit_WeekCount.Text = "";
textEdit_Reason.Text = "";
gridControl_Main.DataSource = null;
SerializedSqlParam[] aParam = new SerializedSqlParam[] {
ClientClass.CreateSqlParameter("COMP_CD", SqlDbType.NVarChar, lookUpEdit_COMP_CD.EditValue),
ClientClass.CreateSqlParameter("YY", SqlDbType.NVarChar, comboBoxEdit_YY.Text)
};
ResultData resultData = ClientClass.GetData("GetWorkdayReport", aParam);
if (resultData.isError)
{
throw new Exception(resultData.ResultValue);
}
monthCalendar_Main.MinDate = Convert.ToDateTime(comboBoxEdit_YY.Text + "-01-01");
monthCalendar_Main.MaxDate = Convert.ToDateTime(comboBoxEdit_YY.Text + "-12-31");
monthCalendar_Main.RemoveAllBoldedDates();
for (int i = 0; i < resultData.DataList.Tables[0].Rows.Count; i++)
{
monthCalendar_Main.AddBoldedDate(Convert.ToDateTime(resultData.DataList.Tables[0].Rows[i]["WORK_DAY"]));
}
monthCalendar_Main.UpdateBoldedDates();
gridBand_Year.Caption = comboBoxEdit_YY.Text;
m_Data = resultData.DataList.Tables[0].Copy();
textEdit_WorkdayCount.Text = UtilClass.toInt(resultData.DataList.Tables[1].Rows[0]["WORK_DAY_COUNT"]).ToString("#,##0");
textEdit_HolidayCount.Text = resultData.DataList.Tables[0].Rows.Count.ToString("#,##0");
if (DateTime.Now.ToString("yyyy").Equals(comboBoxEdit_YY.Text))
{
monthCalendar_Main.SelectionStart = DateTime.Now;
monthCalendar_Main.SelectionEnd = DateTime.Now;
setDateInfo(DateTime.Now);
}
else
{
monthCalendar_Main.SelectionStart = monthCalendar_Main.MinDate;
monthCalendar_Main.SelectionEnd = monthCalendar_Main.MinDate;
setDateInfo(Convert.ToDateTime(comboBoxEdit_YY.Text + "-01-01"));
}
gridControl_Main.DataSource = resultData.DataList.Tables[2];
this.Cursor = Cursors.Arrow;
}
catch (Exception ex)
{
this.Cursor = Cursors.Arrow;
MessageBox.Show(ex.Message);
}
}
public override void excelProc()
{
this.ExportExcelGrid(gridControl_Main);
}
}
}