private void AddAttach(long id) { string hidFileList = Request.Params["hidFileName"]; if (!string.IsNullOrEmpty(hidFileList)) { var bll = new BLL.CCOM.Notice_attach(); string[] fileListArr = hidFileList.Split(','); for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); if (fileArr.Length == 3) { long attach_id = Int64.Parse(fileArr[0]); String toFilePath = DataDic.News_Attach_Path + DateTime.Now.Ticks.ToString() + i.ToString() + FileOperate.GetPostfixStr(fileArr[2]); toFilePath = fileArr[2]; //原有附件地址不变 try { FileOperate.FileMove(Server.MapPath(fileArr[2]), Server.MapPath(toFilePath)); //上传附件至文件服务器 UI.UpLoad.UploadFileThread(toFilePath); } catch { toFilePath = fileArr[2]; } var attach_model = new Model.CCOM.Notice_attach(); attach_model.Notice_attach_name = fileArr[1]; attach_model.Notice_id = id; attach_model.Notice_attach_address = toFilePath; bll.Add(attach_model); } } } }
/// <summary> /// /// </summary> /// <param name="_id">资讯ID</param> /// <returns></returns> private bool DoEdit(int _id) { #region =====================================附件 string hidFileList = Request.Params["hidFileName"]; string strWhere = " News_id=" + _id; var news_attach = new BLL.CCOM.News_attach().GetModelList(strWhere); if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); //附件发生变化,重新上传(从无到有,数目发生变化,内容发生变化) if (news_attach != null && news_attach.Count > 0 && news_attach.Count != fileListArr.Length || this.attachChange.Value == "1" || news_attach.Count == 0) { var bll = new BLL.CCOM.News_attach(); for (int i = 0; i < news_attach.Count; i++) { string str = " News_attach_id=" + news_attach[i].News_attach_id; bll.Delete(str); } for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); if (fileArr.Length == 3) { long attach_id = Int64.Parse(fileArr[0]); String toFilePath = DataDic.News_Attach_Path + DateTime.Now.Ticks.ToString() + i.ToString() + FileOperate.GetPostfixStr(fileArr[2]); //新增文件 if (attach_id == 0) { try { FileOperate.FileMove(Server.MapPath(fileArr[2]), Server.MapPath(toFilePath)); //上传附件至文件服务器 UI.UpLoad.UploadFileThread(toFilePath); } catch { toFilePath = fileArr[2]; } } else { toFilePath = fileArr[2]; //原有附件地址不变 } Model.CCOM.News_attach model_attach = new Model.CCOM.News_attach(); model_attach.News_id = newsId; model_attach.News_attach_name = fileArr[1]; model_attach.News_attach_address = toFilePath; new BLL.CCOM.News_attach().Add(model_attach); } } } } else { //从有到无,删除数据库数据 if (news_attach != null && news_attach.Count > 0) { var bll = new BLL.CCOM.News_attach(); for (int i = 0; i < news_attach.Count; i++) { string str = " News_attach_id=" + news_attach[i].News_attach_id; bll.Delete(str); } } } #endregion //var model = new Model.CCOM.News(); var model = new BLL.CCOM.News().GetModel(_id); model.News_title = this.txtTitle.Text.Trim(); if (this.txtReleaseTime.Text.Trim() != null && this.txtReleaseTime.Text.Trim().Length > 0) { model.News_date = Convert.ToDateTime(this.txtReleaseTime.Text.Trim()); } model.News_last_editor = (int)GetAdminInfo_CCOM().User_id; model.News_type_id = int.Parse(DESEncrypt.Decrypt(this.hidNewsType.Value)); model.News_content = this.hidEditorCnt.Value.Replace("'", ""); model.News_top = false;//默认不置顶 if (this.optTop.Checked) { model.News_top = true; string time = this.txtTopTime.Text.Trim(); if (time != null && time.Length > 0) { int last_time = int.Parse(time); model.News_top_time = last_time; } else { model.News_top_time = 3;//默认置顶3天 } } if (new BLL.CCOM.News().Update(model)) { NewsHtml.CreateHtml(_id, false); return(true); } else { return(false); } }
private int DoAdd() { var model = new Model.CCOM.News(); model.News_title = this.txtTitle.Text.Trim(); model.News_URL = "/AdminMetro/index.aspx"; model.News_creator_id = (int)GetAdminInfo_CCOM().User_id; if (this.txtReleaseTime.Text.Trim() != null && this.txtReleaseTime.Text.Trim().Length > 0) { model.News_date = Convert.ToDateTime(this.txtReleaseTime.Text.Trim()); } else { model.News_date = DateTime.Now; } model.News_readnumber = 1; model.News_type_id = int.Parse(DESEncrypt.Decrypt(this.hidNewsType.Value)); model.News_content = this.hidEditorCnt.Value.Replace("'", ""); model.News_top = false; if (this.optTop.Checked) { model.News_top = true; string time = this.txtTopTime.Text.Trim(); if (time != null && time.Length > 0) { int last_time = int.Parse(time); model.News_top_time = last_time; } else { model.News_top_time = 3;//默认置顶3天 } } Int32 newsId = 0; newsId = new BLL.CCOM.News().Add(model); if (newsId > 0) { #region ====================附件 //保存附件 string hidFileList = Request.Params["hidFileName"]; if (!string.IsNullOrEmpty(hidFileList)) { string[] fileListArr = hidFileList.Split(','); //var list = new List<Model.CCOM.News_attach>(); for (int i = 0; i < fileListArr.Length; i++) { string[] fileArr = fileListArr[i].Split('|'); if (fileArr.Length == 3) { int attach_id = Int32.Parse(fileArr[0]); String toFilePath = DataDic.News_Attach_Path + DateTime.Now.Ticks.ToString() + i.ToString() + FileOperate.GetPostfixStr(fileArr[2]); try { FileOperate.FileMove(Server.MapPath(fileArr[2]), Server.MapPath(toFilePath)); //上传附件至文件服务器 UI.UpLoad.UploadFileThread(toFilePath); } catch (Exception ex) { toFilePath = fileArr[2]; } Model.CCOM.News_attach model_attach = new Model.CCOM.News_attach(); model_attach.News_id = newsId; model_attach.News_attach_name = fileArr[1]; model_attach.News_attach_address = toFilePath; new BLL.CCOM.News_attach().Add(model_attach); } } } #endregion //修改URL Model.CCOM.News model1 = new BLL.CCOM.News().GetModel(newsId); model1.News_URL = "/AdminMetro/CCOM/notification/ViewNews.aspx?id=" + DESEncrypt.Encrypt(newsId.ToString()); new BLL.CCOM.News().Update(model1); //生成静态页 NewsHtml.CreateHtml(newsId, false); } return(newsId); }
private bool DoUpdateUserInfo(long _id) { BLL.CCOM.User_property user_bll = new BLL.CCOM.User_property(); Model.CCOM.User_property user_model = user_bll.GetModel(_id); bool result = false; //国籍 user_model.UP_nation = Convert.ToInt32(this.ddl_UP_nation.SelectedValue); //民族 user_model.UP_nationality = Convert.ToInt32(this.ddl_UP_nationality.SelectedValue); //政治面貌 user_model.UP_politics = Convert.ToInt32(this.ddl_UP_politics.SelectedValue); //文化程度 user_model.UP_degree = Convert.ToInt32(this.ddl_UP_degree.SelectedValue); //高中毕业院校 user_model.UP_high_school = this.txt_UP_high_school.Text; //高考报名号 user_model.UP_CEE_number = this.txt_UP_CEE_number.Text; //省艺术联考考生号 user_model.UP_AEE_number = this.txt_UP_AEE_number.Text; //专业考试期间移动电话 user_model.UP_PE_Iphone = this.txt_UP_PE_Iphone.Text; //常规移动电话 user_model.UP_PE_Aphone = this.txt_UP_PE_Aphone.Text; //高考所在地 user_model.UP_province = Convert.ToInt32(this.ddl_UP_province.SelectedValue); //录取通知书地址 user_model.UP_address = this.txt_UP_address.Text; //收件人 user_model.UP_receiver = this.txt_UP_receiver.Text; //收件人电话 this.txt_UP_receiver_phone.Text = user_model.UP_receiver_phone; //邮编 user_model.UP_postal_code = this.txt_UP_postal_code.Text; //复印件证件图片 if (this.txt_UP_ID_picture.Text != "") { user_model.UP_ID_picture = Utils.Filter(this.txt_UP_ID_picture.Text.Trim()); } if (!String.IsNullOrEmpty(user_model.UP_ID_picture)) { //创建文件夹 FileOperate.FolderCreate(Utils.GetMapPath(DataDic.UP_ID_picture_Path)); //图片处理 String toFilePath = DataDic.UP_ID_picture_Path + DateTime.Now.Ticks.ToString() + FileOperate.GetPostfixStr(user_model.UP_ID_picture); FileOperate.FileMove(Server.MapPath(user_model.UP_ID_picture), Server.MapPath(toFilePath)); user_model.UP_ID_picture = toFilePath; } //上传近期免冠照片 if (this.txt_UP_picture.Text != "") { user_model.UP_picture = Utils.Filter(this.txt_UP_picture.Text.Trim()); } if (!String.IsNullOrEmpty(user_model.UP_picture)) { //创建文件夹 FileOperate.FolderCreate(Utils.GetMapPath(DataDic.UP_picture_Path)); //图片处理 String toFilePath = DataDic.UP_picture_Path + DateTime.Now.Ticks.ToString() + FileOperate.GetPostfixStr(user_model.UP_picture); FileOperate.FileMove(Server.MapPath(user_model.UP_picture), Server.MapPath(toFilePath)); user_model.UP_picture = toFilePath; } //上传省联考合格证 if (this.txt_UP_AEE_picture.Text != "") { user_model.UP_AEE_picture = Utils.Filter(this.txt_UP_AEE_picture.Text.Trim()); } if (!String.IsNullOrEmpty(user_model.UP_AEE_picture)) { //创建文件夹 FileOperate.FolderCreate(Utils.GetMapPath(DataDic.UP_AEE_picture_Path)); //图片处理 String toFilePath = DataDic.UP_AEE_picture_Path + DateTime.Now.Ticks.ToString() + FileOperate.GetPostfixStr(user_model.UP_AEE_picture); FileOperate.FileMove(Server.MapPath(user_model.UP_AEE_picture), Server.MapPath(toFilePath)); user_model.UP_AEE_picture = toFilePath; } //更新的状态 try { bool res = user_bll.Update(user_model); if (res == true) { return(res); } } catch { result = false; } return(result); }