/// <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.ContactListId = Request.Params["ContactListId"]; if (!string.IsNullOrEmpty(this.ContactListId)) { Model.Check_ContactList ContactList = BLL.ContactListService.GetContactListById(this.ContactListId); if (ContactList != null) { this.ProjectId = ContactList.ProjectId; if (this.ProjectId != this.CurrUser.LoginProjectId) { this.InitDropDownList(); } this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.ContactListId); if (!String.IsNullOrEmpty(ContactList.SponsorUnitId)) { this.drpSponsorUnit.SelectedValue = ContactList.SponsorUnitId; } if (!string.IsNullOrEmpty(ContactList.ReceivingUnits)) { this.drpReceivingUnits.SelectedValueArray = ContactList.ReceivingUnits.Split(','); } this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", ContactList.CompileDate); if (!string.IsNullOrEmpty(ContactList.CompileMan)) { this.drpCompileMan.SelectedValue = ContactList.CompileMan; } this.txtRemark.Text = ContactList.Remark; this.txtSeeFile.Text = HttpUtility.HtmlDecode(ContactList.SeeFile); } } else { ////自动生成编码 this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByMenuIdProjectId(BLL.Const.ProjectContactListMenuId, this.ProjectId, this.CurrUser.UnitId); this.drpCompileMan.SelectedValue = this.CurrUser.UserId; this.drpSponsorUnit.SelectedValue = this.CurrUser.UnitId; this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now); var codeTemplateRule = BLL.ProjectData_CodeTemplateRuleService.GetProjectData_CodeTemplateRuleByMenuIdProjectId(BLL.Const.ProjectContactListMenuId, this.ProjectId); if (codeTemplateRule != null) { this.txtSeeFile.Text = HttpUtility.HtmlDecode(codeTemplateRule.Template); } } } }
/// <summary> /// 保存数据 /// </summary> /// <param name="type"></param> private void SaveData(string type) { Model.Check_ContactList newContactList = new Model.Check_ContactList { ProjectId = this.ProjectId, Code = this.txtCode.Text.Trim(), CompileDate = Funs.GetNewDateTime(this.txtCompileDate.Text.Trim()) }; if (this.drpCompileMan.SelectedValue != BLL.Const._Null) { newContactList.CompileMan = this.drpCompileMan.SelectedValue; } if (this.drpSponsorUnit.SelectedValue != BLL.Const._Null) { newContactList.SponsorUnitId = this.drpSponsorUnit.SelectedValue; } ///接收单位 string receivingUnits = string.Empty; string receivingUnitNames = string.Empty; foreach (var item in this.drpReceivingUnits.SelectedValueArray) { var role = BLL.UnitService.GetUnitByUnitId(item); if (role != null) { receivingUnits += role.UnitId + ","; receivingUnitNames += role.UnitName + ","; } } if (!string.IsNullOrEmpty(receivingUnits)) { newContactList.ReceivingUnits = receivingUnits.Substring(0, receivingUnits.LastIndexOf(",")); newContactList.ReceivingUnitNames = receivingUnitNames.Substring(0, receivingUnitNames.LastIndexOf(",")); } newContactList.Remark = this.txtRemark.Text.Trim(); newContactList.SeeFile = HttpUtility.HtmlEncode(this.txtSeeFile.Text); if (!string.IsNullOrEmpty(this.ContactListId)) { newContactList.ContactListId = this.ContactListId; BLL.ContactListService.UpdateContactList(newContactList); BLL.LogService.AddSys_Log(this.CurrUser, newContactList.Code, newContactList.ContactListId, BLL.Const.ProjectContactListMenuId, BLL.Const.BtnModify); } else { this.ContactListId = SQLHelper.GetNewID(typeof(Model.Check_ContactList)); newContactList.ContactListId = this.ContactListId; BLL.ContactListService.AddContactList(newContactList); BLL.LogService.AddSys_Log(this.CurrUser, newContactList.Code, newContactList.ContactListId, BLL.Const.ProjectContactListMenuId, BLL.Const.BtnAdd); } }
/// <summary> /// 删除 /// </summary> /// <param name="ContactListId"></param> public static void DeleteContactListById(string ContactListId) { Model.SUBHSSEDB db = Funs.DB; Model.Check_ContactList ContactList = db.Check_ContactList.FirstOrDefault(e => e.ContactListId == ContactListId); if (ContactList != null) { if (!string.IsNullOrEmpty(ContactList.AttachUrl)) { BLL.UploadAttachmentService.DeleteFile(Funs.RootPath, ContactList.AttachUrl);//删除附件 } CodeRecordsService.DeleteCodeRecordsByDataId(ContactListId); CommonService.DeleteAttachFileById(ContactListId); db.Check_ContactList.DeleteOnSubmit(ContactList); db.SubmitChanges(); } }
/// <summary> /// 修改 /// </summary> /// <param name="ContactList"></param> public static void UpdateContactList(Model.Check_ContactList ContactList) { Model.SUBHSSEDB db = Funs.DB; Model.Check_ContactList newContactList = db.Check_ContactList.FirstOrDefault(e => e.ContactListId == ContactList.ContactListId); if (newContactList != null) { newContactList.Code = ContactList.Code; newContactList.SponsorUnitId = ContactList.SponsorUnitId; newContactList.ReceivingUnits = ContactList.ReceivingUnits; newContactList.ReceivingUnitNames = ContactList.ReceivingUnitNames; newContactList.CompileDate = ContactList.CompileDate; newContactList.CompileMan = ContactList.CompileMan; newContactList.Remark = ContactList.Remark; newContactList.AttachUrl = ContactList.AttachUrl; newContactList.SeeFile = ContactList.SeeFile; db.SubmitChanges(); } }
/// <summary> /// 加载页面 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.btnClose.OnClientClick = ActiveWindow.GetHideReference(); this.ContactListId = Request.Params["ContactListId"]; if (!string.IsNullOrEmpty(this.ContactListId)) { Model.Check_ContactList ContactList = BLL.ContactListService.GetContactListById(this.ContactListId); if (ContactList != null) { this.txtCode.Text = BLL.CodeRecordsService.ReturnCodeByDataId(this.ContactListId); this.drpSponsorUnit.Text = BLL.UnitService.GetUnitNameByUnitId(ContactList.SponsorUnitId); this.drpReceivingUnits.Text = ContactList.ReceivingUnitNames; this.txtCompileDate.Text = string.Format("{0:yyyy-MM-dd}", ContactList.CompileDate); this.txtRemark.Text = ContactList.Remark; this.txtSeeFile.Text = HttpUtility.HtmlDecode(ContactList.SeeFile); this.txtCompileMan.Text = BLL.UserService.GetUserNameByUserId(ContactList.CompileMan); } } } }
/// <summary> /// 添加联系单 /// </summary> /// <param name="ContactList"></param> public static void AddContactList(Model.Check_ContactList ContactList) { Model.SUBHSSEDB db = Funs.DB; Model.Check_ContactList newContactList = new Model.Check_ContactList { ContactListId = ContactList.ContactListId, ProjectId = ContactList.ProjectId, Code = ContactList.Code, SponsorUnitId = ContactList.SponsorUnitId, ReceivingUnits = ContactList.ReceivingUnits, ReceivingUnitNames = ContactList.ReceivingUnitNames, CompileDate = ContactList.CompileDate, CompileMan = ContactList.CompileMan, Remark = ContactList.Remark, AttachUrl = ContactList.AttachUrl, SeeFile = ContactList.SeeFile }; db.Check_ContactList.InsertOnSubmit(newContactList); db.SubmitChanges(); CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectContactListMenuId, newContactList.ProjectId, ContactList.SponsorUnitId, newContactList.ContactListId, newContactList.CompileDate); }