You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
200 lines
6.8 KiB
200 lines
6.8 KiB
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;
|
|
using System.Data.Sql;
|
|
using System.Data.SqlClient;
|
|
using ManagementSystem.Utility;
|
|
|
|
namespace ManagementSystem
|
|
{
|
|
public partial class DayOffEstimate : Form
|
|
{
|
|
//程式內共用物件
|
|
public string strFrmStatus = ""; //表單狀態
|
|
public string strPKey = ""; //程式內的Key值
|
|
string strKey = ""; //程式內加密的Key值
|
|
string strActiveUserID = ""; //取得登入作用的使用者帳號
|
|
string strAccountingBookID = ""; //取得作用中的帳本
|
|
SqlConnection sqlConn = UtilityClass.GetConn(MainForm.strAccountingBookID);
|
|
SqlTransaction sqlTran;
|
|
SqlDataAdapter sqlAdapter = new SqlDataAdapter();
|
|
SqlCommand sqlCmd = new SqlCommand();
|
|
DataSet sdInsurance = new System.Data.DataSet();
|
|
|
|
public DayOffEstimate()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region 自定義程式
|
|
private void StatusChange(string strStatus) //變更主畫面狀態
|
|
{
|
|
strActiveUserID = MainForm.strActiveUserID;
|
|
strAccountingBookID = MainForm.strAccountingBookID;
|
|
strKey = MainForm.strKey;
|
|
|
|
switch (strStatus.ToUpper())
|
|
{
|
|
case "NONE":
|
|
//本功能無None狀態
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "";
|
|
strFrmStatus = "";
|
|
CleanToolbar();
|
|
CleanForm();
|
|
LockForm();
|
|
tsbSearch.Enabled = true;
|
|
tsbOK.Visible = false;
|
|
tsbCancel.Visible = false;
|
|
break;
|
|
case "SEARCH":
|
|
//查詢功能
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "搜尋";
|
|
tsbSearch.Visible = false;
|
|
tsbOK.Visible = true;
|
|
tsbCancel.Visible = true;
|
|
UnLockForm();
|
|
break;
|
|
case "ADD":
|
|
//本程式無新增功能
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "新增";
|
|
strFrmStatus = "ADD";
|
|
break;
|
|
case "MODIFY":
|
|
//本程式無修改功能
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "修改";
|
|
strFrmStatus = "MODIFY";
|
|
break;
|
|
case "DEL":
|
|
//本程式無刪除功能
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "刪除";
|
|
strFrmStatus = "DEL";
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
private void GoEvent() //執行動作
|
|
{
|
|
CleanForm();
|
|
string strAskUser = "";
|
|
double dcLeaveCount = 0.0;
|
|
DateTime dtStartDate = DateTime.Now.AddMonths(-1).AddDays(-(DateTime.Now.AddMonths(-1).Day - 1));
|
|
DateTime dtEndDate = dtStartDate.AddDays(DateTime.DaysInMonth(DateTime.Now.AddMonths(-1).Year, DateTime.Now.AddMonths(-1).Month) - 1);
|
|
StringBuilder sbSQL = new StringBuilder();
|
|
sbSQL.Append("Select AskUser, LeaveDateStart, LeaveDateEnd, [Type],[dbo].OFN_SYS_ArgumentValueByArgumentID(Type,'LeaveType') AS TypeName ");
|
|
sbSQL.Append("From OTB_HR_AskLeave Where 1=1 ");
|
|
sbSQL.Append("And LeaveDateStart > Convert(datetime, '" + dtStartDate.ToShortDateString() + " 00:00:00AM') ");
|
|
sbSQL.Append("And LeaveDateStart < Convert(datetime, '" + dtEndDate.ToShortDateString() + " 12:59:59PM') ");
|
|
sbSQL.Append("Order by AskUser,LeaveDateStart ");
|
|
|
|
//本程式只有查詢結果
|
|
DataTable dtTemp = UtilityClass.GetSQLResult(sbSQL.ToString()).Tables["Result"];
|
|
|
|
foreach (DataRow drData in dtTemp.Rows)
|
|
{
|
|
if (strAskUser != "")
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
strAskUser = drData["AskUser"].ToString();
|
|
//應該計算的內容:起啟日期在上月日期區間中,計算至上月月底 + 結束日期在上月日期區間中,計算至上月月底
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void CleanToolbar() //清除工具列
|
|
{
|
|
//設定Toolbar狀態
|
|
tsbSearch.Visible = true;
|
|
tsbAdd.Visible = false;
|
|
tsbEdit.Visible = false;
|
|
tsbDelete.Visible = false;
|
|
tsbSave.Visible = false;
|
|
tsbOK.Visible = false;
|
|
tsbCancel.Visible = false;
|
|
}
|
|
|
|
private void LockForm() //鎖定物件
|
|
{
|
|
cbYear.Enabled = false;
|
|
cbMonth.Enabled = false;
|
|
}
|
|
|
|
private void UnLockForm() //物件解鎖
|
|
{
|
|
cbYear.Enabled = true;
|
|
cbMonth.Enabled = true;
|
|
}
|
|
|
|
private void CleanForm() //清除畫面
|
|
{
|
|
//設定畫面物件狀態
|
|
string strYear = DateTime.Now.AddMonths(-1).Year.ToString();
|
|
string strMonth = DateTime.Now.AddMonths(-1).Month.ToString();
|
|
cbYear.Items.Clear();
|
|
for (int intCount = DateTime.Now.Year; intCount >= DateTime.Now.AddYears(-4).Year; intCount--)
|
|
{
|
|
cbYear.Items.Add(intCount.ToString());
|
|
}
|
|
|
|
cbYear.SelectedItem = strYear;
|
|
cbMonth.SelectedItem = strMonth;
|
|
|
|
//清除GridView
|
|
dgvDayOffList.Columns.Clear();
|
|
}
|
|
#endregion
|
|
|
|
#region 事件觸發及問題處理
|
|
private void DayOffEstimate_Load(object sender, EventArgs e)
|
|
{
|
|
StatusChange("NONE");
|
|
}
|
|
|
|
private void tsbSearch_Click(object sender, EventArgs e)
|
|
{
|
|
CleanForm();
|
|
UnLockForm();
|
|
tsbOK.Visible = true;
|
|
tsbOK.Enabled = true;
|
|
tsbCancel.Visible = true;
|
|
tsbCancel.Enabled = true;
|
|
StatusChange("SEARCH");
|
|
}
|
|
|
|
private void tsbClean_Click(object sender, EventArgs e)
|
|
{
|
|
CleanForm();
|
|
}
|
|
|
|
private void tsbOK_Click(object sender, EventArgs e)
|
|
{
|
|
GoEvent();
|
|
StatusChange("NONE");
|
|
}
|
|
|
|
private void tsbCancel_Click(object sender, EventArgs e)
|
|
{
|
|
CleanToolbar();
|
|
CleanForm();
|
|
LockForm();
|
|
}
|
|
|
|
private void tsbExit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|