using BLL; using Model; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; using System.Data.Linq.SqlClient; using System.Data.SqlClient; using System.Linq; using System.Reflection; namespace FineUIPro.Web.Customization.CNCCG.ZHGL.Problem { public partial class ProblemNoticeManagerEdit : PageBase { #region 定义项 /// /// 主键 /// public string ProNoticeId { get { return (string)ViewState["ProNoticeId"]; } set { ViewState["ProNoticeId"] = value; } } /// /// 签名附件路径 /// public string SignatureUrl { get { return (string)ViewState["SignatureUrl"]; } set { ViewState["SignatureUrl"] = value; } } /// /// 签名附件路径 /// public string SignatureUrl1 { get { return (string)ViewState["SignatureUrl1"]; } set { ViewState["SignatureUrl1"] = value; } } /// /// 类型 1查看 -1 定稿文件 /// public string Types { get { return (string)ViewState["Types"]; } set { ViewState["Types"] = value; } } /// /// 定义集合 /// private static List details = new List(); public bool IsDel { get { return (bool)ViewState["IsDel"]; } set { ViewState["IsDel"] = value; } } #endregion /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { IsDel = false; this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.ProNoticeId = Request.Params["ProNoticeId"]; Types = Request.Params["Type"]; menuPower(ProNoticeId); //加载项目 var thisUnit = BLL.CommonService.GetIsThisUnit(); if (!string.IsNullOrEmpty(this.CurrUser.UnitId) && thisUnit.UnitId != this.CurrUser.UnitId) { ProjectService.InitProjectDropDownList(this.drpProject, this.CurrUser.UnitId, false); } else { BLL.ProjectService.InitProjectDropDownList(this.drpProject, true); } //加载单位 UnitService.InitBranchUnitDropDownList(this.drpUnitT, true); if (!string.IsNullOrEmpty(ProNoticeId)) { var model = Funs.DB.Problem_Notice.FirstOrDefault(x => x.ProNoticeId == ProNoticeId); if (model != null) { typrFr.Hidden = true; if (model.ProType == "1") { rblType.SelectedValue = "1"; //项目级 drpUnitT.Hidden = true; drpProject.Hidden = false; drpProject.SelectedValue = model.ProjectId; // UnitService.InitProjectUnitDropDownList(drpUnit, drpProject.SelectedValue, true); } else { drpUnitT.SelectedValue = model.ProjectId; rblType.SelectedValue = "2"; drpProject.Hidden = true; drpUnitT.Hidden = false; DrpProjectUser.Hidden = true; } txtProCode.Text = model.ProCode; txtCheckStartTime.Text= string.Format("{0:yyyy-MM-dd}", model.CheckStartTime); txtCheckEndTime.Text= string.Format("{0:yyyy-MM-dd}", model.CheckEndTime); txtCheckMans.Text = model.CheckMans; txtSupervisionMan.Text = model.SupervisionMan; //drpUnit.SelectedValue = model.Unitid; txtResume.Text = model.Resume; txtOtherJob.Text = model.OtherJob; DrpUnitUser.Values = model.UnitApproveUserIds?.Split(','); DrpSubUnitUser.Values = model.SubUnitApproveUserIds?.Split(','); DrpProjectUser.Values = model.ProjectUnitApproveUserIds?.Split(','); //被检查单位负责人签名地址 if (!string.IsNullOrEmpty(model.CheckUnitSignature)) { this.SignatureUrl = model.CheckUnitSignature; this.Image2.ImageUrl = "~/" + this.SignatureUrl; } //检查组人员签名地址 if (!string.IsNullOrEmpty(model.CheckMansSignature)) { this.SignatureUrl1 = model.CheckMansSignature; this.Image1.ImageUrl = "~/" + this.SignatureUrl1; } if (details!=null) { details.Clear(); } if (model.CreateUser==this.CurrUser.UserId) { IsDel = true; } #region 加载检查项 var strSql = @"select F.ProNoticeCId,F.QueDescribe,F.Requirements,F.QueType as QueTypeName,F.RiskLevel as RiskLevelName,F.CheckMan ,F.CheckDatetime,F.ReDay,F.SortIndex from Problem_Notice_C F where ProNoticeId='" + model.ProNoticeId + "' order by SortIndex"; List listStr = new List(); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); Grid1.RecordCount = tb.Rows.Count; var table = this.GetPagedDataTable(Grid1, tb); details = GetList(table); Grid1.DataSource = table; Grid1.DataBind(); #endregion #region 加载审批记录 DataTable approveData = BLL.ProblemNoticeApprove.GetAllApproveData(ProNoticeId); Grid_ApproveLog.DataSource = approveData; Grid_ApproveLog.DataBind(); #endregion } } else { IsDel = true; } //初始化下拉框 InitDropDownList(); } } private void menuPower(string ProNoticeId) { if (string.IsNullOrEmpty(ProNoticeId)) { Form_Approve.Hidden = true; } else { var model= ProblemNoticeService.GetProblemNoticeById(ProNoticeId); var approvelist = ProblemNoticeApprove.GetProblem_NoticeApproveByParentId(ProNoticeId); var thisApprovemodel = approvelist?.Where(x => x.ApproveMan == this.CurrUser.UserId).FirstOrDefault(); if (!ProblemNoticeService.IsCanRefuse(ProNoticeId, CurrUser.UserId)) { ListItem[] list = new ListItem[1]; list[0] = new ListItem("同意", "true"); rblIsAgree.DataTextField = "Text"; rblIsAgree.DataValueField = "Value"; rblIsAgree.DataSource = list; rblIsAgree.DataBind(); rblIsAgree.SelectedIndex = 0; } if (model.State=="0"&& (model.CreateUser == this.CurrUser.UserId || this.CurrUser.UserId==Const.hfnbdId || this.CurrUser.UserId==Const.sysglyId)) { Form_Approve.Hidden = true; } else if (model.State == "1" && thisApprovemodel !=null) { drpUnitT.Readonly = true; txtCheckStartTime.Readonly = true; txtCheckEndTime.Readonly = true; txtCheckMans.Readonly = true; txtSupervisionMan.Readonly = true; //drpUnit.Readonly = true; txtResume.Readonly = true; txtOtherJob.Readonly = true; DrpUnitUser.Hidden=true; DrpSubUnitUser.Hidden=true; DrpProjectUser.Hidden=true; addFr.Hidden=true; GridColumn column = Grid1.FindColumn("Delete"); column.Hidden = true; btnSave.Hidden=true; } else if (model.State=="-1") { Grid1.Hidden = true; Form_Approve.Hidden = true; addFr.Hidden = true; RowcheckMan.Hidden = true; Grid_ApproveLog.Hidden = true; txtOtherJob.Hidden = true; Types ="-1"; } else { Form_Approve.Hidden = true; Form2.Enabled = false; btnSave.Hidden = true; btnSubmit.Hidden=true; } } if (this.Types=="-1") { Grid1.Hidden = true; Form_Approve.Hidden = true; addFr.Hidden = true; RowcheckMan.Hidden = true; Grid_ApproveLog.Hidden = true; txtOtherJob.Hidden = true; } // drpUnit.Hidden = true; } /// /// 切换类型时 /// /// /// protected void rblType_SelectedIndexChanged(object sender, EventArgs e) { if (rblType.SelectedValue == "1") { //项目级 drpUnitT.Hidden = true; drpProject.Hidden = false; //drpUnit.Hidden = false; DrpSubUnitUser.Hidden = true; } else { //公司级 drpProject.Hidden = true; // drpUnit.Hidden = true; drpUnitT.Hidden = false; DrpProjectUser.Hidden = true; } } #region 初始化下拉框 private void InitDropDownList() { //问题类型 ListItem[] item = new ListItem[18]; item[0] = new ListItem("1.1安全管理制度类", "0"); item[1] = new ListItem("1.2组织机构及人员类", "1"); item[2] = new ListItem("1.3安全责任类", "2"); item[3] = new ListItem("1.4隐患排查类", "3"); item[4] = new ListItem("1.5安全教育培训类", ""); item[5] = new ListItem("1.6技术方案类", ""); item[6] = new ListItem("1.7质量管理类", ""); item[7] = new ListItem("1.8劳务实名类", ""); item[8] = new ListItem("1.9其他类", ""); item[9] = new ListItem("2.1临时用电类", ""); item[10] = new ListItem("2.2安全防护类", ""); item[11] = new ListItem("2.3机具设备类", ""); item[12] = new ListItem("2.4技术方案类", ""); item[13] = new ListItem("2.5消防安全类", ""); item[14] = new ListItem("2.6行为操作类", ""); item[15] = new ListItem("2.7文明施工类", ""); item[16] = new ListItem("2.8质量管理类", ""); item[17] = new ListItem("2.9其他类", ""); this.drpQueType.DataValueField = "Text"; this.drpQueType.DataTextField = "Text"; this.drpQueType.DataSource = item; this.drpQueType.DataBind(); //风险等级 ListItem[] item1 = new ListItem[3]; item1[0] = new ListItem("重大", "重大"); item1[1] = new ListItem("较大", "较大"); item1[2] = new ListItem("一般", "一般"); this.drpRiskLevel.DataValueField = "Text"; this.drpRiskLevel.DataTextField = "Text"; this.drpRiskLevel.DataSource = item1; this.drpRiskLevel.DataBind(); BLL.UserService.InitUserDropDownList(drpCheckMan,null,false); BindGrid("集团公司领导班子,集团公司本部人员", "", Grid2, ttbSearch1); BindGrid("子分公司领导班子,子分公司本部人员", "", Grid3, ttbSearch2); BindGrid("项目领导班子", drpProject.SelectedValue, Grid4, ttbSearch3); } private void BindGrid(string roleNames, string projectId, Grid grid, TwinTriggerBox ttbSearch) { string roleIds = ""; var userlist = UserService.GetUserListByProjectIdAndRoleId(projectId, roleIds); var q=from x in userlist join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId select new { x.UserId, x.UserName, y.UnitName }; if (!string.IsNullOrEmpty(ttbSearch.Text)) { q = q.Where(x => x.UserName.Contains(ttbSearch.Text)).ToList(); } grid.DataSource = q; grid.DataBind(); } protected void ttbSearch1_Trigger1Click(object sender, EventArgs e) { ttbSearch1.Text = String.Empty; ttbSearch1.ShowTrigger1 = false; BindGrid("集团公司领导班子,集团公司本部人员", "", Grid2,ttbSearch1); } protected void ttbSearch1_Trigger2Click(object sender, EventArgs e) { ttbSearch1.ShowTrigger1 = true; BindGrid("集团公司领导班子,集团公司本部人员", "", Grid2, ttbSearch1); } protected void ttbSearch2_Trigger1Click(object sender, EventArgs e) { ttbSearch2.Text = String.Empty; ttbSearch2.ShowTrigger1 = false; BindGrid("子分公司领导班子,子分公司本部人员", "", Grid3, ttbSearch2); } protected void ttbSearch2_Trigger2Click(object sender, EventArgs e) { ttbSearch2.ShowTrigger1 = true; BindGrid("子分公司领导班子,子分公司本部人员", "", Grid3, ttbSearch2); } protected void ttbSearch3_Trigger1Click(object sender, EventArgs e) { ttbSearch3.Text = String.Empty; ttbSearch3.ShowTrigger1 = false; BindGrid("项目领导班子", drpProject.SelectedValue, Grid4, ttbSearch3); } protected void ttbSearch3_Trigger2Click(object sender, EventArgs e) { ttbSearch3.ShowTrigger1 = true; BindGrid("项目领导班子", drpProject.SelectedValue, Grid4, ttbSearch3); } protected void Grid2_PageIndexChange(object sender, GridPageEventArgs e) { //Grid1.PageIndex = e.NewPageIndex; BindGrid("集团公司领导班子,集团公司本部人员", "", Grid2, ttbSearch1); } protected void Grid3_PageIndexChange(object sender, GridPageEventArgs e) { //Grid1.PageIndex = e.NewPageIndex; BindGrid("子分公司领导班子,子分公司本部人员", "", Grid2, ttbSearch2); } protected void Grid4_PageIndexChange(object sender, GridPageEventArgs e) { //Grid1.PageIndex = e.NewPageIndex; BindGrid("项目领导班子", drpProject.SelectedValue, Grid4, ttbSearch3); } #endregion #region 附件上传 /// /// 上传附件 /// /// /// protected void btnAttachUrl_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.ProNoticeId)) { this.SaveData(Const.BtnSave); //SaveNew(); } //详情 if (Types == "1" || !IsDel) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}&type=-1", this.ProNoticeId, BLL.Const.ProblemNoticeManagerMenuId))); } else { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}", this.ProNoticeId, BLL.Const.ProblemNoticeManagerMenuId))); } } protected void btnAttachUrl_1_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.ProNoticeId)) { this.SaveData(Const.BtnSave); //SaveNew(); } //详情 if (Types == "1" || !IsDel) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}&type=-1", this.ProNoticeId + "-Finalize", BLL.Const.ProblemNoticeManagerMenuId))); } else { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}", this.ProNoticeId + "-Finalize", BLL.Const.ProblemNoticeManagerMenuId))); } } protected void btnAttachUrl_2_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.ProNoticeId)) { this.SaveData(Const.BtnSave); //SaveNew(); } //详情 if (Types == "1" || !IsDel) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}&type=-1", this.ProNoticeId + "-FinalizeRelpy", BLL.Const.ProblemNoticeManagerMenuId))); } else { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}", this.ProNoticeId + "-FinalizeRelpy", BLL.Const.ProblemNoticeManagerMenuId))); } } #endregion #region 修改编号 /// /// 修改编号 根据检查时间识别到哪一个年份、哪一个季度 xxxx年x季度01 /// /// /// protected void changeCode(object sender, EventArgs e) { if (string.IsNullOrEmpty(ProNoticeId)) { var ObjCode = ""; var month = Convert.ToDateTime(Funs.GetNewDateTime(this.txtCheckStartTime.Text.Trim())); ObjCode = month.Year.ToString() + "年"; if (month.Month== 1 || month.Month == 2 || month.Month == 3) { ObjCode += "1季度"; } else if (month.Month == 4 || month.Month == 5 || month.Month == 6) { ObjCode += "2季度"; } else if (month.Month == 7 || month.Month ==8 || month.Month == 9) { ObjCode += "3季度"; } else if (month.Month == 10 || month.Month ==11 || month.Month == 12) { ObjCode += "4季度"; } //当前年份 //var count = Funs.DB.Problem_Notice.Where(x => SqlMethods.DateDiffDay(x.CreateDate, DateTime.Now) == 0).ToList().Count+1; var count = Funs.DB.Problem_Notice.Where(x => Convert.ToDateTime(x.CreateDate).Year==DateTime.Now.Year).ToList().Count + 1; if (count.ToString().Length == 1) { ObjCode += "0" + count.ToString(); } else { ObjCode += count.ToString(); } this.txtProCode.Text = ObjCode; } } #endregion #region 选择项目后加载项目中的单位 protected void changeProject(object sender, EventArgs e) { // UnitService.InitProjectUnitDropDownList(drpUnit, drpProject.SelectedValue, true); BindGrid("项目领导班子", drpProject.SelectedValue, Grid4, ttbSearch3); } #endregion #region 保存 /// /// 保存 /// protected void btnSave_Click(object sender, EventArgs e) { if (rblType.SelectedValue == "1") { if (string.IsNullOrEmpty(drpProject.SelectedValue) || this.drpProject.SelectedValue == BLL.Const._Null) { ShowNotify("请选择项目!", MessageBoxIcon.Warning); return; } } else { if (string.IsNullOrEmpty(drpUnitT.SelectedValue) ||this.drpUnitT.SelectedValue == BLL.Const._Null) { ShowNotify("请选择单位!", MessageBoxIcon.Warning); return; } } this.SaveData(Const.BtnSave); } /// /// 提交 /// /// /// protected void btnSubmit_Click(object sender, EventArgs e) { if (rblType.SelectedValue == "1") { if (this.drpProject.SelectedValue == BLL.Const._Null) { ShowNotify("请选择项目!", MessageBoxIcon.Warning); return; } } else { if (this.drpUnitT.SelectedValue == BLL.Const._Null) { ShowNotify("请选择单位!", MessageBoxIcon.Warning); return; } } this.SaveData(Const.BtnSubmit); } /// /// 保存提交方法 /// /// private void SaveData(string type) { Model.Problem_Notice model = new Model.Problem_Notice { ProCode = txtProCode.Text.Trim(), CheckMans = txtCheckMans.Text.Trim(), CheckStartTime = Funs.GetNewDateTime(this.txtCheckStartTime.Text.Trim()), CheckEndTime = Funs.GetNewDateTime(this.txtCheckEndTime.Text.Trim()), Resume = txtResume.Text, OtherJob = txtOtherJob.Text, SupervisionMan = txtSupervisionMan.Text, State = "0", }; if (rblType.SelectedValue == "1") { model.ProjectId = this.drpProject.SelectedValue; } else { model.ProjectId = this.drpUnitT.SelectedValue; } model.ProType = rblType.SelectedValue; if (type==Const.BtnSubmit) { model.State = "1"; } if (this.Types =="-1") { model.State = "-1"; } model.UnitApproveUserIds = string.Join(",", DrpUnitUser.Values); model.SubUnitApproveUserIds = string.Join(",", DrpSubUnitUser.Values); model.ProjectUnitApproveUserIds = string.Join(",", DrpProjectUser.Values); if (!string.IsNullOrEmpty(this.ProNoticeId)) { model.ProNoticeId = this.ProNoticeId; BLL.ProblemNoticeService.Update(model); BLL.LogService.AddSys_Log(this.CurrUser, model.ProCode, model.ProNoticeId, BLL.Const.ProblemNoticeManagerMenuId, BLL.Const.BtnModify); } else { model.ProNoticeId = Guid.NewGuid().ToString(); this.ProNoticeId = model.ProNoticeId; model.CreateUser = CurrUser.UserId; model.CreateDate = DateTime.Now; BLL.ProblemNoticeService.Add(model); BLL.LogService.AddSys_Log(this.CurrUser, model.ProCode, model.ProNoticeId, BLL.Const.ProblemNoticeManagerMenuId, BLL.Const.BtnAdd); } this.SaveDetail(model.ProNoticeId); PageContext.RegisterStartupScript(String.Format("showImg();")); if (type == Const.BtnSubmit&& Types!= "-1") { ProblemNoticeService.CreateFirstNoticeApprove(ProNoticeId); ProblemNoticeService.Approve(ProNoticeId, this.CurrUser.UserId, Boolean.Parse(rblIsAgree.SelectedValue), txtApproveIdea.Text); ProblemNoticeService.SendNotice(ProNoticeId); ShowNotify("提交成功.", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } else if (type == Const.BtnSubmit && Types == "-1") { ShowNotify("提交成功.", MessageBoxIcon.Success); PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference()); } else { ShowNotify("保存成功。", MessageBoxIcon.Success); } } /// /// 保存明细项 /// private void SaveDetail(string objId) { //1.先删除明细项 var detailList = Funs.DB.Problem_Notice_C.Where(x => x.ProNoticeId == objId).ToList(); if (detailList.Count>0) { Funs.DB.Problem_Notice_C.DeleteAllOnSubmit(detailList); Funs.DB.SubmitChanges(); } //2.根据列表中的明细项添加 List detailLists = new List(); JArray teamGroupData = Grid1.GetMergedData(); foreach (JObject teamGroupRow in teamGroupData) { JObject values = teamGroupRow.Value("values"); int rowIndex = teamGroupRow.Value("index"); Model.Problem_Notice_C newDetail = new Model.Problem_Notice_C { ProNoticeId = objId, //ProNoticeCId= values.Value("ProNoticeCId"), QueDescribe = values.Value("QueDescribe"), Requirements = values.Value("Requirements"), QueType = values.Value("QueTypeName"), RiskLevel = values.Value("RiskLevelName"), CheckMan = values.Value("CheckMan"), // ReDay = values.Value("ReDay"), SortIndex = rowIndex }; if (Grid1.Rows[rowIndex].DataKeys.Length > 0) { newDetail.ProNoticeCId = Grid1.Rows[rowIndex].DataKeys[0].ToString(); } //if (!string.IsNullOrEmpty(values.Value("CheckDatetime"))) //{ // newDetail.CheckDatetime = values.Value("CheckDatetime"); //} detailLists.Add(newDetail); } if (detailLists.Count>0) { Funs.DB.Problem_Notice_C.InsertAllOnSubmit(detailLists); Funs.DB.SubmitChanges(); } } /// /// 添加 附件的时候添加 /// protected void SaveNew() { if (string.IsNullOrEmpty(this.ProNoticeId)) { Model.Problem_Notice model = new Model.Problem_Notice { ProNoticeId = Guid.NewGuid().ToString(), //ProjectId = this.drpProject.SelectedValue, ProCode = txtProCode.Text.Trim(), CheckMans=txtCheckMans.Text.Trim(), CheckStartTime = Funs.GetNewDateTime(this.txtCheckStartTime.Text.Trim()), CheckEndTime= Funs.GetNewDateTime(this.txtCheckEndTime.Text.Trim()), Resume=txtResume.Text, OtherJob= txtOtherJob.Text, SupervisionMan=txtSupervisionMan.Text, CreateUser=CurrUser.UserId, CreateDate=DateTime.Now, State="0", //Unitid = this.drpUnit.SelectedValue }; if (rblType.SelectedValue == "1") { model.ProjectId = this.drpProject.SelectedValue; } else { // model.ProjectId = this.drpUnit.SelectedValue; } model.ProType = rblType.SelectedValue; //被检查单位负责人签名 if (!string.IsNullOrEmpty(this.SignatureUrl)) { model.CheckUnitSignature = SignatureUrl; model.CheckUnitDatetime = DateTime.Now; } //检查组人员签名 if (!string.IsNullOrEmpty(this.SignatureUrl1)) { model.CheckMansSignature = SignatureUrl1; model.CheckMansDatetime = DateTime.Now; } this.ProNoticeId = model.ProNoticeId; BLL.ProblemNoticeService.Add(model); BLL.LogService.AddSys_Log(this.CurrUser, model.ProCode, model.ProNoticeId, BLL.Const.ProblemNoticeManagerMenuId, BLL.Const.BtnAdd); } } #endregion #region 上传签名 /// /// 被检查单位负责人上传签名 /// /// /// protected void btnSignature_Click(object sender, EventArgs e) { if (fileSignature.HasFile) { string fileName = fileSignature.ShortFileName; if (!ValidateFileType(fileName)) { ShowNotify("无效的文件类型!", MessageBoxIcon.Warning); return; } this.SignatureUrl = UploadFileService.UploadAttachment(Funs.RootPath, this.fileSignature, this.SignatureUrl, UploadFileService.ProblemFilePath); this.Image2.ImageUrl = "~/" + this.SignatureUrl; } } /// /// 检查组人员上传签名 /// /// /// protected void btnSignature_Click1(object sender, EventArgs e) { if (fileSignature1.HasFile) { string fileName = fileSignature1.ShortFileName; if (!ValidateFileType(fileName)) { ShowNotify("无效的文件类型!", MessageBoxIcon.Warning); return; } this.SignatureUrl1 = UploadFileService.UploadAttachment(Funs.RootPath, this.fileSignature1, this.SignatureUrl1, UploadFileService.ProblemFilePath); this.Image1.ImageUrl = "~/" + this.SignatureUrl1; } } #endregion #region 检查项 /// /// /// /// /// protected void Grid1_PreDataBound(object sender, EventArgs e) { // 设置LinkButtonField的点击客户端事件 LinkButtonField deleteField = Grid1.FindColumn("Delete") as LinkButtonField; deleteField.OnClientClick = GetDeleteScript(); } /// /// 删除提示 /// /// private string GetDeleteScript() { if (IsDel) { return Confirm.GetShowReference("删除选中行?", String.Empty, MessageBoxIcon.Question, Grid1.GetDeleteSelectedRowsReference(), String.Empty); } else { return Confirm.GetShowReference("不允许操作删除项,只能进行上传签名操作。", MessageBoxIcon.Warning); } } protected void Grid1_RowCommand(object sender, GridCommandEventArgs e) { string itemId = Grid1.DataKeys[e.RowIndex][0].ToString(); if (e.CommandName == "attchUrl") { if (Types == "1" || !IsDel ) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}&type=-1", itemId, BLL.Const.ProblemNoticeManagerMenuId))); } else { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}&type=0", itemId, BLL.Const.ProblemNoticeManagerMenuId))); } } if (e.CommandName == "RectificationUrl") { if (Types == "1" || !IsDel) { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}&type=-1", itemId+ "Ref", BLL.Const.ProblemNoticeManagerMenuId))); } else { PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("~/AttachFile/webuploader.aspx?toKeyId={0}&path=FileUpload/Problem&menuId={1}&type=0", itemId+ "Ref", BLL.Const.ProblemNoticeManagerMenuId))); } } } /// /// 新增检查项 /// /// /// protected void btnAdd_Click(object sender, EventArgs e) { JArray teamGroupData = Grid1.GetMergedData(); List list = new List(); foreach (JObject teamGroupRow in teamGroupData) { JObject values = teamGroupRow.Value("values"); values.Add("ProNoticeCId", teamGroupRow.Value("id")); values.Add("SortIndex", teamGroupRow.Value("index")); list.Add(values); } JObject defaultObj = new JObject { { "ProNoticeCId",Guid.NewGuid() }, { "SortIndex", "" }, { "QueDescribe", "" }, { "Requirements", "" }, { "QueTypeName",""}, { "RiskLevelName", "" }, {"CheckDatetime","" }, { "ReDay", "" }, { "Delete", String.Format("", GetDeleteScript(), IconHelper.GetResolvedIconUrl(Icon.Delete)) } }; list.Add(defaultObj); Grid1.DataSource = list; Grid1.DataBind(); } /// /// 获取整改前图片(放于Img中) /// /// /// protected string ConvertImageUrlByImage(object proNoticeCId) { string url = string.Empty; string httpUrl = string.Empty; var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault(); if (sysSet6 != null) { httpUrl = sysSet6.SetValue; } if (proNoticeCId != null) { Model.AttachFile file = Funs.DB.AttachFile.FirstOrDefault(e => e.ToKeyId == proNoticeCId.ToString()); if (file != null && !string.IsNullOrEmpty(file.AttachUrl)) { string modelurl = file.AttachUrl.Replace('\\', '/'); url = BLL.UploadAttachmentService.ShowImage(httpUrl, modelurl); } } return url; } /// /// 获取整改后图片 /// /// /// protected string ConvertImgUrlByImage(object proNoticeCId) { string url = string.Empty; string httpUrl = string.Empty; var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault(); if (sysSet6 != null) { httpUrl = sysSet6.SetValue; } if (proNoticeCId != null) { Model.AttachFile file = Funs.DB.AttachFile.FirstOrDefault(e => e.ToKeyId == (proNoticeCId.ToString() + "Ref")); if (file != null && !string.IsNullOrEmpty(file.AttachUrl)) { string modelurl = file.AttachUrl.Replace('\\', '/'); url = BLL.UploadAttachmentService.ShowImage(httpUrl, modelurl); } } return url; } #endregion #region datable转换list public class ProblemNoticeItems { public string ProNoticeCId { get; set; } public string QueDescribe { get; set; } public string Requirements { get; set; } public string QueTypeName { get; set; } public string RiskLevelName { get; set; } public DateTime? CheckDatetime { get; set; } public string ReDay { get; set; } public int SortIndex { get; set; } public string CheckMan { get; set; } } public List GetList(DataTable table) { List list = new List(); T t = default(T); PropertyInfo[] propertypes = null; string tempName = string.Empty; foreach (DataRow row in table.Rows) { t = Activator.CreateInstance(); propertypes = t.GetType().GetProperties(); foreach (PropertyInfo pro in propertypes) { tempName = pro.Name; if (table.Columns.Contains(tempName)) { object value = row[tempName]; if (!value.ToString().Equals("")) { pro.SetValue(t, value, null); } } } list.Add(t); } return list.Count == 0 ? null : list; } #endregion } }