人员考试
This commit is contained in:
@@ -0,0 +1,228 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.HSSE.SitePerson
|
||||
{
|
||||
public partial class PersonAskForLeaveEdit : PageBase
|
||||
{
|
||||
#region 定义项
|
||||
/// <summary>
|
||||
/// 项目主键
|
||||
/// </summary>
|
||||
public string LeaveId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["LeaveId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["LeaveId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string UnitId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["UnitId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["UnitId"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
///区域下拉框
|
||||
UnitService.InitUnitDropDownList(this.drpUnit, this.CurrUser.LoginProjectId, true);
|
||||
if (ProjectUnitService.GetProjectUnitTypeByProjectIdUnitId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId))
|
||||
{
|
||||
this.drpUnit.SelectedValue = this.CurrUser.UnitId;
|
||||
this.drpUnit.Enabled = false;
|
||||
}
|
||||
BindGrid(string.Empty);
|
||||
LeaveId = Request.Params["LeaveId"];
|
||||
|
||||
if (!string.IsNullOrEmpty(LeaveId))
|
||||
{
|
||||
var getData = Funs.DB.SitePerson_AskForLeave.FirstOrDefault(x=>x.LeaveId== LeaveId);
|
||||
if (getData != null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(getData.PersonId))
|
||||
{
|
||||
BindGrid(getData.PersonId);
|
||||
this.drpPersonId.Value = getData.PersonId;
|
||||
}
|
||||
this.txtRemark.Text = getData.Remark;
|
||||
this.txtReason.Text = getData.Reason;
|
||||
this.dpDateA.Text = string.Format("{0:yyyy-MM-dd HH:mm}", getData.DateA);
|
||||
this.dpDateZ.Text = string.Format("{0:yyyy-MM-dd HH:mm}", getData.DateZ);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dpDateA.Text = string.Format("{0:yyyy-MM-dd HH:mm}", DateTime.Now);
|
||||
this.dpDateZ.Text = string.Format("{0:yyyy-MM-dd HH:mm}", DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region DropDownList下拉选择事件
|
||||
/// <summary>
|
||||
/// 人员下拉框选择
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void drpPersonId_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(this.drpPersonId.Value))
|
||||
{
|
||||
|
||||
var person = BLL.PersonService.GetPersonById(this.drpPersonId.Value);
|
||||
if (person != null)
|
||||
{
|
||||
UnitId = person.UnitId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 绑定数据
|
||||
/// <summary>
|
||||
/// 下拉框查询
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.BindGrid(string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindGrid(string personId)
|
||||
{
|
||||
string strSql = @"SELECT Person.PersonId,Person.CardNo,Person.PersonName,Person.IdentityCard,Person.UnitId,Person.WorkPostId,Unit.UnitName,WorkPost.WorkPostName "
|
||||
+ @" FROM SitePerson_Person AS Person "
|
||||
+ @" LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = Person.UnitId "
|
||||
+ @" LEFT JOIN Base_WorkPost AS WorkPost ON WorkPost.WorkPostId = Person.WorkPostId "
|
||||
+@" WHERE IsUsed =1 AND (OutTime IS NULL OR OutTime > GETDATE()) AND ProjectId='" + this.CurrUser.LoginProjectId + "'";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
//if (!string.IsNullOrEmpty(this.txtCardNo.Text.Trim()))
|
||||
//{
|
||||
// strSql += " AND Person.CardNo LIKE @CardNo";
|
||||
// listStr.Add(new SqlParameter("@CardNo", "%" + this.txtCardNo.Text.Trim() + "%"));
|
||||
//}
|
||||
if (this.drpUnit.SelectedValue != Const._Null)
|
||||
{
|
||||
strSql += " AND Person.UnitId = @UnitId";
|
||||
listStr.Add(new SqlParameter("@UnitId", this.drpUnit.SelectedValue));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtPersonName.Text.Trim()))
|
||||
{
|
||||
strSql += " AND Person.PersonName LIKE @PersonName";
|
||||
listStr.Add(new SqlParameter("@PersonName", "%" + this.txtPersonName.Text.Trim() + "%"));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtIdentityCard.Text.Trim()))
|
||||
{
|
||||
strSql += " AND Person.IdentityCard LIKE @IdentityCard";
|
||||
listStr.Add(new SqlParameter("@IdentityCard", "%" + this.txtIdentityCard.Text.Trim() + "%"));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(personId))
|
||||
{
|
||||
strSql += " AND Person.PersonId = @PersonId";
|
||||
listStr.Add(new SqlParameter("@PersonId", personId));
|
||||
}
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存
|
||||
/// <summary>
|
||||
/// 保存按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.drpPersonId.Value))
|
||||
{
|
||||
ShowNotify("请选择人员!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
Model.SitePerson_AskForLeave newPersonInfo = null;
|
||||
if (!string.IsNullOrEmpty(LeaveId))
|
||||
{
|
||||
newPersonInfo = Funs.DB.SitePerson_AskForLeave.FirstOrDefault(x => x.LeaveId == LeaveId);
|
||||
}
|
||||
else
|
||||
{
|
||||
newPersonInfo = new Model.SitePerson_AskForLeave
|
||||
{
|
||||
PersonId = this.drpPersonId.Value,
|
||||
ProjectId = this.CurrUser.LoginProjectId,
|
||||
Reason = this.txtReason.Text.Trim(),
|
||||
Remark = this.txtRemark.Text.Trim()
|
||||
};
|
||||
}
|
||||
var person = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.PersonId == this.drpPersonId.Value);
|
||||
if (person != null)
|
||||
{
|
||||
newPersonInfo.UnitId = person.UnitId;
|
||||
newPersonInfo.PersonName = person.PersonName;
|
||||
|
||||
}
|
||||
|
||||
newPersonInfo.DateA = Funs.GetNewDateTimeOrNow(dpDateA.Text + ":00");
|
||||
newPersonInfo.DateZ = Funs.GetNewDateTimeOrNow(dpDateZ.Text + ":00");
|
||||
newPersonInfo.Reason= this.txtReason.Text.Trim();
|
||||
newPersonInfo.Remark= this.txtRemark.Text.Trim();
|
||||
newPersonInfo.CreateMan = this.CurrUser.UserId;
|
||||
newPersonInfo.CreateDate = DateTime.Now;
|
||||
if (string.IsNullOrEmpty(LeaveId))
|
||||
{
|
||||
newPersonInfo.LeaveId = Guid.NewGuid().ToString();
|
||||
Funs.DB.SitePerson_AskForLeave.InsertOnSubmit(newPersonInfo);
|
||||
}
|
||||
|
||||
Funs.DB.SubmitChanges();
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, newPersonInfo.PersonId, newPersonInfo.PersonId, BLL.Const.PersonAskForLeaveListMenuId, BLL.Const.BtnDelete);
|
||||
|
||||
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user