345 lines
13 KiB
C#
345 lines
13 KiB
C#
using BLL;
|
|
using FineUIPro.Web.HSSE.EduTrain;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.HSSE.PostTraining
|
|
{
|
|
public partial class RecordEdit : PageBase
|
|
{
|
|
#region 定义项
|
|
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string Id
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["Id"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["Id"] = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </summary>
|
|
public string ProjectId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["ProjectId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["ProjectId"] = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 定义集合
|
|
/// </summary>
|
|
private static List<Model.View_PostTraining_RecordDetail> recordDetails = new List<Model.View_PostTraining_RecordDetail>();
|
|
|
|
#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;
|
|
this.btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
|
this.InitDropDownList();
|
|
|
|
this.Id = Request.Params["Id"];
|
|
if (!string.IsNullOrEmpty(this.Id))
|
|
{
|
|
Model.PostTraining_Record model = BLL.PostTrainingRecordService.GetRecordById(this.Id);
|
|
if (model != null)
|
|
{
|
|
this.txtCode.Text = model.Code;
|
|
this.txtRemark.Text = model.Remark;
|
|
if (!string.IsNullOrWhiteSpace(model.CourseId))
|
|
{
|
|
var course = BLL.PostTrainingCourseService.GetCourseById(model.CourseId);
|
|
this.drpCategory.SelectedValue = course.CategoryId;
|
|
//培训课程
|
|
PostTrainingCourseService.InitPostTrainingCourseDropDownList(this.drpCourse, course.CategoryId, false);
|
|
this.drpCourse.SelectedValue = model.CourseId;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(model.Method))
|
|
{
|
|
this.drpMethod.SelectedValue = model.Method;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
////自动生成编码
|
|
this.txtCode.Text = SQLHelper.RunProcNewId("SpGetNewCode5", "dbo.PostTraining_Record", "Code", "");
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 下拉框加载
|
|
/// </summary>
|
|
private void InitDropDownList()
|
|
{
|
|
//培训单位
|
|
UnitService.InitUnitDropDownList(this.drpUnits, this.ProjectId, false);
|
|
//获取适用岗位下拉框
|
|
PostTrainingRoleService.InitPostTrainingRoleDropDownList(this.drpRole, false);
|
|
//获取培训类别下拉框
|
|
PostTrainingCategoryService.InitPostTrainingCategoryDropDownList(this.drpCategory, false);
|
|
//获取培训方式下拉框
|
|
PostTrainingMethodService.InitPostTrainingMethodDropDownList(this.drpMethod, null, false);
|
|
|
|
this.drpUnits.SelectedValue = this.CurrUser.UnitId;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 培训类别下拉加载
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void drpCategory_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
//培训课程
|
|
PostTrainingCourseService.InitPostTrainingCourseDropDownList(this.drpCourse, this.drpCategory.SelectedValue, false);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定 Grid1
|
|
/// </summary>
|
|
private void Grid1DataBind()
|
|
{
|
|
recordDetails = (from x in Funs.DB.View_PostTraining_RecordDetail
|
|
where x.RecordId == this.Id
|
|
orderby x.UnitName, x.RoleName, x.PersonName
|
|
select x).ToList();
|
|
Grid1.DataSource = recordDetails;
|
|
Grid1.DataBind();
|
|
//for (int i = 0; i < Grid1.Rows.Count; i++)
|
|
//{
|
|
// bool isRed = true;
|
|
// string trainDetailId = Grid1.Rows[i].DataKeys[0].ToString();
|
|
// var getAtt = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == trainDetailId);
|
|
// if (getAtt != null)
|
|
// {
|
|
// isRed = false;
|
|
// }
|
|
// if (isRed)
|
|
// {
|
|
// var getRecordDetail = recordDetails.FirstOrDefault(x => x.DetailId == trainDetailId);
|
|
// if (getRecordDetail != null && !string.IsNullOrEmpty(this.TestPlanId)) ////未参加过培训的人员
|
|
// {
|
|
// var getTestRecord = Funs.DB.Training_TestRecord.FirstOrDefault(x => x.TestManId == getRecordDetail.PersonId && x.TestPlanId == this.TestPlanId);
|
|
// if (getTestRecord != null)
|
|
// {
|
|
// isRed = false;
|
|
// }
|
|
// }
|
|
// }
|
|
// if (isRed)
|
|
// {
|
|
// Grid1.Rows[i].RowCssClass = "Red";
|
|
// }
|
|
//}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 选择按钮
|
|
/// <summary>
|
|
/// 选择按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSelect_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.Id))
|
|
{
|
|
this.SaveData(BLL.Const.BtnSave);
|
|
}
|
|
//培训岗位
|
|
string roleIds = string.Empty;
|
|
foreach (var item in this.drpRole.SelectedValueArray)
|
|
{
|
|
roleIds += item + ",";
|
|
}
|
|
if (!string.IsNullOrEmpty(roleIds))
|
|
{
|
|
roleIds = roleIds.Substring(0, roleIds.LastIndexOf(","));
|
|
}
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SelectPerson.aspx?RecordId={0}&RoleIds={1}", this.Id, roleIds, "编辑 - ")));
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 批量删除
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
BLL.PostTrainingRecordDetailService.DeleteTrainDetailByTrainDetail(rowID);
|
|
}
|
|
|
|
this.Grid1DataBind();
|
|
this.txtPersonNum.Text = recordDetails.Count.ToString();
|
|
this.ShowNotify("删除数据成功!(表格数据已重新绑定)");
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 关闭弹出窗
|
|
|
|
/// <summary>
|
|
/// 关闭弹出窗
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Window1_Close(object sender, EventArgs e)
|
|
{
|
|
this.Grid1DataBind();
|
|
this.txtPersonNum.Text = recordDetails.Count.ToString();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 保存
|
|
|
|
/// <summary>
|
|
/// 保存按钮
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
this.SaveData(BLL.Const.BtnSave);
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存数据
|
|
/// </summary>
|
|
/// <param name="type"></param>
|
|
private void SaveData(string type)
|
|
{
|
|
Model.PostTraining_Record newModel = new Model.PostTraining_Record
|
|
{
|
|
ProjectId = this.ProjectId,
|
|
Code = this.txtCode.Text.Trim(),
|
|
CompileDate = DateTime.Now,
|
|
CompileMan = this.CurrUser.UserId,
|
|
PersonNum = this.Grid1.Rows.Count,
|
|
TrainingTime = Funs.GetNewDateTimeOrNow(this.txtTrainingTime.Text.Trim())
|
|
};
|
|
newModel.Name = this.txtName.Text.Trim();
|
|
newModel.Content = this.txtContent.Text.Trim();
|
|
newModel.CategoryId = this.drpCategory.SelectedValue;
|
|
newModel.CategoryName = this.drpCategory.SelectedText;
|
|
newModel.CourseId = this.drpCourse.SelectedValue;
|
|
newModel.CourseName = this.drpCourse.SelectedText;
|
|
newModel.Location = this.txtLocation.Text.Trim();
|
|
newModel.Method = this.drpMethod.SelectedText;
|
|
newModel.Lecturer = this.txtLecturer.Text.Trim();
|
|
newModel.Duration = decimal.Parse(this.txtDuration.Text.Trim());
|
|
newModel.Remark = this.txtRemark.Text.Trim();
|
|
|
|
//培训单位
|
|
string unitIds = string.Empty;
|
|
foreach (var item in this.drpUnits.SelectedValueArray)
|
|
{
|
|
unitIds += item + ",";
|
|
}
|
|
if (!string.IsNullOrEmpty(unitIds))
|
|
{
|
|
unitIds = unitIds.Substring(0, unitIds.LastIndexOf(","));
|
|
}
|
|
|
|
//培训岗位
|
|
string roleIds = string.Empty;
|
|
foreach (var item in this.drpRole.SelectedValueArray)
|
|
{
|
|
roleIds += item + ",";
|
|
}
|
|
if (!string.IsNullOrEmpty(roleIds))
|
|
{
|
|
roleIds = roleIds.Substring(0, roleIds.LastIndexOf(","));
|
|
}
|
|
|
|
newModel.UnitIds = unitIds;
|
|
newModel.RoleIds = roleIds;
|
|
if (!string.IsNullOrEmpty(this.Id))
|
|
{
|
|
newModel.Id = this.Id;
|
|
BLL.PostTrainingRecordService.UpdateRecord(newModel);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, newModel.Code, newModel.Id, BLL.Const.PostTrainingRecordMenuId, BLL.Const.BtnModify);
|
|
}
|
|
else
|
|
{
|
|
this.Id = SQLHelper.GetNewID(typeof(Model.PostTraining_Record));
|
|
newModel.Id = this.Id;
|
|
BLL.PostTrainingRecordService.AddRecord(newModel);
|
|
BLL.LogService.AddSys_Log(this.CurrUser, newModel.Code, newModel.Id, BLL.Const.PostTrainingRecordMenuId, BLL.Const.BtnAdd);
|
|
}
|
|
|
|
//JArray mergedData = Grid1.GetMergedData();
|
|
//foreach (JObject mergedRow in mergedData)
|
|
//{
|
|
// string status = mergedRow.Value<string>("status");
|
|
// JObject values = mergedRow.Value<JObject>("values");
|
|
// Model.PostTraining_Record_Detail detail = BLL.PostTrainingRecordDetailService.GetRecordDetailById(values.Value<string>("DetailId").ToString());
|
|
// if (detail != null)
|
|
// {
|
|
// if (values.Value<string>("CheckResult").ToString() == "1")
|
|
// {
|
|
// detail.CheckResult = true;
|
|
// }
|
|
// else
|
|
// {
|
|
// detail.CheckResult = false;
|
|
// }
|
|
// detail.CheckScore = Funs.GetNewDecimalOrZero(values.Value<string>("CheckScore").ToString()); ;
|
|
// BLL.EduTrain_TrainRecordDetailService.UpdateTrainDetail(detail);
|
|
// }
|
|
//}
|
|
}
|
|
#endregion
|
|
|
|
#region 附件上传
|
|
/// <summary>
|
|
/// 上传附件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnAttachUrl_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(this.Id))
|
|
{
|
|
SaveData(BLL.Const.BtnSave);
|
|
}
|
|
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/PostTraining/Record&menuId={1}", Id, BLL.Const.PostTrainingRecordMenuId)));
|
|
}
|
|
#endregion
|
|
}
|
|
} |