/// <summary> ///添加功能 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Add_Fac(object sender, DirectEventArgs e) { try { if (num == 0) { try { NoticePicInfo info = new NoticePicInfo(); info.Id = DateTime.Now.ToString("yyyyMMddHHmmss"); info.PicName = txtNewPicName.Text; info.Name = txtNewName.Text; info.Wfxw = txtNewWfxw.Text; info.DicDisc = txtNewPicDisc.Text; if (Session["userinfo"] != null) { info.Lrr = (Session["userinfo"] as UserInfo).UserName; } else { info.Lrr = "admin"; } info.Lrsj = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); PublicPath = settingManager.GetSettingPublicPath("00"); if (FileUploadField1.HasFile) { string typepic = FileUploadField1.PostedFile.ContentType; //获取图片上传格式 int imgsize = FileUploadField1.PostedFile.ContentLength; //获取图片大小 if (typepic == "image/bmp" || typepic == "image/gif" || typepic == "image/pjpeg" || typepic == "image/x-png" || typepic == "image/png" || typepic == "image/jpg" || typepic == "image/jpeg") { string savepic = FileUploadField1.PostedFile.FileName.ToString(); FileInfo ff = new FileInfo(savepic); string newp = ff.Name; string savetu = Server.MapPath("~/Capture/" + newp); FileUploadField1.PostedFile.SaveAs(savetu); info.PicUrl = PublicPath + "//" + newp + ""; } } if (noticeManager.AddNoticePic(info) > 0) { string lblname = ""; lblname += Bll.Common.AssembleRunLog("", info.Name, GetLangStr("NoticePicManager10", "公告名称"), "0"); lblname += Bll.Common.AssembleRunLog("", info.PicName, GetLangStr("NoticePicManager11", "公告简称"), "0"); lblname += Bll.Common.AssembleRunLog("", info.Wfxw, GetLangStr("NoticePicManager13", "违法行为"), "0"); lblname += Bll.Common.AssembleRunLog("", info.DicDisc, GetLangStr("NoticePicManager39", "描述"), "0"); lblname += Bll.Common.AssembleRunLog("", info.PicUrl, GetLangStr("NoticePicManager18", "文件"), "0"); logManager.InsertLogRunning(uName, GetLangStr("NoticePicManager41", "添加:") + lblname, nowIp, "1"); Notice(GetLangStr("NoticePicManager22", "信息提示"), GetLangStr("NoticePicManager23", "添加成功")); TbutQueryClick(null, null); DataRow[] dt = dtgg.Select("col0='" + info.Id + "'"); gg = dt[0]["col1"].ToString(); gj = dt[0]["col2"].ToString(); ms = dt[0]["col3"].ToString(); wx = dt[0]["col4"].ToString(); lj = dt[0]["col7"].ToString(); Window1.Hide(); } else { Notice(GetLangStr("NoticePicManager22", "信息提示"), GetLangStr("NoticePicManager24", "添加失败")); } } catch (Exception ex) { ILog.WriteErrorLog(ex); logManager.InsertLogError("NoticePicManager.aspx-Add_Fac", ex.Message + ";" + ex.StackTrace, "StoreDataBind has an exception"); } } else if (num == 1)//修改 { try { NoticePicInfo info = new NoticePicInfo(); info.Id = ggid; info.PicName = txtNewPicName.Text; info.Name = txtNewName.Text; info.Wfxw = txtNewWfxw.Text; info.DicDisc = txtNewPicDisc.Text; PublicPath = settingManager.GetSettingPublicPath("00"); if (FileUploadField1.HasFile) { string typepic = FileUploadField1.PostedFile.ContentType; //获取图片上传格式 int imgsize = FileUploadField1.PostedFile.ContentLength; //获取图片大小 if (typepic == "image/bmp" || typepic == "image/gif" || typepic == "image/pjpeg" || typepic == "image/x-png" || typepic == "image/png" || typepic == "image/jpg" || typepic == "image/jpeg") { string savepic = FileUploadField1.PostedFile.FileName.ToString(); FileInfo ff = new FileInfo(savepic); string newp = ff.Name; string savetu = Server.MapPath("~/Capture/" + newp); FileUploadField1.PostedFile.SaveAs(savetu); info.PicUrl = PublicPath + "//" + newp; } } if (noticeManager.EditNoticePic(info) > 0) { string gg1 = txtNewPicName.Text; string gj1 = txtNewName.Text; string wx1 = txtNewWfxw.Text; string ms1 = txtNewPicDisc.Text; string lj1 = info.PicUrl; string lblname = ""; lblname += Bll.Common.AssembleRunLog(gg, gg1, GetLangStr("NoticePicManager10", "公告名称"), "2"); lblname += Bll.Common.AssembleRunLog(gj, gj1, GetLangStr("NoticePicManager11", "公告简称"), "2"); lblname += Bll.Common.AssembleRunLog(wx, wx1, GetLangStr("NoticePicManager13", "违法行为"), "2"); lblname += Bll.Common.AssembleRunLog(ms, ms1, GetLangStr("NoticePicManager39", "描述"), "2"); lblname += Bll.Common.AssembleRunLog(lj, lj1, GetLangStr("NoticePicManager18", "文件"), "2"); if (!string.IsNullOrEmpty(lblname)) { logManager.InsertLogRunning(uName, GetLangStr("NoticePicManager42", "修改:") + lblname, nowIp, "1"); } else { Notice(GetLangStr("NoticePicManager22", "信息提示"), GetLangStr("NoticePicManager25", "未作任何修改!")); } TbutQueryClick(null, null); Window1.Hide(); } else { Notice(GetLangStr("NoticePicManager22", "信息提示"), GetLangStr("NoticePicManager26", "修改失败")); } Window1.Hide(); } catch (Exception ex) { ILog.WriteErrorLog(ex); logManager.InsertLogError("NoticePicManager.aspx-Add_Fac", ex.Message + ";" + ex.StackTrace, "StoreDataBind has an exception"); } } else { } } catch (Exception ex) { ILog.WriteErrorLog(ex); logManager.InsertLogError("NoticePicManager.aspx-Add_Fac", ex.Message + ";" + ex.StackTrace, "StoreDataBind has an exception"); } }