123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376 |
- using LYFZ.BLL;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.OAShopManagement
- {
- public class frmRequestLeaveList : LYFZ.Software.UI.OAShopManagement.frmRequestLeaveList
- {
- /// <summary>
- /// 当前事项角色
- /// </summary>
- MattersApplyType currentMatterRole = MattersApplyType.申请人;
- /// <summary>
- /// 不当查询的审核状态
- /// </summary>
- state currentAuditStatus = state.申请中;
- public frmRequestLeaveList(string parameter)
- :this()
- {
- this.currentMatterRole = (MattersApplyType)Enum.Parse(typeof(MattersApplyType), parameter);
- }
- public frmRequestLeaveList() {
-
- //我要申请
- this.btnAddApplication.Click += btnAddTask_Click;
- //审批申请
- this.btnApproving.Click += btnApproving_Click;
- //删除申请
- this.btndel.Click += btndel_Click;
- //关闭
- this.btnClose.Click += btnClose_Click;
- //dgv事件
- this.dgvTaskView.CellDoubleClick += dgvTaskView_CellDoubleClick;
- // this.dgvTaskView.RowsAdded += dgvTaskView_RowsAdded;
- //加载事件
- this.Load += frmMattersApply_Load;
- this.ucMatt.EventPaging += ucMatt_EventPaging;
- this.btnAddApplication.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RequestLeave, CustomAttributes.OperatingAuthority.Add);
- this.btndel.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RequestLeave, CustomAttributes.OperatingAuthority.Delete);
- this.btnApproving.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RequestLeave, CustomAttributes.OperatingAuthority.Audit);
- this.ucMatt.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize;
- this.rdoapply.Click += RdoClick_Click;
- this.rdopassed.Click += RdoClick_Click;
- this.rdoNotpassed.Click += RdoClick_Click;
- }
-
- void RdoClick_Click(object sender, EventArgs e)
- {
- ComponentLibrary.RadioButtonEx rdoBtn = (ComponentLibrary.RadioButtonEx)sender;
- if (rdoBtn.Checked)
- {
- this.currentAuditStatus = (state)Convert.ToInt32(rdoBtn.Tag);
- }
- ucMatt.Bind();
- }
- //void dgvTaskView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
- //{
- // if (!string.IsNullOrEmpty(this.dgvTaskView.Rows[e.RowIndex].Cells["Column5"].Value.ToString().Trim()))
- // {
- // this.dgvTaskView.Rows[e.RowIndex].Cells["Column5"].Value = LYFZ.Command.Command_Validate.DateTimeToString(this.dgvTaskView.Rows[e.RowIndex].Cells["Column5"].Value, "yyyy-MM-dd HH:mm");
- // }
- //}
- string GetWhereString()
- {
- string whereStr = " 1=1 ";//"Matter_Type=1 ";
- if (currentMatterRole == MattersApplyType.申请人)
- {
- whereStr += " and Matter_CreateName='" + LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID.Trim() + "'";
- }
- else if(currentMatterRole == MattersApplyType.审核人){
- whereStr += " and Matter_UpdateName='" + LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID.Trim() + "'";
- }
- whereStr += " and Matter_state='" + this.currentAuditStatus.ToString().Trim() + "'";
-
- return whereStr;
- }
- public int ucMatt_EventPaging(UCPager.EventPagingArg e)
- {
-
- LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
- pageData.TableName = "tb_ErpShopEvententry";
- pageData.PageIndex = this.ucMatt.PageCurrent;
- pageData.PageSize = this.ucMatt.PageSize;
- pageData.QueryCondition = GetWhereString();
- pageData.QueryFieldName = " [ID]"
- +" ,[Matter_CreateName]"
- +" ,[Matter_CreateDatetime]"
- +" ,[Matter_content]"
- +" ,[Matter_state]"
- +" ,[Matter_UpdateName]"
- +" ,[Matter_UpdateDatetime]"
- +" ,[Matter_opinion]"
- +" ,[Matter_Type]"
- +" ,[Matter_Category]"
- +" ,[Matter_Title]"
- +" ,[Matter_StarLeaveTime]"
- +" ,[Matter_EndLeaveTime]"
- +" ,[Matter_LeadershipInstruction]"
- +" ,[Matter_InstructedPeople]"
- +" ,[Matter_InstructedTime] ";
- pageData.OrderStr = "ID desc";
- DataTable dt = null;
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- dt = pageData.QueryDataTable().Tables[0];
- });
- try
- {
- if (dt != null)
- {
- this.dgvTaskView.Rows.Clear();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- DataGridViewRow row = new DataGridViewRow();
- row.CreateCells(this.dgvTaskView);
- row.Tag = dt.Rows[i];
- row.Cells[0].Value = dt.Rows[i]["ID"].ToString();
- row.Cells[1].Value = LYFZ.BLL.WageStatisticsProcess.GetClassCodeToCalssName(dt.Rows[i]["Matter_Category"].ToString());
- string Matter_Title = "无主题";
- if (dt.Rows[i]["Matter_Title"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Matter_Title"].ToString().Trim()))
- {
- Matter_Title = dt.Rows[i]["Matter_Title"].ToString();
- }
- row.Cells[2].Value = Matter_Title;
- row.Cells[3].Value = dt.Rows[i]["Matter_content"].ToString();
- if (LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_StarLeaveTime"], "yyyy-MM-dd HH:mm") == "")
- {
- row.Cells[4].Value = "";
- }
- else
- {
- row.Cells[4].Value = "从【" + LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_StarLeaveTime"], "yyyy-MM-dd HH:mm")
- + "】至【"
- + LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_EndLeaveTime"], "yyyy-MM-dd HH:mm") + "】";
- }
- row.Cells[5].Value = UserIDToName(dt.Rows[i]["Matter_CreateName"]);
- row.Cells[5].Tag = dt.Rows[i]["Matter_CreateName"].ToString();
- row.Cells[6].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_CreateDatetime"], "yyyy-MM-dd HH:mm");
- row.Cells[7].Value = dt.Rows[i]["Matter_state"].ToString();
- row.Cells[8].Value = UserIDToName(dt.Rows[i]["Matter_UpdateName"]);
- row.Cells[8].Tag = dt.Rows[i]["Matter_UpdateName"].ToString();
- row.Cells[9].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_UpdateDatetime"], "yyyy-MM-dd HH:mm");
- if (dt.Rows[i]["Matter_opinion"] != null)
- {
- row.Cells[10].Value = dt.Rows[i]["Matter_opinion"].ToString();
- }
- if (dt.Rows[i]["Matter_LeadershipInstruction"] != null)
- {
- row.Cells[11].Value = dt.Rows[i]["Matter_LeadershipInstruction"].ToString();
- }
- if (dt.Rows[i]["Matter_InstructedPeople"] != null)
- {
- row.Cells[12].Value = UserIDToName(dt.Rows[i]["Matter_InstructedPeople"]);
- row.Cells[12].Tag = dt.Rows[i]["Matter_InstructedPeople"].ToString();
- }
- row.Cells[13].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_InstructedTime"], "yyyy-MM-dd HH:mm");
- this.dgvTaskView.Rows.Add(row);
- }
- this.ucMatt.TbDataSource = dt;
- }
- }
- catch (Exception ex){
- MessageBoxCustom.Show("加载数据出错:"+ex.Message);
- }
- return pageData.TotalCount;
- }
- string UserIDToName(object uid)
- {
- if (uid != null)
- {
- return UserIDToName(uid.ToString());
- }
- else {
- return "";
- }
- }
- public static string UserIDToName(string uid)
- {
- DataRow row = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(uid);
- if (row != null)
- {
- return row["User_Name"].ToString();
- }
- else {
- return "";
- }
- }
- //页面加载事件
- void frmMattersApply_Load(object sender, EventArgs e)
- {
- bool b;
- this.UcNavigationTool.LabTitle = "请假审批";
- switch (currentMatterRole)
- {
- case MattersApplyType.批示领导:
- this.tpMyApplication.Text = "请假审批管理";
- this.btnAddApplication.Visible = false;
- this.btnApproving.Visible = true;
- this.btndel.Visible = true;
- b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理请假申请管理);
- if (!b)
- {
- this.Close();
- return;
- }
- break;
- case MattersApplyType.申请人:
- this.UcNavigationTool.LabTitle = "请假申请";
- this.tpMyApplication.Text = "我的请假申请";
- this.btnAddApplication.Visible = true;
- this.btnApproving.Visible = false;
- this.btndel.Visible = true;
- b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理请假申请);
- if (!b)
- {
- this.Close();
- return;
- }
- break;
- case MattersApplyType.审核人:
- this.tpMyApplication.Text = "请假审批";
- this.btnAddApplication.Visible = false;
- this.btnApproving.Visible = true;
- this.btndel.Visible = false;
- b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理请假审批);
- if (!b)
- {
- this.Close();
- return;
- }
- break;
- }
- ucMatt.Bind();
- }
- /// <summary>
- /// 公共刷新方法
- /// </summary>
- public void refresh()
- {
- ucMatt.Bind();
- }
- //dgv双击事件
- void dgvTaskView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
- {
- if (this.currentMatterRole == MattersApplyType.申请人 && this.currentAuditStatus != state.申请通过)
- {
- if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
- {
- frmAddRequestLeave releaseApply = new frmAddRequestLeave();
- releaseApply.ID = this.dgvTaskView.CurrentRow.Cells["ID"].Value.ToString();
- if (releaseApply.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- ucMatt.Bind();
- }
- }
- }
- }
- //关闭
- void btnClose_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 删除事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btndel_Click(object sender, EventArgs e)
- {
- if (this.currentMatterRole == MattersApplyType.申请人 || this.currentMatterRole == MattersApplyType.批示领导)
- {
- if (this.currentMatterRole == MattersApplyType.申请人 && this.currentAuditStatus == state.申请通过)
- {
- MessageBoxCustom.Show("已通过申请事项不能删除");
- return;
- }
- if (this.dgvTaskView.SelectedRows != null && this.dgvTaskView.SelectedRows.Count > 0)
- {
- if (MessageBoxCustom.Show("是否删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
- {
- BLL_ErpShopEvententry bll = new BLL_ErpShopEvententry();
- bool ret = true;
- foreach (DataGridViewRow row in this.dgvTaskView.SelectedRows)
- {
- if (!bll.Delete(Convert.ToInt32(row.Cells["ID"].Value.ToString())))
- {
- ret = false;
- break;
- }
- }
- if (ret)
- {
- ucMatt.Bind();
- }
- else
- {
- MessageBoxCustom.Show("删除失败");
- }
- }
- }
- else
- { MessageBoxCustom.Show("请选中信息"); }
- }
- else
- {
- MessageBoxCustom.Show("审核人只能审核申请,不能删除申请");
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnApproving_Click(object sender, EventArgs e)
- {
- if (this.dgvTaskView.SelectedRows != null && this.dgvTaskView.SelectedRows.Count > 0)
- {
- frmRequestLeaveView applyView = new frmRequestLeaveView();
- applyView.ID = dgvTaskView.CurrentRow.Cells["ID"].Value.ToString();
- applyView.ApplyType = this.currentMatterRole;
- if (applyView.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- ucMatt.Bind();
- }
- }
- else
- {
- MessageBoxCustom.Show("请选择申请事项");
- }
- }
- /// <summary>
- /// 我要申请
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void btnAddTask_Click(object sender, EventArgs e)
- {
- frmAddRequestLeave releaseApply = new frmAddRequestLeave();
- if (releaseApply.ShowDialog() == System.Windows.Forms.DialogResult.OK)
- {
- ucMatt.Bind();
- }
- }
-
- }
- }
|