学习园地
This commit is contained in:
@@ -0,0 +1,286 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Model;
|
||||
using BLL;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
|
||||
namespace FineUIPro.Web.HSSE.EduTrain
|
||||
{
|
||||
public partial class StudyZoneItemSave : PageBase
|
||||
{
|
||||
#region 定义变量
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public string StudyZoneItemId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["StudyZoneItemId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["StudyZoneItemId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主表主键
|
||||
/// </summary>
|
||||
public string StudyZoneId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["StudyZoneId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["StudyZoneId"] = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 加载页面
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.GetButtonPower();
|
||||
btnClose.OnClientClick = ActiveWindow.GetHideReference();
|
||||
//BoundTree(treeTestTraining.Nodes, "0");
|
||||
//BindEnumrableToDropDownList();
|
||||
this.StudyZoneItemId = Request.QueryString["StudyZoneItemId"];
|
||||
this.StudyZoneId = Request.QueryString["StudyZoneId"];
|
||||
if (!string.IsNullOrEmpty(this.StudyZoneItemId))
|
||||
{
|
||||
var model = StudyZoneItemService.GetStudyZoneItemById(this.StudyZoneItemId);
|
||||
if (model != null)
|
||||
{
|
||||
this.StudyZoneId = model.StudyZoneId;
|
||||
txtStudyZoneItemCode.Text = model.StudyZoneItemCode;
|
||||
txtStudyZoneItemName.Text = model.StudyZoneItemName;
|
||||
txtCompileMan.Text = model.CompileMan;
|
||||
hdCompileMan.Text = model.CompileMan;
|
||||
// if (model.Outcome!=null)
|
||||
// drpOutcome.SelectedValue = model.Outcome.ToString();
|
||||
// if (!string.IsNullOrEmpty(model.TestTrainingIds))
|
||||
// {
|
||||
// ddTestTraining.Values = model.TestTrainingIds.Split(',');
|
||||
// string text = "";
|
||||
// var trains = Funs.DB.Training_TestTraining.ToList();
|
||||
// foreach (var ids in ddTestTraining.Values)
|
||||
// {
|
||||
// var t = trains.FirstOrDefault(x => x.TrainingId == ids);
|
||||
// if (t != null)
|
||||
// {
|
||||
// text += "[" + t.TrainingCode + "]" + t.TrainingName + ",";
|
||||
// }
|
||||
// }
|
||||
// ddTestTraining.Text = text.TrimEnd(new char[] { ',' });
|
||||
// }
|
||||
// if (!string.IsNullOrEmpty(model.WorkPostIds))
|
||||
// {
|
||||
// string[] ids1 = model.WorkPostIds.Split(',');
|
||||
// DropDownBox1.Values = ids1;
|
||||
// }
|
||||
// if (model.LearningTime.HasValue)
|
||||
//{
|
||||
// txtLearningTime.Text = (model.LearningTime.Value/60).ToString();
|
||||
//}
|
||||
if (model.CompileDate != null)
|
||||
{
|
||||
txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", model.CompileDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var cTraining = BLL.StudyZoneService.GetStudyZoneById(this.StudyZoneId);
|
||||
if (cTraining != null)
|
||||
{
|
||||
txtCompileMan.Text = this.CurrUser.UserName;
|
||||
hdCompileMan.Text = this.CurrUser.UserName;
|
||||
//this.txtStudyZoneItemName.Text = cTraining.StudyZoneName;
|
||||
this.txtStudyZoneItemCode.Text = SQLHelper.RunProcNewId("SpGetNewCode3", "Training_StudyZoneItem", "StudyZoneItemCode", cTraining.StudyZoneCode + "-");
|
||||
txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//private void BindEnumrableToDropDownList()
|
||||
//{
|
||||
// List<Model.Base_WorkPost> workPostList = BLL.WorkPostService.GetWorkPostList();
|
||||
// RadioButtonList1.DataTextField = "WorkPostName";
|
||||
// RadioButtonList1.DataValueField = "WorkPostId";
|
||||
// RadioButtonList1.DataSource = workPostList;
|
||||
// RadioButtonList1.DataBind();
|
||||
|
||||
// Enums.InitOutcomeDropDownList(drpOutcome, false);
|
||||
//}
|
||||
|
||||
#endregion
|
||||
//private List<Model.Training_TestTraining> GetNewTraining(string parentId)
|
||||
//{
|
||||
// return (from x in Funs.DB.Training_TestTraining
|
||||
// where x.SupTrainingId == parentId
|
||||
// orderby x.TrainingCode
|
||||
// select x).ToList();
|
||||
//}
|
||||
//private void BoundTree(TreeNodeCollection nodes, string parentId)
|
||||
//{
|
||||
// var dt = GetNewTraining(parentId);
|
||||
// if (dt.Count() > 0)
|
||||
// {
|
||||
// TreeNode tn = null;
|
||||
// foreach (var dr in dt)
|
||||
// {
|
||||
// string name = dr.TrainingName;
|
||||
// if (!string.IsNullOrEmpty(dr.TrainingCode))
|
||||
// {
|
||||
// name = "[" + dr.TrainingCode + "]" + dr.TrainingName;
|
||||
// }
|
||||
// tn = new TreeNode
|
||||
// {
|
||||
|
||||
// Text = name,
|
||||
// NodeID = dr.TrainingId,
|
||||
// EnableClickEvent = true,
|
||||
// ToolTip = dr.TrainingName
|
||||
// };
|
||||
// nodes.Add(tn);
|
||||
// ///是否存在下级节点
|
||||
// var sup = Funs.DB.Training_TestTraining.FirstOrDefault(x => x.SupTrainingId == tn.NodeID);
|
||||
// if (sup != null)
|
||||
// {
|
||||
// BoundTree(tn.Nodes, tn.NodeID);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
#region 保存
|
||||
/// <summary>
|
||||
/// 保存数据
|
||||
/// </summary>
|
||||
private void SaveData(bool isClose)
|
||||
{
|
||||
Model.Training_StudyZoneItem newModel = new Training_StudyZoneItem
|
||||
{
|
||||
StudyZoneItemCode = this.txtStudyZoneItemCode.Text.Trim(),
|
||||
StudyZoneItemName = this.txtStudyZoneItemName.Text.Trim(),
|
||||
CompileMan = hdCompileMan.Text.Trim()
|
||||
};
|
||||
|
||||
// newModel.Outcome = int.Parse(drpOutcome.SelectedValue);
|
||||
// if (!string.IsNullOrEmpty(DropDownBox1.Text))
|
||||
// {
|
||||
// newModel.WorkPostIds = String.Join(",", DropDownBox1.Values);
|
||||
// newModel.WorkPostNames = String.Join(",", DropDownBox1.Texts);
|
||||
// }
|
||||
// if (ddTestTraining.Values != null && ddTestTraining.Values.Length > 0)
|
||||
// {
|
||||
// newModel.TestTrainingIds = string.Join(",", ddTestTraining.Values);
|
||||
// }
|
||||
// if (!string.IsNullOrEmpty(txtLearningTime.Text))
|
||||
//{
|
||||
// newModel.LearningTime = int.Parse(txtLearningTime.Text)*60;
|
||||
//}
|
||||
if (!string.IsNullOrEmpty(txtCompileDate.Text.Trim()))
|
||||
{
|
||||
newModel.CompileDate = Convert.ToDateTime(txtCompileDate.Text.Trim());
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.StudyZoneItemId))
|
||||
{
|
||||
newModel.StudyZoneItemId = this.StudyZoneItemId;
|
||||
BLL.StudyZoneItemService.UpdateStudyZoneItem(newModel);
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, newModel.StudyZoneItemCode, newModel.StudyZoneItemId,BLL.Const.StudyZoneMenuId,BLL.Const.BtnModify);
|
||||
}
|
||||
else
|
||||
{
|
||||
newModel.StudyZoneId = this.StudyZoneId;
|
||||
this.StudyZoneItemId = SQLHelper.GetNewID(typeof(Model.Training_StudyZoneItem));
|
||||
newModel.StudyZoneItemId = this.StudyZoneItemId;
|
||||
BLL.StudyZoneItemService.AddStudyZoneItem(newModel);
|
||||
BLL.LogService.AddSys_Log(this.CurrUser, newModel.StudyZoneItemCode, newModel.StudyZoneItemId, BLL.Const.StudyZoneMenuId, BLL.Const.BtnAdd);
|
||||
}
|
||||
if (isClose)
|
||||
{
|
||||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
SaveData(true);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 验证教材名称是否存在
|
||||
/// <summary>
|
||||
/// 验证教材名称是否存在
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void TextBox_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
var q = Funs.DB.Training_StudyZoneItem.FirstOrDefault(x => x.StudyZoneId == this.StudyZoneId && x.StudyZoneItemName == this.txtStudyZoneItemName.Text.Trim() && (x.StudyZoneItemId != this.StudyZoneItemId || (this.StudyZoneItemId == null && x.StudyZoneItemId != null)));
|
||||
if (q != null)
|
||||
{
|
||||
ShowNotify("输入的教材名称已存在!", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 上传附件资源
|
||||
/// <summary>
|
||||
/// 上传附件资源
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnUploadResources_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.btnSave.Hidden)
|
||||
{
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/StudyZone&menuId={1}&type=-1", StudyZoneItemId, BLL.Const.StudyZoneMenuId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (string.IsNullOrEmpty(this.StudyZoneItemId))
|
||||
{
|
||||
SaveData(false);
|
||||
}
|
||||
PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/StudyZone&menuId={1}", StudyZoneItemId, BLL.Const.StudyZoneMenuId)));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 按钮权限
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
private void GetButtonPower()
|
||||
{
|
||||
if (Request.Params["value"] == "0")
|
||||
{
|
||||
return;
|
||||
}
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.StudyZoneMenuId);
|
||||
if (buttonList.Count() > 0)
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnSave))
|
||||
{
|
||||
this.btnSave.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user