using BLL; using FineUIPro.Web.OfficeCheck.Check; using System; using System.EnterpriseServices.CompensatingResourceManager; using System.Linq; using System.Web.UI.WebControls; namespace FineUIPro.Web.CQMS.Comprehensive { public partial class DataReceivingDocEdit : PageBase { #region 定义变量 /// /// 主键 /// public string DataReceivingDocId { get { return (string)ViewState["DataReceivingDocId"]; } set { ViewState["DataReceivingDocId"] = value; } } #endregion #region 加载专业工程师 /// /// 加载专业工程师 /// //public void LoadAuditSelect() //{ // var db = Funs.DB; // var userList = from x in db.Sys_User // join y in db.Project_ProjectUnit // on x.UnitId equals y.UnitId // join p in db.Project_ProjectUser // on x.UserId equals p.UserId // where y.UnitId == Const.UnitId_CWCEC && p.ProjectId == CurrUser.LoginProjectId && y.ProjectId == CurrUser.LoginProjectId // where p.RoleId.Contains(Const.ZBCNEngineer) // select new { UserId = x.UserId, UserName = x.UserName }; // drpAudit.DataValueField = "UserId"; // drpAudit.DataTextField = "UserName"; // this.drpAudit.DataSource = userList.ToList(); // this.drpAudit.DataBind(); //} #endregion #region 禁止编辑 /// /// 禁止编辑 /// public void Readonly() { this.txtFileCode.Readonly = true; this.txtFileName.Readonly = true; this.txtReceiveDate.Readonly = true; //this.txtFileType.Readonly = true; this.drpFileType.Readonly = true; this.drpCNProfessionalId.Readonly = true; //this.drpSendUnit.Readonly = true; this.drpSendUnitId.Readonly = true; this.txtCopies.Readonly = true; this.txtSendMan.Readonly = true; this.txtDocumentHandler.Readonly = true; this.txtSendDate.Readonly = true; this.drpReceiveUnit.Readonly = true; this.txtReceiveMan.Readonly = true; this.rblIsReply.Readonly = true; this.txtReturnWuhuangDate.Readonly = true; this.txtRetrunWuhuangCopies.Readonly = true; this.drpIssueToUnit.Readonly = true; this.txtIssueCopies.Readonly = true; this.txtIssueUnitReceiver.Readonly = true; this.rblIsOnFile.Readonly = true; this.txtRemarkCode.Readonly = true; //this.drpAudit.Readonly = true; //this.btnAttach.Enabled = false; } #endregion #region 加载 /// /// 加载页面 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { GetButtonPower(); BLL.UnitService.GetUnit(this.drpSendUnitId, this.CurrUser.LoginProjectId, false);//发件单位 BLL.UnitService.GetUnit(this.drpReceiveUnit, this.CurrUser.LoginProjectId, false);//接收单位 BLL.UnitService.GetUnit(this.drpIssueToUnit, this.CurrUser.LoginProjectId, false);//下发至单位 BLL.ReceivingDocTypeService.InitReceivingDocType(this.drpFileType, false);//文件类别 BLL.CNProfessionalService.InitCNProfessionalDocDownList(this.drpCNProfessionalId, true);//专业 //LoadAuditSelect(); //this.agree.Hidden = true; //this.options.Hidden = true; //this.btnSave.Hidden = true; //this.btnSubmit.Hidden = true; this.DataReceivingDocId = Request.Params["DataReceivingDocId"]; Model.Comprehensive_DataReceivingDoc model = BLL.DataReceivingDocService.GetDataReceivingDocById(this.DataReceivingDocId); if (model != null) { //this.hdAttachUrl.Text = this.DataReceivingDocId; this.txtFileCode.Text = model.FileCode; this.txtFileName.Text = model.FileName; this.txtReceiveDate.Text = model.ReceiveDate.HasValue ? string.Format("{0:yyyy-MM-dd}", model.ReceiveDate) : ""; //this.txtFileType.Text = model.FileType; if (!string.IsNullOrWhiteSpace(model.FileType)) { bool containsValue = drpFileType.Items.FindByValue(model.FileType) != null; if (containsValue) { // 存在指定的值 this.drpFileType.SelectedValue = model.FileType; } else { // 不存在指定的值 this.drpFileType.Text = model.FileType; } } if (!string.IsNullOrEmpty(model.SendUnit)) { //this.drpSendUnit.SelectedValueArray = model.SendUnit.Split(','); this.drpSendUnitId.SelectedValue = model.SendUnit; } if (!string.IsNullOrEmpty(model.CNProfessionalId)) { this.drpCNProfessionalId.SelectedValue = model.CNProfessionalId; } this.txtCopies.Text = model.Copies.HasValue ? model.Copies.ToString() : ""; this.txtSendMan.Text = model.SendMan; this.txtDocumentHandler.Text = model.DocumentHandler; this.txtSendDate.Text = model.SendDate.HasValue ? string.Format("{0:yyyy-MM-dd}", model.SendDate) : ""; if (!string.IsNullOrEmpty(model.ReceiveUnit)) { this.drpReceiveUnit.SelectedValueArray = model.ReceiveUnit.Split(','); } this.txtReceiveMan.Text = model.ReceiveMan; if (model.IsReply == true) { this.rblIsReply.SelectedValue = "true"; } else { this.rblIsReply.SelectedValue = "false"; } this.txtReturnWuhuangDate.Text = model.ReturnWuhuangDate.HasValue ? string.Format("{0:yyyy-MM-dd}", model.ReturnWuhuangDate) : ""; this.txtRetrunWuhuangCopies.Text = model.RetrunWuhuangCopies.HasValue ? model.RetrunWuhuangCopies.ToString() : ""; if (!string.IsNullOrEmpty(model.IssueToUnit)) { this.drpIssueToUnit.SelectedValueArray = model.IssueToUnit.Split(','); } this.txtIssueCopies.Text = model.IssueCopies.HasValue ? model.IssueCopies.ToString() : ""; this.txtIssueUnitReceiver.Text = model.IssueUnitReceiver; if (model.IsOnFile.HasValue) { if (model.IsOnFile == true) { this.rblIsOnFile.SelectedValue = "true"; } else { this.rblIsOnFile.SelectedValue = "false"; } } this.txtRemarkCode.Text = model.RemarkCode.HasValue ? model.RemarkCode.ToString() : ""; //var currApprove = DataReceivingDocApproveService.GetCurrentApprove(model.DataReceivingDocId); //if (currApprove != null) //{ //重新编制 编制人 可以 显示 提交 保存按钮 // this.drpAudit.SelectedValue = currApprove.ApproveMan; // if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile && model.CompileMan == CurrUser.UserId) // { // this.btnSubmit.Hidden = false; // this.btnSave.Hidden = false; // }//审核状态 审核人 可以显示 提交 保存按钮 // else if (currApprove.ApproveType == BLL.Const.Comprehensive_Audit && currApprove.ApproveMan == CurrUser.UserId) // { // //审核状态不可编辑 // Readonly(); // this.agree.Hidden = false; // this.options.Hidden = false; // this.btnSubmit.Hidden = false; // this.btnSave.Hidden = false; // } //}//没有当前审核人,已完成状态 或者 待提交状态 //else //{ // if (model.Status == BLL.Const.Comprehensive_Compile && model.CompileMan == CurrUser.UserId) // { // this.btnSubmit.Hidden = false; // this.btnSave.Hidden = false; // } //} } else { // this.btnSave.Hidden = false; // this.btnSubmit.Hidden = false; this.txtReceiveDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); } } } #endregion #region 保存、提交 /// /// 保存按钮 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { if (drpSendUnitId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择发件单位!", MessageBoxIcon.Warning); return; } if ((string.IsNullOrWhiteSpace(drpFileType.Text) && string.IsNullOrWhiteSpace(drpFileType.SelectedValue)) || drpFileType.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择文件类别!", MessageBoxIcon.Warning); return; } if (drpCNProfessionalId.SelectedValue == BLL.Const._Null) { Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning); return; } var q = Funs.DB.Comprehensive_DataReceivingDoc.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.RemarkCode == Funs.GetNewInt(this.txtRemarkCode.Text.Trim()) && (x.DataReceivingDocId != this.DataReceivingDocId || (this.DataReceivingDocId == null && x.DataReceivingDocId != null))); if (q != null) { Alert.ShowInTop("标志编号已存在!", MessageBoxIcon.Warning); return; } Model.Comprehensive_DataReceivingDoc model = new Model.Comprehensive_DataReceivingDoc(); model.ProjectId = this.CurrUser.LoginProjectId; model.FileCode = this.txtFileCode.Text.Trim(); model.FileName = this.txtFileName.Text.Trim(); model.ReceiveDate = Funs.GetNewDateTime(this.txtReceiveDate.Text.Trim()); //model.FileType = this.txtFileType.Text.Trim(); //model.FileType = this.drpFileType.SelectedValue; if (this.drpFileType.SelectedValue != BLL.Const._Null && !string.IsNullOrEmpty(this.drpFileType.SelectedValue)) { model.FileType = this.drpFileType.SelectedValue; } else { model.FileType = this.drpFileType.Text; } model.CNProfessionalId = this.drpCNProfessionalId.SelectedValue; //string unitIds = string.Empty; //var unitList = this.drpSendUnit.SelectedValueArray; //foreach (var item in unitList) //{ // unitIds += item + ","; //} //if (!string.IsNullOrEmpty(unitIds)) //{ // unitIds = unitIds.Substring(0, unitIds.LastIndexOf(",")); //} //model.SendUnit = unitIds; model.SendUnit = this.drpSendUnitId.SelectedValue; model.SendMan = this.txtSendMan.Text.Trim(); model.Copies = Funs.GetNewInt(this.txtCopies.Text.Trim()); model.DocumentHandler = this.txtDocumentHandler.Text.Trim(); model.SendDate = Funs.GetNewDateTime(this.txtSendDate.Text); string receivingUnits = string.Empty; var receivingUnitList = this.drpReceiveUnit.SelectedValueArray; foreach (var item in receivingUnitList) { receivingUnits += item + ","; } if (!string.IsNullOrEmpty(receivingUnits)) { receivingUnits = receivingUnits.Substring(0, receivingUnits.LastIndexOf(",")); } model.ReceiveUnit = receivingUnits; model.ReceiveMan = this.txtReceiveMan.Text.Trim(); model.IsReply = Convert.ToBoolean(this.rblIsReply.SelectedValue); model.ReturnWuhuangDate = Funs.GetNewDateTime(this.txtReturnWuhuangDate.Text.Trim()); model.RetrunWuhuangCopies = Funs.GetNewInt(this.txtRetrunWuhuangCopies.Text.Trim()); string issueToUnits = string.Empty; var issueToUnitLists = this.drpIssueToUnit.SelectedValueArray; foreach (var item in issueToUnitLists) { issueToUnits += item + ","; } if (!string.IsNullOrEmpty(issueToUnits)) { issueToUnits = issueToUnits.Substring(0, issueToUnits.LastIndexOf(",")); } model.IssueToUnit = issueToUnits; model.IssueCopies = Funs.GetNewInt(this.txtIssueCopies.Text.Trim()); model.IssueUnitReceiver = this.txtIssueUnitReceiver.Text.Trim(); if (!string.IsNullOrEmpty(this.rblIsOnFile.SelectedValue)) { model.IsOnFile = Convert.ToBoolean(this.rblIsOnFile.SelectedValue); } model.RemarkCode = Funs.GetNewInt(this.txtRemarkCode.Text.Trim()); //if (!string.IsNullOrEmpty(this.drpAudit.SelectedValue)) //{ // model.AuditMan = drpAudit.SelectedValue; //} //审核人 if (string.IsNullOrEmpty(this.DataReceivingDocId)) { //if (!string.IsNullOrEmpty(this.hdAttachUrl.Text)) //{ // model.DataReceivingDocId = this.hdAttachUrl.Text; //} //else //{ model.DataReceivingDocId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DataReceivingDoc)); //this.hdAttachUrl.Text = model.DataReceivingDocId; //} //var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == model.DataReceivingDocId); //if (sour == null || string.IsNullOrEmpty(sour.AttachUrl)) //{ // Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); // return; //} model.CompileMan = this.CurrUser.UserId; model.CompileDate = DateTime.Now; //model.Status = BLL.Const.Comprehensive_Compile; model.DataReceivingDocId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DataReceivingDoc)); BLL.DataReceivingDocService.AddDataReceivingDoc(model); } else { model.DataReceivingDocId = this.DataReceivingDocId; //var model = Funs.DB.Comprehensive_DataReceivingDoc.Where(u => u.DataReceivingDocId == this.DataReceivingDocId).FirstOrDefault(); //if (model != null) //{ // model.Status = model.Status; //} //else //{ // model.Status = BLL.Const.Comprehensive_Compile; //} //var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.DataReceivingDocId); //if (sour == null || string.IsNullOrEmpty(sour.AttachUrl)) //{ // Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); // return; //} BLL.DataReceivingDocService.UpdateDataReceivingDoc(model); } PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); } /// /// 提交 /// /// /// //protected void btnSubmit_Click(object sender, EventArgs e) //{ // if (drpCNProfessionalId.SelectedValue == BLL.Const._Null) // { // Alert.ShowInTop("请选择专业!", MessageBoxIcon.Warning); // return; // } // Model.Comprehensive_DataReceivingDoc model = new Model.Comprehensive_DataReceivingDoc(); // model.ProjectId = this.CurrUser.LoginProjectId; // model.FileCode = this.txtFileCode.Text.Trim(); // model.FileName = this.txtFileName.Text.Trim(); // model.ReceiveDate = Funs.GetNewDateTime(this.txtReceiveDate.Text.Trim()); // model.FileType = this.txtFileType.Text.Trim(); // model.CNProfessionalId = this.drpCNProfessionalId.SelectedValue; // //string unitIds = string.Empty; // //var unitList = this.drpSendUnit.SelectedValueArray; // //foreach (var item in unitList) // //{ // // unitIds += item + ","; // //} // //if (!string.IsNullOrEmpty(unitIds)) // //{ // // unitIds = unitIds.Substring(0, unitIds.LastIndexOf(",")); // //} // model.SendUnit = drpSendUnitId.SelectedValue; // model.SendMan = this.txtSendMan.Text.Trim(); // model.Copies = Funs.GetNewInt(this.txtCopies.Text.Trim()); // model.DocumentHandler = this.txtDocumentHandler.Text.Trim(); // model.SendDate = Funs.GetNewDateTime(this.txtSendDate.Text); // string receivingUnits = string.Empty; // var receivingUnitList = this.drpReceiveUnit.SelectedValueArray; // foreach (var item in receivingUnitList) // { // receivingUnits += item + ","; // } // if (!string.IsNullOrEmpty(receivingUnits)) // { // receivingUnits = receivingUnits.Substring(0, receivingUnits.LastIndexOf(",")); // } // model.ReceiveUnit = receivingUnits; // model.ReceiveMan = this.txtReceiveMan.Text.Trim(); // model.IsReply = Convert.ToBoolean(this.rblIsReply.SelectedValue); // model.ReturnWuhuangDate = Funs.GetNewDateTime(this.txtReturnWuhuangDate.Text.Trim()); // model.RetrunWuhuangCopies = Funs.GetNewInt(this.txtRetrunWuhuangCopies.Text.Trim()); // string issueToUnits = string.Empty; // var issueToUnitLists = this.drpIssueToUnit.SelectedValueArray; // foreach (var item in issueToUnitLists) // { // issueToUnits += item + ","; // } // if (!string.IsNullOrEmpty(issueToUnits)) // { // issueToUnits = issueToUnits.Substring(0, issueToUnits.LastIndexOf(",")); // } // model.IssueToUnit = issueToUnits; // model.IssueCopies = Funs.GetNewInt(this.txtIssueCopies.Text.Trim()); // model.IssueUnitReceiver = this.txtIssueUnitReceiver.Text.Trim(); // model.IsOnFile = Convert.ToBoolean(this.rblIsOnFile.SelectedValue); // if (!string.IsNullOrEmpty(this.drpAudit.SelectedValue)) // { // model.AuditMan = drpAudit.SelectedValue; // } //审核人 // if (string.IsNullOrEmpty(this.DataReceivingDocId)) // { // if (!string.IsNullOrEmpty(this.hdAttachUrl.Text)) // { // model.DataReceivingDocId = this.hdAttachUrl.Text; // } // else // { // model.DataReceivingDocId = SQLHelper.GetNewID(typeof(Model.Comprehensive_DataReceivingDoc)); // this.hdAttachUrl.Text = model.DataReceivingDocId; // } // var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == model.DataReceivingDocId); // if (sour == null || string.IsNullOrEmpty(sour.AttachUrl)) // { // Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); // return; // } // model.CompileMan = this.CurrUser.UserId; // model.CompileDate = DateTime.Now; // model.Status = BLL.Const.Comprehensive_Audit; // BLL.DataReceivingDocService.AddDataReceivingDoc(model); // } // else // { // model.DataReceivingDocId = this.DataReceivingDocId; // var sour = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == this.DataReceivingDocId); // if (sour == null || string.IsNullOrEmpty(sour.AttachUrl)) // { // Alert.ShowInTop("请上传附件!", MessageBoxIcon.Warning); // return; // } // var model = Funs.DB.Comprehensive_DataReceivingDoc.Where(u => u.DataReceivingDocId == this.DataReceivingDocId).FirstOrDefault(); // if (model.Status == BLL.Const.Comprehensive_Compile)//编制状态提交变审核 // { // model.Status = BLL.Const.Comprehensive_Audit; // } // else if (model.Status == BLL.Const.Comprehensive_ReCompile)//重新编制状态提交变审核 // { // model.Status = BLL.Const.Comprehensive_Audit; // } // else //审核状态 提交 变 完成 或者 重新编制 // { // if (Convert.ToBoolean(rblIsAgree.SelectedValue)) // { // model.Status = BLL.Const.Comprehensive_Complete; // } // else // { // model.Status = BLL.Const.Comprehensive_ReCompile; // } // } // BLL.DataReceivingDocService.UpdateDataReceivingDoc(model); // } // #region 审核记录 // var currApprove = DataReceivingDocApproveService.GetCurrentApprove(model.DataReceivingDocId); // if (currApprove == null) //为获取到为 当前编制状态 直接提交 // { // var approve = new Model.Comprehensive_DataReceivingDocApprove(); // approve.DataReceivingDocId = model.DataReceivingDocId; // approve.ApproveMan = this.CurrUser.UserId; // approve.ApproveType = Const.Comprehensive_Compile; // approve.ApproveDate = DateTime.Now; // DataReceivingDocApproveService.EditApprove(approve); //新增编制记录 // Model.Comprehensive_DataReceivingDocApprove newApprove = new Model.Comprehensive_DataReceivingDocApprove(); // newApprove.DataReceivingDocId = model.DataReceivingDocId; // newApprove.ApproveMan = this.drpAudit.SelectedValue; // newApprove.ApproveType = Const.InspectionManagement_Audit; // DataReceivingDocApproveService.EditApprove(newApprove); //新增专业工程师审核记录 // } // else if (currApprove.ApproveMan == CurrUser.UserId) // { // if (currApprove.ApproveType == BLL.Const.Comprehensive_ReCompile) // { // currApprove.ApproveDate = DateTime.Now; // DataReceivingDocApproveService.EditApprove(currApprove); //新增专业工程师审核记录 // Model.Comprehensive_DataReceivingDocApprove newApprove = new Model.Comprehensive_DataReceivingDocApprove(); // newApprove.DataReceivingDocId = model.DataReceivingDocId; // newApprove.ApproveMan = this.drpAudit.SelectedValue; // newApprove.ApproveType = Const.InspectionManagement_Audit; // DataReceivingDocApproveService.EditApprove(newApprove); //新增专业工程师审核记录 // } // else // { // currApprove.ApproveDate = DateTime.Now; //更新审核时间 // currApprove.IsAgree = Convert.ToBoolean(rblIsAgree.SelectedValue); // currApprove.ApproveIdea = this.txtidea.Text; // DataReceivingDocApproveService.EditApprove(currApprove); // if (Convert.ToBoolean(rblIsAgree.SelectedValue)) //同意时 审批完成 // { // Model.Comprehensive_DataReceivingDocApprove reApprove = new Model.Comprehensive_DataReceivingDocApprove(); // reApprove.DataReceivingDocId = currApprove.DataReceivingDocId; // reApprove.ApproveDate = DateTime.Now.AddSeconds(10); // reApprove.ApproveMan = CurrUser.UserId; // reApprove.ApproveType = Const.Comprehensive_Complete; // reApprove.ApproveIdea = txtidea.Text; // DataReceivingDocApproveService.EditApprove(reApprove); // } // else // { // Model.Comprehensive_DataReceivingDocApprove reApprove = new Model.Comprehensive_DataReceivingDocApprove(); // reApprove.DataReceivingDocId = currApprove.DataReceivingDocId; // reApprove.ApproveMan = model.CompileMan; // reApprove.ApproveType = Const.Comprehensive_ReCompile; // DataReceivingDocApproveService.EditApprove(reApprove); // } // } // } // PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference()); // #endregion //} #endregion #region 附件上传 /// /// 附件上传 /// /// /// //protected void btnAttach_Click(object sender, EventArgs e) //{ // if (string.IsNullOrEmpty(this.hdAttachUrl.Text)) //新增记录 // { // this.hdAttachUrl.Text = SQLHelper.GetNewID(typeof(Model.Comprehensive_DataReceivingDoc)); // } // var model = BLL.DataReceivingDocService.GetDataReceivingDocById(this.DataReceivingDocId); // if (model == null || ((model.CompileMan == CurrUser.UserId && model.Status == BLL.Const.Comprehensive_Compile) || (model.CompileMan == CurrUser.UserId && model.Status == BLL.Const.Comprehensive_ReCompile))) // { // PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=0&toKeyId={0}&path=FileUpload/CQMS/DataReceivingDoc&menuId={1}", this.hdAttachUrl.Text, BLL.Const.DataReceivingDocMenuId))); // } // else // { // PageContext.RegisterStartupScript(WindowAtt.GetShowReference(String.Format("../../AttachFile/webuploader.aspx?type=-1&toKeyId={0}&path=FileUpload/CQMS/DataReceivingDoc&menuId={1}", this.hdAttachUrl.Text, BLL.Const.DataReceivingDocMenuId))); // } //} #endregion #region 获取按钮权限 /// /// 获取按钮权限 /// /// /// private void GetButtonPower() { if (Request.Params["value"] == BLL.Const._Null) { return; } var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.DataReceivingDocMenuId); if (buttonList.Count > 0) { if (buttonList.Contains(BLL.Const.BtnSave)) { this.btnSave.Hidden = false; } } } #endregion } }