211 lines
8.5 KiB
C#
211 lines
8.5 KiB
C#
|
|
using BLL;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
namespace FineUIPro.Web.Customization.CNCCG.HSSE.Check
|
|
{
|
|
public partial class SafePersonWagesEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string SafePersonWagesId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["SafePersonWagesId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["SafePersonWagesId"] = value;
|
|
}
|
|
}
|
|
|
|
public string Userid
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Userid"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Userid"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
SafePersonWagesId = Request.Params["SafePersonWagesId"];
|
|
Userid = Request.Params["Userid"];
|
|
this.txtCheckDate.Text = DateTime.Now.ToString();
|
|
//加载群安员下拉
|
|
if (Userid == Const.sysglyId || Userid == Const.hfnbdId)
|
|
{
|
|
SafetyOfficerCheckPersonService.PersonInitMonth(drpAjy, "", true);
|
|
}
|
|
else
|
|
{
|
|
SafetyOfficerCheckPersonService.PersonInitMonth(drpAjy, CurrUser.LoginProjectId, true);
|
|
}
|
|
if (!string.IsNullOrEmpty(SafePersonWagesId)) {
|
|
Model.SafePersonWages model = Funs.DB.SafePersonWages.FirstOrDefault(x => x.SafePersonWagesId == SafePersonWagesId);
|
|
if (model!=null)
|
|
{
|
|
drpAjy.SelectedValue = model.SafetyOfficerCheckPersonId;
|
|
txtPayableAmount.Text = model.PayableAmount;
|
|
txtPaidAmount.Text = model.PayableAmount;
|
|
txtCheckDate.Text = model.CheckDate.ToString() ;
|
|
txtRemark.Text = model.Remark;
|
|
Model.SafetyOfficerCheckPerson Checkmodel = Funs.DB.SafetyOfficerCheckPerson.FirstOrDefault(x => x.SafetyOfficerCheckPersonId == model.SafetyOfficerCheckPersonId);
|
|
if (Checkmodel != null)
|
|
{
|
|
Model.Sys_User Umodel = Funs.DB.Sys_User.FirstOrDefault(x => x.UserId == Checkmodel.UserId);
|
|
if (Umodel != null)
|
|
{
|
|
txtIdentityCard.Text = Umodel.IdentityCard;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 选择群安员修改身份证
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpAjy_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
var PersonId = this.drpAjy.SelectedValue;
|
|
Model.SafetyOfficerCheckPerson model = Funs.DB.SafetyOfficerCheckPerson.FirstOrDefault(x => x.SafetyOfficerCheckPersonId == PersonId);
|
|
if (model!=null)
|
|
{
|
|
Model.Sys_User Umodel = Funs.DB.Sys_User.FirstOrDefault(x => x.UserId == model.UserId);
|
|
if (Umodel!=null)
|
|
{
|
|
txtIdentityCard.Text = Umodel.IdentityCard;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (drpAjy.SelectedValue == Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择群安员!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
Model.SafePersonWages model = new Model.SafePersonWages();
|
|
model.CheckDate =Convert.ToDateTime(txtCheckDate.Text);
|
|
model.SafetyOfficerCheckPersonId = drpAjy.SelectedValue;
|
|
model.PayableAmount = txtPayableAmount.Text.Trim(); ;
|
|
model.PaidAmount = txtPaidAmount.Text.Trim();
|
|
model.CheckMan = Userid;
|
|
model.Remark = txtRemark.Text;
|
|
|
|
if (!string.IsNullOrEmpty(SafePersonWagesId))
|
|
{
|
|
//判断该人员是否填写过月度报表
|
|
Model.SafePersonWages RepeatModel = Funs.DB.SafePersonWages.FirstOrDefault(x => x.SafePersonWagesId != SafePersonWagesId
|
|
&& x.SafetyOfficerCheckPersonId == drpAjy.SelectedValue && x.CheckDate.Value == Convert.ToDateTime(txtCheckDate.Text));
|
|
if (RepeatModel != null)
|
|
{
|
|
Alert.ShowInTop("该群安员当前月份已录入过工资!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
model.SafePersonWagesId = SafePersonWagesId;
|
|
SafePersonWagesService.Update(model);
|
|
}
|
|
else
|
|
{
|
|
|
|
Model.SafePersonWages RepeatModel = Funs.DB.SafePersonWages.FirstOrDefault(x =>x.SafetyOfficerCheckPersonId == drpAjy.SelectedValue
|
|
&& x.CheckDate.Value == Convert.ToDateTime(txtCheckDate.Text));
|
|
if (RepeatModel != null)
|
|
{
|
|
Alert.ShowInTop("该群安员当前月份已录入过工资!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
model.SafePersonWagesId = SQLHelper.GetNewID(typeof(Model.SafePersonWages));
|
|
SafePersonWagesService.Add(model);
|
|
}
|
|
|
|
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (drpAjy.SelectedValue == Const._Null)
|
|
{
|
|
Alert.ShowInTop("请选择群安员!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(this.SafePersonWagesId))
|
|
{
|
|
SaveData(BLL.Const.BtnSave);
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/SendAndAccepAttachUrl&menuId={1}", SafePersonWagesId, BLL.Const.SendAndAccepMenuId)));
|
|
}
|
|
|
|
private void SaveData(string type)
|
|
{
|
|
Model.SafePersonWages model = new Model.SafePersonWages();
|
|
model.CheckDate = Convert.ToDateTime(txtCheckDate.Text);
|
|
model.SafetyOfficerCheckPersonId = drpAjy.SelectedValue;
|
|
model.PayableAmount = txtPayableAmount.Text.Trim(); ;
|
|
model.PaidAmount = txtPaidAmount.Text.Trim();
|
|
model.CheckMan = Userid;
|
|
model.Remark = txtRemark.Text;
|
|
|
|
if (!string.IsNullOrEmpty(SafePersonWagesId))
|
|
{
|
|
//判断该人员是否填写过月度报表
|
|
Model.SafePersonWages RepeatModel = Funs.DB.SafePersonWages.FirstOrDefault(x => x.SafePersonWagesId != SafePersonWagesId
|
|
&& x.SafetyOfficerCheckPersonId == drpAjy.SelectedValue && x.CheckDate.Value == Convert.ToDateTime(txtCheckDate.Text));
|
|
if (RepeatModel != null)
|
|
{
|
|
Alert.ShowInTop("该群安员当前月份已录入过工资!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
model.SafePersonWagesId = SafePersonWagesId;
|
|
SafePersonWagesService.Update(model);
|
|
}
|
|
else
|
|
{
|
|
|
|
Model.SafePersonWages RepeatModel = Funs.DB.SafePersonWages.FirstOrDefault(x => x.SafetyOfficerCheckPersonId == drpAjy.SelectedValue
|
|
&& x.CheckDate.Value == Convert.ToDateTime(txtCheckDate.Text));
|
|
if (RepeatModel != null)
|
|
{
|
|
Alert.ShowInTop("该群安员当前月份已录入过工资!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
SafePersonWagesId= SQLHelper.GetNewID(typeof(Model.SafePersonWages));
|
|
model.SafePersonWagesId = SafePersonWagesId;
|
|
SafePersonWagesService.Add(model);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
} |