| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_TAT_0803.cs
- * 2.功能描述:出勤考核扣罚明细
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 任海 2014/12/16 1.00 新建
- *******************************************************************************/
- 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;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- using Dongke.IBOSS.PRD.WCF.DataModels;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
- using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
- namespace Dongke.IBOSS.PRD.Client.TATModule
- {
- /// <summary>
- /// 出勤考核扣罚明细
- /// </summary>
- public partial class F_TAT_0803 : FormBase
- {
- #region 成员变量
- // 窗体模式ID
- private Constant.FormMode _formType;
- // 操作实体ID
- private int? _entityId;
- // 主体工种ID
- private int? _JobsId;
- // 操作实体名称
- //private string _entityname;
- // 操作出勤考核实体
- private AttendanceEntity _attendanceEntity = new AttendanceEntity();
- // 操作出勤考核明细实体
- private AttendanceDetailEntity _attendanceDetailEntity = new AttendanceDetailEntity();
- // 选择窗体弹出标识
- //private bool _showFlag = true;
- // 数据源
- private DataSet _dsSourse;
- // 窗体加载完毕标识
- //private bool _pageLoadOK = false;
- #endregion
- #region 构造函数
- /// <summary>
- /// 窗体构造
- /// </summary>
- /// <param name="formType">窗体开启模式</param>
- /// <param name="entityId">操作实体ID</param>
- public F_TAT_0803(Constant.FormMode formType, int AttendanceID,
- int JobsId)
- {
- InitializeComponent();
- this._formType = formType;
- this._entityId = AttendanceID;
- this._JobsId = JobsId;
- this.btnSubmit.Text = ButtonText.BTN_SAVE;
- this.btnClose.Text = ButtonText.BTN_CANCEL;
- }
- #endregion
- #region 事件处理
- /// <summary>
- /// 窗体加载
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_TAT_0803_Load(object sender, EventArgs e)
- {
- try
- {
- this.WeekData();
- ///不自动创建列
- this.dgvPunishMode.AutoGenerateColumns = false;
- this.BindAttFinesRules();
- ///绑定主体信息
- this.BindPage();
- /// 加载控件
- this.Loading();
- if (this._formType == Constant.FormMode.CopyAndAdd)
- {
- this.dgvPunishMode.ReadOnly = true;
- this.dgvPunishMode.IsSetInputColumnsColor = false;
- this.dgvPunishMode.AllowUserToAddRows = false;
- }
- if (this._formType == Constant.FormMode.Display)
- {
- //列表设置为只读
- this.dgvPunishMode.ReadOnly = true;
- this.dgvPunishMode.IsSetInputColumnsColor = false;
- this.dgvPunishMode.AllowUserToAddRows = false;
- //控件除关闭外全部不可用
- this.txtday.Enabled = false;
- this.cbday.Enabled = false;
- this.cbWeek.Enabled = false;
- this.SelWeek.Enabled = false;
- this.cbPunishSetting.Enabled = false;
- this.cbBasicSalaryScale.Enabled = false;
- this.btnSubmit.Enabled = false;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 选中控件时休息天数控件不可用
- /// </summary>
- private void cbWeek_Click(object sender, EventArgs e)
- {
- this.SelWeek.Enabled = true;
- this.txtday.Enabled = false;
- }
- /// <summary>
- /// 选中控件时按星期控件不可用
- /// </summary>
- private void cbday_Click(object sender, EventArgs e)
- {
- this.txtday.Enabled = true;
- this.SelWeek.Enabled = false;
- }
- // <summary>
- /// 选中控件时表格不可用
- /// </summary>
- private void cbBasicSalaryScale_Click(object sender, EventArgs e)
- {
- try
- {
- this.dgvPunishMode.Enabled = false;
- this.dgvPunishMode.ReadOnly = true;
- this.dgvPunishMode.IsSetInputColumnsColor = false;
- DataTable dtCurrentTable = this.dgvPunishMode.DataSource as DataTable;
- if (dtCurrentTable != null)
- {
- foreach(DataRow r in dtCurrentTable.Rows)
- {
- r.Delete();
- }
- }
- this.dgvPunishMode.DataSource = dtCurrentTable;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 选中控件时表格可用
- /// </summary>
- private void cbPunishSetting_Click(object sender, EventArgs e)
- {
- this.dgvPunishMode.Enabled = true;
- this.dgvPunishMode.ReadOnly = false;
- this.dgvPunishMode.IsSetInputColumnsColor = true;
- }
- /// <summary>
- /// 提交操作
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnSubmit_Click(object sender, EventArgs e)
- {
- try
- {
- //获取页面值绑定属性
- this.BindEntity();
- DataTable datatPunishMode = (DataTable)this.dgvPunishMode.DataSource;
- int StartIndex = 1;
- if (datatPunishMode != null && datatPunishMode.Rows.Count > 0)
- {
- if (datatPunishMode.Rows[0].RowState != DataRowState.Deleted)
- StartIndex = Convert.ToInt32(datatPunishMode.Rows[0]["BeginAbsentDays"]);
- }
- bool isError = false;
- if (datatPunishMode != null)
- {
- foreach (DataRow drproductionData in datatPunishMode.Rows)
- {
- if (drproductionData.RowState != DataRowState.Deleted)
- {
- if (drproductionData["BeginAbsentDays"].ToString() == "" || drproductionData["EndAbsentDays"].ToString() == "")
- {
- isError = true;
- break;
- }
- if (Convert.ToInt32(drproductionData["BeginAbsentDays"]) != StartIndex)
- {
- isError = true;
- break;
- }
- int number = Convert.ToInt32(drproductionData["EndAbsentDays"]) - Convert.ToInt32(drproductionData["BeginAbsentDays"]);
- if (number < 0)
- {
- isError = true;
- break;
- }
- StartIndex = (Convert.ToInt32(drproductionData["EndAbsentDays"]) + 1);
- }
- }
- if (isError)
- {
- MessageBox.Show(string.Format("日期区间不能有间隔或重叠"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (this.dgvPunishMode.CurrentRow != null)
- {
- DataGridViewRow gvrNow = this.dgvPunishMode.CurrentRow;
- if (gvrNow.Cells["PunishAmount"].Value.ToString() == "")
- {
- // 单元格的错误消息
- MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "扣罚金额"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- }
- }
- //
- //DataSet ds = new DataSet();
- //ds.Tables.Add(datatPunishMode.Copy());
- //DataSet dss = _dsSourse;
- //提交操作
- ServiceResultEntity srEntity =
- (ServiceResultEntity)DoAsync(() =>
- {
- return TATModuleProxy.Service.EditAttendanceDetail(this._attendanceDetailEntity, _dsSourse);//_dsSourse
- });
- ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
- if (srEntity.Status == Constant.ServiceResultStatus.Success)
- {
- this.DialogResult = DialogResult.OK;
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 关闭窗体
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- #endregion
- #region 私有方法/函数
- /// <summary>
- /// 加载控件
- /// </summary>
- private void Loading()
- {
- //扣罚方式选中状态,判断表格是否可用
- if (this.cbBasicSalaryScale.Checked)
- {
- this.dgvPunishMode.Enabled = false;
- this.dgvPunishMode.ReadOnly = true;
- this.dgvPunishMode.IsSetInputColumnsColor = false;
- }
- else
- {
- this.dgvPunishMode.Enabled = true;
- this.dgvPunishMode.ReadOnly = false;
- this.dgvPunishMode.IsSetInputColumnsColor = true;
- }
- if (this.cbWeek.Checked)
- {
- this.SelWeek.Enabled = true;
- this.txtday.Enabled = false;
- }
- else
- {
- this.SelWeek.Enabled = false;
- this.txtday.Enabled = true;
- }
- }
- /// <summary>
- /// 绑定对应扣罚明细
- /// </summary>
- private void BindAttFinesRules()
- {
- try
- {
- //获取对应扣罚明细
- ServiceResultEntity srEntityDetail
- = TATModuleProxy.Service.GetAttFinesRulesById(Convert.ToInt32(this._entityId), Convert.ToInt32(this._JobsId));
- if (srEntityDetail.Data != null && srEntityDetail.Data.Tables.Count != 0)
- {
- this._dsSourse = srEntityDetail.Data;
- this.dgvPunishMode.DataSource = srEntityDetail.Data.Tables[0];
- this.dgvPunishMode.IsSetInputColumnsColor = true;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 绑定需要操作的实体信息
- /// </summary>
- private void BindPage()
- {
- try
- {
- if (this._entityId != 0 && this._entityId != null)
- {
- this._attendanceDetailEntity.AttendanceID = this._entityId;
- this._attendanceDetailEntity.JobsID = this._JobsId;
- //获取出勤考核明细
- ServiceResultEntity srEntity
- = TATModuleProxy.Service.GetAttendanceDetail(_attendanceDetailEntity);
- //如果取出了对应的数据
- if (srEntity.Data != null && srEntity.Data.Tables.Count != 0
- && srEntity.Data.Tables[0].Rows.Count != 0)
- {
- //为实体及页面相关赋值
- DataSet dsEntityData = (DataSet)srEntity.Data;
- DataRow drEntityRow = dsEntityData.Tables[0].Rows[0];
- this.txtday.Text = drEntityRow["RestDays"].ToString();
- int RestmMode = Convert.ToInt32(drEntityRow["RestmMode"]);
- this._attendanceDetailEntity.RestmMode = RestmMode;
- if (RestmMode == 1)
- {
- this.cbWeek.Checked = true;
- }
- else
- {
- this.cbday.Checked = true;
- }
- int PunishMode = Convert.ToInt32(drEntityRow["PunishMode"]);
- this._attendanceDetailEntity.PunishMode = PunishMode;
- if (PunishMode == 1)
- {
- this.cbBasicSalaryScale.Checked = true;
- }
- else
- {
- this.cbPunishSetting.Checked = true;
- }
- //绑定多选的选项
- object[] objec = new object[7];
- if (drEntityRow["Monday"].ToString() == "1")
- {
- objec[0] = 1;
- }
- else
- {
- objec[0] = 0;
- }
- if (drEntityRow["Tuesday"].ToString() == "1")
- {
- objec[1] = 2;
- }
- else
- {
- objec[1] = 0;
- }
- if (drEntityRow["Wednesday"].ToString() == "1")
- {
- objec[2] = 3;
- }
- else
- {
- objec[2] = 0;
- }
- if (drEntityRow["Thursday"].ToString() == "1")
- {
- objec[3] = 4;
- }
- else
- {
- objec[3] = 0;
- }
- if (drEntityRow["Friday"].ToString() == "1")
- {
- objec[4] = 5;
- }
- else
- {
- objec[4] = 0;
- }
- if (drEntityRow["Saturday"].ToString() == "1")
- {
- objec[5] = 6;
- }
- else
- {
- objec[5] = 0;
- }
- if (drEntityRow["Sunday"].ToString() == "1")
- {
- objec[6] = 7;
- }
- else
- {
- objec[6] = 0;
- }
- this.SelWeek.SelectedValues = objec;
- this._attendanceDetailEntity.OPTimeStamp = Convert.ToDateTime(drEntityRow["OPTimeStamp"]);
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 设置绑定星期信息
- /// </summary>
- private void WeekData()
- {
- DataTable dtWeek = new DataTable();
- dtWeek.Columns.Add("WeekName");
- dtWeek.Columns.Add("WeekValue");
- DataRow drWeekOne = dtWeek.NewRow();
- drWeekOne["WeekName"] = "星期一";
- drWeekOne["WeekValue"] = "1";
- dtWeek.Rows.Add(drWeekOne);
- DataRow drWeekTwo = dtWeek.NewRow();
- drWeekTwo["WeekName"] = "星期二";
- drWeekTwo["WeekValue"] = "2";
- dtWeek.Rows.Add(drWeekTwo);
- DataRow drWeekThree = dtWeek.NewRow();
- drWeekThree["WeekName"] = "星期三";
- drWeekThree["WeekValue"] = "3";
- dtWeek.Rows.Add(drWeekThree);
- DataRow drWeekfour = dtWeek.NewRow();
- drWeekfour["WeekName"] = "星期四";
- drWeekfour["WeekValue"] = "4";
- dtWeek.Rows.Add(drWeekfour);
- DataRow drWeekfive = dtWeek.NewRow();
- drWeekfive["WeekName"] = "星期五";
- drWeekfive["WeekValue"] = "5";
- dtWeek.Rows.Add(drWeekfive);
- DataRow drWeeksix = dtWeek.NewRow();
- drWeeksix["WeekName"] = "星期六";
- drWeeksix["WeekValue"] = "6";
- dtWeek.Rows.Add(drWeeksix);
- DataRow drWeekseven = dtWeek.NewRow();
- drWeekseven["WeekName"] = "星期日";
- drWeekseven["WeekValue"] = "7";
- dtWeek.Rows.Add(drWeekseven);
- this.SelWeek.DisplayMember = "WeekName";
- this.SelWeek.ValueMember = "WeekValue";
- this.SelWeek.DataSource = dtWeek;
- }
- /// <summary>
- /// 为实体绑定页面属性
- /// </summary>
- private void BindEntity()
- {
- this._attendanceDetailEntity.RestDays = Convert.ToInt32(this.txtday.Text);
- if (this.cbWeek.Checked)
- {
- this._attendanceDetailEntity.RestmMode = 1;
- }
- else
- {
- this._attendanceDetailEntity.RestmMode = 2;
- }
- if (this.cbBasicSalaryScale.Checked)
- {
- this._attendanceDetailEntity.PunishMode = 1;
- }
- else
- {
- this._attendanceDetailEntity.PunishMode = 2;
- }
- //绑定星期页面属性
- string[] sub = this.SelWeek.SelectedArray.Split(',');
- int Monday = 0;
- int Tuesday = 0;
- int Wednesday = 0;
- int Thursday = 0;
- int Friday = 0;
- int Saturday = 0;
- int Sunday = 0;
- if (sub.Length > 0)
- {
- for (int i = 0; i < sub.Length; i++)
- {
- switch (Convert.ToInt32(sub[i]))
- {
- case 1:
- Monday = 1;
- break;
- case 2:
- Tuesday = 1;
- break;
- case 3:
- Wednesday = 1;
- break;
- case 4:
- Thursday = 1;
- break;
- case 5:
- Friday = 1;
- break;
- case 6:
- Saturday = 1;
- break;
- case 7:
- Sunday = 1;
- break;
- }
- }
- }
- this._attendanceDetailEntity.Monday = Monday;
- this._attendanceDetailEntity.Tuesday = Tuesday;
- this._attendanceDetailEntity.Wednesday = Wednesday;
- this._attendanceDetailEntity.Thursday = Thursday;
- this._attendanceDetailEntity.Friday = Friday;
- this._attendanceDetailEntity.Saturday = Saturday;
- this._attendanceDetailEntity.Sunday = Sunday;
- }
- #endregion
- }
- }
|