自动生成培训计划
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
using BLL;
|
||||
using FineUIPro.Web.DataShow;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
|
||||
namespace FineUIPro.Web.HSSE.EduTrain
|
||||
{
|
||||
/// <summary>
|
||||
/// 选择培训教材生成培训计划
|
||||
/// </summary>
|
||||
public partial class SelectCompanyTrainingItemProducePlan : PageBase
|
||||
{
|
||||
|
||||
#region 项目主键
|
||||
/// <summary>
|
||||
/// 项目主键
|
||||
/// </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)
|
||||
{
|
||||
Funs.DropDownPageSize(this.ddlPageSize);
|
||||
BLL.CompanyTrainingService.InitCompanyTrainingIsEndDropDownList(this.drpCompanyTrainingType, true);
|
||||
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
||||
{
|
||||
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
||||
}
|
||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
||||
{
|
||||
this.ProjectId = Request.Params["projectId"];
|
||||
}
|
||||
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
||||
|
||||
// 绑定表格
|
||||
this.BindGrid();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
//培训教材
|
||||
string strSql = @"SELECT item.CompanyTrainingItemId,train.CompanyTrainingName,item.CompanyTrainingId,item.CompanyTrainingItemCode,item.CompanyTrainingItemName,item.CompileMan,item.CompileDate,(CASE WHEN WorkPostNames IS NULL THEN '通用' ELSE WorkPostNames END) AS WorkPostNames
|
||||
FROM Training_CompanyTrainingItem AS item LEFT JOIN Training_CompanyTraining AS train on train.CompanyTrainingId=item.CompanyTrainingId
|
||||
WHERE 1=1 ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
var drpType = this.drpCompanyTrainingType.SelectedValue;
|
||||
if (!string.IsNullOrEmpty(drpType) && drpType != Const._Null)
|
||||
{
|
||||
strSql += " AND item.CompanyTrainingId=@CompanyTrainingId ";
|
||||
listStr.Add(new SqlParameter("@CompanyTrainingId", drpType));
|
||||
}
|
||||
strSql += "ORDER BY item.CompanyTrainingItemCode ";
|
||||
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();
|
||||
}
|
||||
|
||||
#region 排序 分页
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
Grid1.PageIndex = e.NewPageIndex;
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
||||
{
|
||||
Grid1.SortDirection = e.SortDirection;
|
||||
Grid1.SortField = e.SortField;
|
||||
BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 确定按钮事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSure_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
string itemId = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
this.SaveData(itemId,this.ProjectId);
|
||||
}
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 双击事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length == 0)
|
||||
{
|
||||
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string itemId = Grid1.SelectedRowID;
|
||||
this.SaveData(itemId, this.ProjectId);
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
|
||||
#region 查询
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.BindGrid();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 生成计划
|
||||
/// </summary>
|
||||
/// <param name="itemId">被选中的培训教材Id</param>
|
||||
/// <param name="projectId">项目</param>
|
||||
private void SaveData(string itemId, string projectId)
|
||||
{
|
||||
Model.ProducePlanInfo info = new Model.ProducePlanInfo
|
||||
{
|
||||
CurrProjectId = projectId,
|
||||
CurrUserId = this.CurrUser.UserId,
|
||||
//CheckId = model.HazardRegisterId,
|
||||
//CheckType = (int)Enums.RetakeCourseType.日常巡检,
|
||||
//CheckTypeName = "日常巡检重修",
|
||||
//PersonId = model.ResponsibleMan,
|
||||
CompanyTrainingItemId = itemId,
|
||||
TrainEndDate = new DateTime(DateTime.Now.Year, 12, 31)
|
||||
};
|
||||
TrainingPlanService.SelectCompanyTrainingItemProducePlan(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user