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.
851 lines
32 KiB
851 lines
32 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.Sql;
|
|
using System.Data.SqlClient;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using ManagementSystem.Utility;
|
|
|
|
namespace ManagementSystem
|
|
{
|
|
public partial class HRMembers : Form
|
|
{
|
|
//程式內共用物件
|
|
string strFrmStatus = ""; //表單狀態
|
|
string strActiveUserID = ""; //取得登入作用的使用者帳號
|
|
SqlConnection sqlConn = UtilityClass.GetConn(MainForm.strAccountingBookID);
|
|
SqlCommand sqlCmd = new SqlCommand();
|
|
string strPKey = ""; //程式內的Key值
|
|
string strKey = ""; //程式內加密的Key值
|
|
|
|
public HRMembers()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
#region 自定義程式
|
|
private string CheckForm() //確認畫面必填欄位
|
|
{
|
|
string strResult = "";
|
|
if (txtSID.Text.Trim() == "")
|
|
{
|
|
strResult = "請輸入身份證字號";
|
|
txtSID.Focus();
|
|
}
|
|
if (cbHR_Class.SelectedValue.ToString().Trim() == "")
|
|
{
|
|
strResult = "請輸入人事類別";
|
|
cbHR_Class.Focus();
|
|
}
|
|
if (cbDepartments.SelectedValue.ToString().Trim() == "")
|
|
{
|
|
strResult = "請輸入所屬部門";
|
|
cbDepartments.Focus();
|
|
}
|
|
if (!UtilityClass.IsNumber(txtInsuranceSalary.Text.Trim()) & txtInsuranceSalary.Text.Trim() != "")
|
|
{
|
|
strResult = "只接受數值資料";
|
|
txtInsuranceSalary.Focus();
|
|
}
|
|
if (!UtilityClass.IsNumber(txtSalary.Text.Trim()) & txtSalary.Text.Trim() != "")
|
|
{
|
|
strResult = "只接受數值資料";
|
|
txtSalary.Focus();
|
|
}
|
|
if (!UtilityClass.IsNumber(txtBonus.Text.Trim()) & txtBonus.Text.Trim() != "")
|
|
{
|
|
strResult = "只接受數值資料";
|
|
txtBonus.Focus();
|
|
}
|
|
if (!UtilityClass.IsNumber(txtSubsidy.Text.Trim()) & txtSubsidy.Text.Trim() != "")
|
|
{
|
|
strResult = "只接受數值資料";
|
|
txtSubsidy.Focus();
|
|
}
|
|
return strResult;
|
|
}
|
|
|
|
private void SetupStatus() //畫面載入設定
|
|
{
|
|
try
|
|
{
|
|
strActiveUserID = MainForm.strActiveUserID;
|
|
strKey = MainForm.strKey;
|
|
|
|
if (MainForm.strKey == "")
|
|
{
|
|
//設定Toolbar初始狀態
|
|
tsbSave.Enabled = false;
|
|
tsbDelete.Enabled = false;
|
|
}
|
|
|
|
//設定畫面初始狀態
|
|
CleanForm();
|
|
CleanToolbar();
|
|
LockForm();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void GetMemberData(string strMemberID) //取得成員資料
|
|
{
|
|
try
|
|
{
|
|
string strInsuranceSalary = "";
|
|
string strSalary = "";
|
|
string strBonus = "";
|
|
string strSubsidy = "";
|
|
//排除空值
|
|
if (strMemberID.Trim() == "")
|
|
{
|
|
return;
|
|
}
|
|
if (strMemberID == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
strPKey = strMemberID;
|
|
|
|
StringBuilder strSQL = new StringBuilder("");
|
|
strSQL.Append("Select M.MemberID, H.[SID], M.MemberName, M.DepartmentID,H.InsuranceSalary,H.CountSalary ,H.Salary,H.Bonus,H.Subsidy,H.HR_Class,M.Effective,M.ArriveDate,H.InsuranceLevel,isnull(M.LeaveDate, dateadd(YEAR,10,getdate())) as LeaveDate, H.Modify_Date, H.Modify_User ");
|
|
strSQL.Append("From OTB_SYS_Members M Left Join OTB_HR_HRDetail H On M.MemberID = H.MemberID ");
|
|
strSQL.Append("Where M.MemberID = '" + strPKey + "'");
|
|
|
|
//進行查詢
|
|
DataTable dtTemp = (DataTable)UtilityClass.GetSQLResult(strSQL.ToString()).Tables["Result"];
|
|
|
|
//進行資料顯示
|
|
strInsuranceSalary = UtilityClass.DecryptDES(dtTemp.Rows[0]["InsuranceSalary"].ToString(),strKey);
|
|
strSalary = UtilityClass.DecryptDES(dtTemp.Rows[0]["Salary"].ToString(), strKey);
|
|
strBonus = UtilityClass.DecryptDES(dtTemp.Rows[0]["Bonus"].ToString(),strKey);
|
|
strSubsidy = UtilityClass.DecryptDES(dtTemp.Rows[0]["Subsidy"].ToString(), strKey);
|
|
|
|
txtMemberID.Text = dtTemp.Rows[0]["MemberID"].ToString();
|
|
txtSID.Text = dtTemp.Rows[0]["SID"].ToString();
|
|
txtMemberName.Text = dtTemp.Rows[0]["MemberName"].ToString();
|
|
cbCountSalary.Checked = dtTemp.Rows[0]["CountSalary"].ToString() == "Y" ? true : false;
|
|
txtInsuranceSalary.Text = UtilityClass.MarkNumber(strInsuranceSalary);
|
|
txtSalary.Text = UtilityClass.MarkNumber(strSalary);
|
|
txtBonus.Text = UtilityClass.MarkNumber(strBonus);
|
|
txtSubsidy.Text = UtilityClass.MarkNumber(strSubsidy);
|
|
cbDepartments.SelectedValue = dtTemp.Rows[0]["DepartmentID"].ToString();
|
|
cbHR_Class.SelectedValue = dtTemp.Rows[0]["HR_Class"].ToString();
|
|
txtEffective.Text = dtTemp.Rows[0]["Effective"].ToString();
|
|
dtpArriveDate.Text = dtTemp.Rows[0]["ArriveDate"].ToString();
|
|
dtpLeaveDate.Text = dtTemp.Rows[0]["LeaveDate"].ToString();
|
|
((MainForm)ParentForm).SsStatus.Items["tsslModifyUser"].Text = dtTemp.Rows[0]["Modify_User"].ToString().Trim();
|
|
((MainForm)ParentForm).SsStatus.Items["tsslModifyDate"].Text = dtTemp.Rows[0]["Modify_Date"].ToString().Trim();
|
|
txtInsuranceLevel.Text = dtTemp.Rows[0]["InsuranceLevel"].ToString();
|
|
txtC_HealthInsuranceAmount.Text = "";
|
|
txtS_HealthInsuranceAmount.Text = "";
|
|
txtC_LaborProtection.Text = "";
|
|
txtS_LaborProtection.Text = "";
|
|
txtS_LaborProtection.Text = "";
|
|
txtRetirementAmount.Text = "";
|
|
SetInsurance();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void LockForm() //限制唯讀物件
|
|
{
|
|
txtMemberID.ReadOnly = true;
|
|
txtSID.ReadOnly = true;
|
|
txtMemberName.ReadOnly = true;
|
|
cbCountSalary.Enabled = false;
|
|
txtInsuranceSalary.ReadOnly = true;
|
|
txtSalary.ReadOnly = true;
|
|
txtBonus.ReadOnly = true;
|
|
txtSubsidy.ReadOnly = true;
|
|
cbDepartments.Enabled = false;
|
|
cbHR_Class.Enabled = false;
|
|
txtEffective.ReadOnly = true;
|
|
txtInsuranceLevel.ReadOnly = true;
|
|
dtpArriveDate.Enabled = false;
|
|
dtpLeaveDate.Enabled = false;
|
|
}
|
|
|
|
private void UnLockForm() //解除限制唯讀物件
|
|
{
|
|
txtMemberID.ReadOnly = false;
|
|
txtSID.ReadOnly = false;
|
|
txtMemberName.ReadOnly = false;
|
|
cbCountSalary.Enabled = true;
|
|
txtInsuranceSalary.ReadOnly = false;
|
|
txtSalary.ReadOnly = false;
|
|
txtBonus.ReadOnly = false;
|
|
txtSubsidy.ReadOnly = false;
|
|
cbDepartments.Enabled = true;
|
|
cbHR_Class.Enabled = true;
|
|
txtEffective.ReadOnly = false;
|
|
txtInsuranceLevel.ReadOnly = false;
|
|
dtpArriveDate.Enabled = false;
|
|
dtpLeaveDate.Enabled = false;
|
|
}
|
|
|
|
private void StatusChange(string strStatus) //變更主畫面狀態
|
|
{
|
|
switch (strStatus.ToUpper())
|
|
{
|
|
case "NONE":
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "";
|
|
strFrmStatus = "";
|
|
CleanForm();
|
|
CleanToolbar();
|
|
dgvHRItem.ReadOnly = false;
|
|
break;
|
|
case "SEARCH":
|
|
tsbSearch.Visible = false;
|
|
tsbEdit.Enabled = false;
|
|
tsbDelete.Enabled = false;
|
|
tsbOK.Visible = true;
|
|
tsbCancel.Visible = true;
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "搜尋";
|
|
strFrmStatus = "SEARCH";
|
|
break;
|
|
case "ADD":
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "新增";
|
|
strFrmStatus = "ADD";
|
|
break;
|
|
case "MODIFY":
|
|
tsbSearch.Enabled = false;
|
|
tsbEdit.Visible = false;
|
|
tsbSave.Visible = true;
|
|
tsbDelete.Enabled = false;
|
|
tsbCancel.Visible = true;
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "修改";
|
|
strFrmStatus = "MODIFY";
|
|
break;
|
|
case "DEL":
|
|
tsbDelete.Visible = false;
|
|
tsbSearch.Enabled = false;
|
|
tsbEdit.Enabled = false;
|
|
((MainForm)ParentForm).SsStatus.Items["tsslStatus"].Text = "刪除";
|
|
strFrmStatus = "DEL";
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
private void CleanToolbar() //清除工具列
|
|
{
|
|
//設定Toolbar狀態
|
|
tsbSearch.Enabled = true;
|
|
tsbSearch.Visible = true;
|
|
tsbEdit.Enabled = true;
|
|
tsbEdit.Visible = true;
|
|
tsbDelete.Enabled = true;
|
|
tsbDelete.Visible = true;
|
|
tsbSave.Visible = false;
|
|
tsbOK.Visible = false;
|
|
tsbCancel.Visible = false;
|
|
}
|
|
|
|
private void CleanForm() //清除畫面
|
|
{
|
|
//設定部門資料
|
|
cbDepartments.DataSource = UtilityClass.GetOrganization().Tables[0];
|
|
cbDepartments.ValueMember = "DepartmentID";
|
|
cbDepartments.DisplayMember = "DepartmentName";
|
|
|
|
//設定人事類別
|
|
cbHR_Class.DataSource = UtilityClass.GetSystemArgument("HRClass", "zh-TW").Tables["Arguments"];
|
|
cbHR_Class.DisplayMember = "ArgumentValue";
|
|
cbHR_Class.ValueMember = "ArgumentID";
|
|
|
|
//清除GridView
|
|
string strSQL = "Select MemberID, MemberName, EMail From OTB_SYS_Members Where Effective='Y'";
|
|
dgvHRItem.DataSource = UtilityClass.GetSQLResult(strSQL).Tables["Result"];
|
|
|
|
//設定畫面物件狀態
|
|
txtMemberID.Text = "";
|
|
txtSID.Text = "";
|
|
txtMemberName.Text = "";
|
|
txtBonus.Text = "";
|
|
cbCountSalary.Checked = false;
|
|
txtInsuranceSalary.Text = "";
|
|
txtSalary.Text = "";
|
|
txtSubsidy.Text = "";
|
|
txtEffective.Text = "";
|
|
txtInsuranceLevel.Text = "";
|
|
txtC_HealthInsuranceAmount.Text = "";
|
|
txtS_HealthInsuranceAmount.Text = "";
|
|
txtC_LaborProtection.Text = "";
|
|
txtS_LaborProtection.Text = "";
|
|
txtS_LaborProtection.Text = "";
|
|
txtRetirementAmount.Text = "";
|
|
cbDepartments.SelectedIndex = 0;
|
|
cbHR_Class.SelectedIndex = 0;
|
|
dtpLeaveDate.Value = DateTime.Now.AddYears(10);
|
|
|
|
Application.DoEvents();
|
|
}
|
|
|
|
private void AddEven() //新增事件
|
|
{
|
|
try
|
|
{
|
|
//本功能無新增功能
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
|
|
}
|
|
}
|
|
|
|
private void SaveEven() //儲存事件
|
|
{
|
|
//物件宣告
|
|
string strInsuranceSalary = "";
|
|
string strSalary = "";
|
|
string strBonus = "";
|
|
string strSubSidy = "";
|
|
|
|
try
|
|
{
|
|
switch (strFrmStatus.ToString())
|
|
{
|
|
case "ADD": //新增(本功能不含新增功能)
|
|
break;
|
|
case "MODIFY": //修改
|
|
StringBuilder sbSQL = new StringBuilder();
|
|
StringBuilder sbCheckExsit = new StringBuilder();
|
|
//確認資料是否存在
|
|
sbCheckExsit.Append("Select * From OTB_HR_HRDetail Where MemberID = '" + strPKey + "'");
|
|
if (UtilityClass.IsExist(sbCheckExsit.ToString()))
|
|
{
|
|
//資料存在,執行Update命令
|
|
//執行命令
|
|
sbSQL.Append("Update OTB_HR_HRDetail Set ");
|
|
sbSQL.Append(" [SID] =@SID,");
|
|
sbSQL.Append(" HR_Class = @HR_Class,");
|
|
sbSQL.Append(" CountSalary = @CountSalary,");
|
|
sbSQL.Append(" InsuranceSalary = @InsuranceSalary,");
|
|
sbSQL.Append(" Salary = @Salary,");
|
|
sbSQL.Append(" Bonus = @Bonus,");
|
|
sbSQL.Append(" SubSidy = @SubSidy,");
|
|
sbSQL.Append(" InsuranceLevel = @InsuranceLevel,");
|
|
sbSQL.Append(" Modify_Date = GETDATE(), ");
|
|
sbSQL.Append(" Modify_User = @Modify_User ");
|
|
sbSQL.Append("Where MemberID = @MemberID");
|
|
using (SqlDataAdapter sqlAdapter = new SqlDataAdapter())
|
|
{
|
|
//物件處理
|
|
strInsuranceSalary = txtInsuranceSalary.Text.Trim().Replace(",", "");
|
|
strSalary = txtSalary.Text.Trim().Replace(",","");
|
|
strBonus = txtBonus.Text.Trim().Replace(",","");
|
|
strSubSidy = txtSubsidy.Text.Trim().Replace(",","");
|
|
|
|
//添加參數
|
|
sqlAdapter.UpdateCommand = new SqlCommand();
|
|
sqlAdapter.UpdateCommand.Connection = sqlConn;
|
|
sqlAdapter.UpdateCommand.CommandText = sbSQL.ToString();
|
|
sqlAdapter.UpdateCommand.Parameters.AddRange
|
|
(
|
|
new SqlParameter[]
|
|
{
|
|
new SqlParameter("@MemberID",txtMemberID.Text.Trim()),
|
|
new SqlParameter("@SID",txtSID.Text.Trim()),
|
|
new SqlParameter("@HR_Class",cbHR_Class.SelectedValue.ToString()),
|
|
new SqlParameter("@CountSalary",cbCountSalary.Checked ? "Y" : "N"),
|
|
new SqlParameter("@InsuranceSalary",UtilityClass.EncryptDES(strInsuranceSalary,strKey)),
|
|
new SqlParameter("@Salary",UtilityClass.EncryptDES(strSalary,strKey)),
|
|
new SqlParameter("@Bonus",UtilityClass.EncryptDES(strBonus,strKey)),
|
|
new SqlParameter("@SubSidy",UtilityClass.EncryptDES(strSubSidy,strKey)),
|
|
new SqlParameter("@InsuranceLevel",Convert.ToInt32(txtInsuranceLevel.Text.Trim())),
|
|
new SqlParameter("@Modify_User",strActiveUserID.ToString())
|
|
}
|
|
);
|
|
|
|
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
|
|
{
|
|
sqlConn.Open();
|
|
}
|
|
|
|
sqlAdapter.UpdateCommand.ExecuteNonQuery();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//資料不存在,執行Insert命令
|
|
//執行命令
|
|
sbSQL.Append("Insert Into OTB_HR_HRDetail(MemberID, SID, HR_Class, CountSalary,InsuranceSalary, Salary, Bonus, SubSidy, InsuranceLevel, Create_Date, Create_User, Modify_Date, Modify_User) ");
|
|
sbSQL.Append("Values(@MemberID, @SID, @HR_Class, @CountSalary,@InsuranceSalary, @Salary, @Bonus, @SubSidy, @InsuranceLevel, Getdate(), @Create_User, Getdate(), @Create_User)");
|
|
using (SqlDataAdapter sqlAdapter = new SqlDataAdapter())
|
|
{
|
|
//物件處理
|
|
strInsuranceSalary = txtInsuranceSalary.Text.Trim().Replace(",", "");
|
|
strSalary = txtSalary.Text.Trim().Replace(",", "");
|
|
strBonus = txtBonus.Text.Trim().Replace(",", "");
|
|
strSubSidy = txtSubsidy.Text.Trim().Replace(",", "");
|
|
|
|
//添加參數
|
|
sqlAdapter.InsertCommand = new SqlCommand();
|
|
sqlAdapter.InsertCommand.Connection = sqlConn;
|
|
sqlAdapter.InsertCommand.CommandText = sbSQL.ToString();
|
|
sqlAdapter.InsertCommand.Parameters.AddRange
|
|
(
|
|
new SqlParameter[]
|
|
{
|
|
new SqlParameter("@MemberID",txtMemberID.Text.Trim()),
|
|
new SqlParameter("@SID",txtSID.Text.Trim()),
|
|
new SqlParameter("@HR_Class",cbHR_Class.SelectedValue.ToString()),
|
|
new SqlParameter("@CountSalary",cbCountSalary.Checked ? "Y" : "N"),
|
|
new SqlParameter("@InsuranceSalary",UtilityClass.EncryptDES(strInsuranceSalary,strKey)),
|
|
new SqlParameter("@Salary",UtilityClass.EncryptDES(strSalary,strKey)),
|
|
new SqlParameter("@Bonus",UtilityClass.EncryptDES(strBonus,strKey)),
|
|
new SqlParameter("@SubSidy",UtilityClass.EncryptDES(strSubSidy,strKey)),
|
|
new SqlParameter("@InsuranceLevel",Convert.ToInt32(txtInsuranceLevel.Text.Trim())),
|
|
new SqlParameter("@Create_User",strActiveUserID.ToString())
|
|
}
|
|
);
|
|
|
|
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
|
|
{
|
|
sqlConn.Open();
|
|
}
|
|
|
|
sqlAdapter.InsertCommand.ExecuteNonQuery();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
MessageBox.Show("儲存成功", "提示");
|
|
dgvHRItem.ReadOnly = false;
|
|
StatusChange("None");
|
|
LockForm();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("儲存失敗","提示");
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void DelEven() //刪除事件
|
|
{
|
|
StringBuilder sbSQL = new StringBuilder();
|
|
try
|
|
{
|
|
//執行Delete命令
|
|
//執行命令
|
|
sbSQL.Append("Delete OTB_HR_HRDetail Where MemberID = @MemberID");
|
|
|
|
using (SqlConnection sqlConn = UtilityClass.GetConn(MainForm.strAccountingBookID))
|
|
{
|
|
using (SqlDataAdapter sqlAdapter = new SqlDataAdapter())
|
|
{
|
|
//添加參數
|
|
sqlAdapter.DeleteCommand = new SqlCommand();
|
|
sqlAdapter.DeleteCommand.Connection = sqlConn;
|
|
sqlAdapter.DeleteCommand.CommandText = sbSQL.ToString();
|
|
sqlAdapter.DeleteCommand.Parameters.AddRange
|
|
(
|
|
new SqlParameter[]
|
|
{
|
|
new SqlParameter("@MemberID",txtMemberID.Text.Trim()),
|
|
}
|
|
);
|
|
|
|
if (sqlConn.State == ConnectionState.Closed) //判斷連線狀態
|
|
{
|
|
sqlConn.Open();
|
|
}
|
|
|
|
sqlAdapter.DeleteCommand.ExecuteNonQuery();
|
|
GetMemberData(txtMemberID.Text.Trim()); //顯示該帳號的值到畫面上
|
|
|
|
}
|
|
}
|
|
|
|
StatusChange("None");
|
|
LockForm();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void GoEvent() //執行事件
|
|
{
|
|
try
|
|
{
|
|
StringBuilder strSQL = new StringBuilder("");
|
|
switch (strFrmStatus.ToString())
|
|
{
|
|
case "SEARCH": //搜尋
|
|
strSQL.Append("Select M.MemberID, M.MemberName, M.Email ");
|
|
strSQL.Append("From OTB_SYS_Members M Left Join OTB_HR_HRDetail H On M.MemberID = H.MemberID ");
|
|
strSQL.Append("Where 1 = 1 ");
|
|
if (txtMemberID.Text.Trim() != "") //人員帳號
|
|
{
|
|
strSQL.Append("And M.MemberID like '" + txtMemberID.Text.Trim() + "' ");
|
|
}
|
|
if (txtSID.Text.Trim() != "") //身份證字號
|
|
{
|
|
strSQL.Append("And H.SID like '" + txtSID.Text.Trim() + "' ");
|
|
}
|
|
if (txtMemberName.Text.Trim() != "") //人員姓名
|
|
{
|
|
strSQL.Append("And M.MemberName like '" + txtMemberName.Text.Trim() + "' ");
|
|
}
|
|
if (cbHR_Class.SelectedValue != null)
|
|
{
|
|
if (cbHR_Class.SelectedValue.ToString().Trim() != "")
|
|
{
|
|
strSQL.Append("And H.HR_Class = '" + cbHR_Class.SelectedValue.ToString() + "' ");
|
|
}
|
|
}
|
|
if (txtEffective.Text.Trim() != "") //在職狀態
|
|
{
|
|
strSQL.Append("And M.Effective = '" + txtEffective.Text.Trim() + "' ");
|
|
}
|
|
if (cbDepartments.SelectedValue != null) //部門資料
|
|
{
|
|
if (cbDepartments.SelectedValue.ToString() != "")
|
|
{
|
|
strSQL.Append("And M.DepartmentID = '" + cbDepartments.SelectedValue.ToString() + "' ");
|
|
}
|
|
}
|
|
|
|
//進行查詢
|
|
dgvHRItem.DataSource = UtilityClass.GetSQLResult(strSQL.ToString()).Tables[0];
|
|
break;
|
|
|
|
}
|
|
StatusChange("None");
|
|
LockForm();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void SetInsurance() //取得勞、健保及勞退資料
|
|
{
|
|
try
|
|
{
|
|
string strInsuranceSalary = txtInsuranceSalary.Text.Trim().Replace(",","");
|
|
string strInsruanceLevel = txtInsuranceLevel.Text.Trim();
|
|
string[] strInsurances = new string[6];
|
|
if (strInsruanceLevel != "")
|
|
{
|
|
if (UtilityClass.IsNumber(strInsruanceLevel))
|
|
{
|
|
strInsurances = UtilityClass.GetInsuranceByLevel(strInsruanceLevel);
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (UtilityClass.IsNumber(strInsuranceSalary) & (strInsuranceSalary != ""))
|
|
{
|
|
strInsurances = UtilityClass.GetInsurance(strInsuranceSalary);
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
txtInsuranceLevel.Text = UtilityClass.MarkNumber(strInsurances[0]); //投保級距
|
|
txtC_LaborProtection.Text = UtilityClass.MarkNumber(strInsurances[1]); //公司提列勞保
|
|
txtS_LaborProtection.Text = UtilityClass.MarkNumber(strInsurances[2]); //自行提列勞保
|
|
txtC_HealthInsuranceAmount.Text = UtilityClass.MarkNumber(strInsurances[3]); //公司提列健保
|
|
txtS_HealthInsuranceAmount.Text = UtilityClass.MarkNumber(strInsurances[4]); //自行提列健保
|
|
txtRetirementAmount.Text = UtilityClass.MarkNumber(strInsurances[5]); //勞退金
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 事件觸發及問題處理
|
|
private void tsbAdd_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
CleanToolbar();
|
|
tsbSearch.Enabled = false;
|
|
tsbEdit.Enabled = false;
|
|
tsbSave.Visible = true;
|
|
CleanForm();
|
|
UnLockForm();
|
|
StatusChange("ADD");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void tsbEdit_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (strPKey == "")
|
|
{
|
|
MessageBox.Show("請先選擇資料", "提示");
|
|
return;
|
|
}
|
|
CleanToolbar();
|
|
UnLockForm();
|
|
txtMemberID.ReadOnly = true;
|
|
txtMemberName.ReadOnly = true;
|
|
cbDepartments.Enabled = false;
|
|
txtEffective.ReadOnly = true;
|
|
dtpArriveDate.Enabled = false;
|
|
dtpLeaveDate.Enabled = false;
|
|
dgvHRItem.ReadOnly = true;
|
|
txtSID.Focus();
|
|
StatusChange("Modify");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void tsbSave_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string strMessage = CheckForm();
|
|
if (strMessage == "")
|
|
{
|
|
this.SaveEven();
|
|
GetMemberData(strPKey);
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show(strMessage,"提示");
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void tsbDelete_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (MessageBox.Show("請問您確定要刪除本資料?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
|
|
{
|
|
this.DelEven();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void tsbSearch_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
//設定Toolbar狀態
|
|
CleanToolbar();
|
|
|
|
//開放查詢條件
|
|
UnLockForm();
|
|
|
|
//設定畫面物件狀態
|
|
CleanForm();
|
|
txtMemberID.Focus();
|
|
|
|
StatusChange("Search");
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void tsbOK_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
GoEvent();
|
|
|
|
//還原Toolbar狀態
|
|
tsbSearch.Enabled = true;
|
|
tsbOK.Visible = false;
|
|
|
|
//關閉查詢條件
|
|
LockForm();
|
|
StatusChange("Search");
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ErrorHandler.WriteErrorLog("HRMembers.cs", ex);
|
|
}
|
|
}
|
|
|
|
private void tsbCancel_Click(object sender, EventArgs e)
|
|
{
|
|
CleanForm();
|
|
CleanToolbar();
|
|
LockForm();
|
|
StatusChange("None");
|
|
}
|
|
|
|
private void HRMembers_Load(object sender, EventArgs e)
|
|
{
|
|
SetupStatus(); //設定畫面狀態
|
|
}
|
|
|
|
private void dgvHRItem_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
GetMemberData(dgvHRItem.CurrentRow.Cells[0].Value.ToString()); //顯示該帳號的值到畫面上
|
|
}
|
|
|
|
private void dgvHRItem_CellEnter(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
GetMemberData(dgvHRItem.CurrentRow.Cells[0].Value.ToString()); //顯示該帳號的值到畫面上
|
|
}
|
|
|
|
private void txtSID_Leave(object sender, EventArgs e)
|
|
{
|
|
txtSID.Text = txtSID.Text.ToUpper();
|
|
}
|
|
|
|
private void txtEffective_Leave(object sender, EventArgs e)
|
|
{
|
|
txtEffective.Text = txtEffective.Text.ToUpper();
|
|
}
|
|
|
|
private void tsbExit_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
private void txtSalary_Leave(object sender, EventArgs e)
|
|
{
|
|
txtSalary.Text = UtilityClass.MarkNumber(txtSalary.Text.Trim());
|
|
}
|
|
|
|
private void txtSalary_Enter(object sender, EventArgs e)
|
|
{
|
|
txtSalary.Text = txtSalary.Text.Replace(",", "");
|
|
}
|
|
|
|
private void txtBonus_Enter(object sender, EventArgs e)
|
|
{
|
|
txtBonus.Text = txtBonus.Text.Replace(",", "");
|
|
}
|
|
|
|
private void txtBonus_Leave(object sender, EventArgs e)
|
|
{
|
|
txtBonus.Text = UtilityClass.MarkNumber(txtBonus.Text.Trim());
|
|
}
|
|
|
|
private void txtSubsidy_Enter(object sender, EventArgs e)
|
|
{
|
|
txtSubsidy.Text = txtSubsidy.Text.Replace(",", "");
|
|
}
|
|
|
|
private void txtSubsidy_Leave(object sender, EventArgs e)
|
|
{
|
|
txtSubsidy.Text = UtilityClass.MarkNumber(txtSubsidy.Text.Trim());
|
|
}
|
|
|
|
private void txtInsuranceSalary_Leave(object sender, EventArgs e)
|
|
{
|
|
if ((strFrmStatus == "MODIFY" | strFrmStatus == "ADD") & txtInsuranceSalary.Text.Trim() != "")
|
|
{
|
|
SetInsurance();
|
|
}
|
|
txtInsuranceSalary.Text = UtilityClass.MarkNumber(txtInsuranceSalary.Text.Trim());
|
|
}
|
|
|
|
private void txtInsuranceSalary_Enter(object sender, EventArgs e)
|
|
{
|
|
txtInsuranceSalary.Text = txtInsuranceSalary.Text.Replace(",", "");
|
|
}
|
|
|
|
private void tsbClean_Click(object sender, EventArgs e)
|
|
{
|
|
CleanForm();
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|