岗位培训
This commit is contained in:
@@ -0,0 +1,236 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Web.Security;
|
||||
|
||||
namespace FineUIPro.Web.HSSE.PostTraining
|
||||
{
|
||||
public partial class SelectPerson : PageBase
|
||||
{
|
||||
#region 定义项
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string RecordId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["RecordId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["RecordId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// GV被选择项列表
|
||||
///// </summary>
|
||||
//public List<string> ItemSelectedList
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return (List<string>)ViewState["ItemSelectedList"];
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// ViewState["ItemSelectedList"] = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 项目id
|
||||
/// </summary>
|
||||
public string ProjectId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["ProjectId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ProjectId"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 页面加载
|
||||
/// <summary>
|
||||
/// 页面加载
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.ProjectId)
|
||||
{
|
||||
this.ProjectId = Request.Params["projectId"];
|
||||
}
|
||||
//单位
|
||||
BLL.UnitService.InitUnitDropDownList(this.drpUnit, this.ProjectId, true);
|
||||
this.RecordId = Request.Params["RecordId"];
|
||||
// 绑定表格
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 保存
|
||||
/// <summary>
|
||||
/// 保存
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||||
{
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
//var sss = Grid1;
|
||||
//var item = Grid1.Rows[rowIndex];
|
||||
//var sssrrr22 = Grid1.Rows[rowIndex].RowID;
|
||||
//var sssrrr2233 = item.GetType().GetProperty("PostTrainingRoleId").GetValue(item, null); ;
|
||||
string personId = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
//string roleId = Grid1.DataKeys[rowIndex][1].ToString();
|
||||
var recordDetail = BLL.PostTrainingRecordDetailService.GetRecordDetailByRecordIdPersonId(this.RecordId, personId);
|
||||
if (recordDetail == null && !string.IsNullOrEmpty(personId))
|
||||
{
|
||||
string newKeyID = SQLHelper.GetNewID(typeof(Model.PostTraining_Record_Detail));
|
||||
Model.PostTraining_Record_Detail detail = new Model.PostTraining_Record_Detail
|
||||
{
|
||||
Id = newKeyID,
|
||||
RecordId = this.RecordId,
|
||||
PersonId = personId
|
||||
};
|
||||
BLL.PostTrainingRecordDetailService.AddRecordDetail(detail);
|
||||
}
|
||||
}
|
||||
|
||||
//更新培训人数
|
||||
var record = BLL.PostTrainingRecordService.GetRecordById(this.RecordId);
|
||||
if (record != null)
|
||||
{
|
||||
var item = BLL.PostTrainingRecordDetailService.GetRecordDetailByRecordId(this.RecordId);
|
||||
record.PersonNum = item.Count();
|
||||
BLL.PostTrainingRecordService.UpdateRecord(record);
|
||||
}
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInParent("请至少选择一条记录!");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 绑定数据
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string roleIds = Request.Params["RoleIds"];
|
||||
//var trainType = BLL.TrainTypeService.GetTrainTypeById(type);
|
||||
if (!string.IsNullOrWhiteSpace(roleIds))
|
||||
{
|
||||
string roleIdStr = StringHelper.StringConvert(roleIds);
|
||||
string strSql = $@"SELECT viewPerSon.PersonId,viewPerSon.UnitName,viewPerSon.PersonName,viewPerSon.CardNo,viewPerSon.SexName,PostTrainingRoleId,PostTrainingRoleName,viewPerSon.IdentityCard,TeamGroupName,WorkAreaName,InTime
|
||||
FROM View_SitePerson_Person AS viewPerSon
|
||||
WHERE viewPerSon.ProjectId='{this.ProjectId}' AND viewPerSon.IsUsed='1' ";
|
||||
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
if (BLL.PostTrainingRecordDetailService.GetRecordDetailByRecordId(this.RecordId).Count() > 0)
|
||||
{
|
||||
strSql += $@" AND (viewPerSon.PersonId NOT IN (
|
||||
SELECT PersonId FROM PostTraining_Record AS R
|
||||
LEFT JOIN PostTraining_Record_Detail AS D ON R.Id = D.RecordId
|
||||
WHERE R.ProjectId='{this.ProjectId}' AND R.Id = '{this.RecordId}')) ";
|
||||
}
|
||||
|
||||
strSql += $@" AND viewPerSon.PostTrainingRoleId IN ({roleIdStr})";
|
||||
|
||||
//if (!trainType.IsRepeat.HasValue || trainType.IsRepeat == false)
|
||||
//{
|
||||
// strSql += @" AND viewPerSon.PersonId NOT IN
|
||||
// (SELECT PersonId FROM PostTraining_Record AS R
|
||||
// LEFT JOIN PostTraining_Record_Detail AS D ON R.RecordId = D.RecordId
|
||||
// WHERE R.ProjectId='" + this.ProjectId + "' AND R.TrainTypeId ='" + type + "' AND D.CheckResult = 1)";
|
||||
//}
|
||||
|
||||
if (this.drpUnit.SelectedValue != BLL.Const._Null)
|
||||
{
|
||||
strSql += " AND viewPerSon.UnitId=@UnitId";
|
||||
listStr.Add(new SqlParameter("@UnitId", this.drpUnit.SelectedValue));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtPersonName.Text.Trim()))
|
||||
{
|
||||
strSql += " AND viewPerSon.PersonName LIKE @PersonName";
|
||||
listStr.Add(new SqlParameter("@PersonName", "%" + this.txtPersonName.Text.Trim() + "%"));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(this.txtCardNo.Text.Trim()))
|
||||
{
|
||||
strSql += " AND viewPerSon.CardNo LIKE @CardNo";
|
||||
listStr.Add(new SqlParameter("@CardNo", "%" + this.txtCardNo.Text.Trim() + "%"));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtRoleName.Text.Trim()))
|
||||
{
|
||||
strSql += " AND viewPerSon.PostTrainingRoleName LIKE @RoleName";
|
||||
listStr.Add(new SqlParameter("@RoleName", "%" + this.txtRoleName.Text.Trim() + "%"));
|
||||
}
|
||||
//if (ckPostType2.Checked)
|
||||
//{
|
||||
// strSql += " AND viewPerSon.PostType = @PostType";
|
||||
// listStr.Add(new SqlParameter("@PostType", BLL.Const.PostType_2));
|
||||
//}
|
||||
//if (ckIsHsse.Checked)
|
||||
//{
|
||||
// strSql += " AND IsHsse = @IsHsse";
|
||||
// listStr.Add(new SqlParameter("@IsHsse", true));
|
||||
//}
|
||||
strSql += " group by viewPerSon.PersonId,viewPerSon.UnitName,viewPerSon.PersonName,viewPerSon.CardNo,viewPerSon.Sex,PostTrainingRoleId,PostTrainingRoleName,viewPerSon.IdentityCard,TeamGroupName,WorkAreaName,InTime,SexName";
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
var table1 = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table1;
|
||||
Grid1.DataBind();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 排序
|
||||
/// <summary>
|
||||
/// Grid1排序
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
||||
{
|
||||
Grid1.SortDirection = e.SortDirection;
|
||||
Grid1.SortField = e.SortField;
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.BindGrid();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user