using LYFZ.BLL;
using LYFZ.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace LYFZ.Software.MainBusiness.OAShopManagement
{
public class frmRequestLeaveView : LYFZ.Software.UI.OAShopManagement.frmRequestLeaveView
{
public frmRequestLeaveView() {
this.btnClose.Click += btnClose_Click;
this.btnSave.Click += btnSave_Click;
this.Load += frmTeskView_Load;
if (LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RequestLeave, CustomAttributes.OperatingAuthority.Audit))
{ this.btnSave.Enabled = true; }
else
{ this.btnSave.Enabled = false; }
}
BLL_ErpShopEvententry Bll = new BLL_ErpShopEvententry();
string _id = "";
///
/// ID
///
public string ID { get { return this._id; } set { this._id = value; } }
Model_ErpShopEvententry model = new Model_ErpShopEvententry();
void frmTeskView_Load(object sender, EventArgs e)
{
comboBoxApplyState.ReadOnly = true;
if (!string.IsNullOrEmpty(this.ID))
{
model = Bll.GetModel(Convert.ToInt32(ID));
//申请人
this.labPriority.Text = frmMattersApply.UserIDToName(model.Matter_UpdateName);
this.lbCategory.Text = LYFZ.BLL.WageStatisticsProcess.GetClassCodeToCalssName(model.Matter_Category);
//申请时间
this.labReleaseDatetime.Text = model.Matter_CreateDatetime.ToString("yyyy-MM-dd HH:mm");
//申请内容
this.txtApplyInfo.Text = model.Matter_content;
//审批状态
this.comboBoxApplyState.SelectedText = model.Matter_state;
//审批人
this.labPostedby.Text = Bll.Name(model.Matter_UpdateName);
//审批意见
this.txtApplyReply.Text = model.Matter_opinion;
this.txtLeadershipInstruction.Text = model.Matter_LeadershipInstruction;
this.txtTitle.Text = model.Matter_Title;
this.lbRequestLeaveTiem.Text = "从【" + LYFZ.Command.Command_Validate.DateTimeToString(model.Matter_StarLeaveTime, "yyyy-MM-dd HH:mm")
+ "】至【"
+ LYFZ.Command.Command_Validate.DateTimeToString(model.Matter_EndLeaveTime, "yyyy-MM-dd HH:mm") + "】";
}
switch (_ApplyType)
{
case MattersApplyType.批示领导:
this.txtApplyReply.Enabled = false;
this.txtLeadershipInstruction.Enabled = true;
this.btnSave.Enabled = true;
break;
case MattersApplyType.申请人:
this.txtApplyReply.Enabled = false;
this.txtLeadershipInstruction.Enabled = false;
this.btnSave.Enabled = false;
break;
case MattersApplyType.审核人:
this.txtApplyReply.Enabled = true;
this.txtLeadershipInstruction.Enabled = false;
this.btnSave.Enabled = true;
break;
}
this.comboBoxApplyState.Items.Clear();
// this.comboBoxApplyState.Items.Add(state.申请中.ToString());
this.comboBoxApplyState.Items.Add(state.申请通过.ToString());
this.comboBoxApplyState.Items.Add(state.申请打回.ToString());
}
///
/// 审核按钮
///
///
///
void btnSave_Click(object sender, EventArgs e)
{
if (model.ID > 0)
{
if (_ApplyType == MattersApplyType.审核人)
{
if (string.IsNullOrEmpty(txtApplyReply.Text))
{
MessageBoxCustom.Show("请输入审批意见"); return;
}
if (txtApplyReply.Text.Trim().Length > 200)
{
MessageBoxCustom.Show("审批意见不能超过200个字"); return;
}
model.Matter_opinion = this.txtApplyReply.Text.Trim();
model.Matter_UpdateDatetime = SDateTime.Now;
model.Matter_UpdateName = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
}
else if (_ApplyType == MattersApplyType.批示领导)
{
if (string.IsNullOrEmpty(txtLeadershipInstruction.Text))
{
MessageBoxCustom.Show("请输入领导批示意见"); return;
}
if (txtLeadershipInstruction.Text.Trim().Length > 200)
{
MessageBoxCustom.Show("领导批示意见不能超过200个字"); return;
}
model.Matter_LeadershipInstruction = this.txtLeadershipInstruction.Text.Trim();
model.Matter_InstructedPeople = LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_EmployeeID;
model.Matter_InstructedTime = SDateTime.Now;
}
model.Matter_state = this.comboBoxApplyState.Text.Trim();
if (model.Matter_state == state.申请中.ToString())
{
MessageBoxCustom.Show("请选择审核状态"); return;
}
if (Bll.Update(model))
{
MessageBoxCustom.Show("审核成功");
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
else
{
MessageBoxCustom.Show("审核失败");
}
}
}
void btnClose_Click(object sender, EventArgs e)
{ this.Close(); }
MattersApplyType _ApplyType = MattersApplyType.申请人;
///
/// 操作人类型 申请,审核
///
internal MattersApplyType ApplyType
{
get { return _ApplyType; }
set { _ApplyType = value; }
}
}
}