protected void btnAdd_Click(object sender, ImageClickEventArgs e) { string fileName = fileName = CommonFunction.Get_DynamicString() + FileUploadImg.FileName; string vfileName = "v_" + fileName; string vvfileName = "vv_" + fileName; string file_Path = Server.MapPath("~/CertificateImg/" + fileName); string vfile_Path = Server.MapPath("~/CertificateImg/" + vfileName); string vvfile_Path = Server.MapPath("~/CertificateImg/" + vvfileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadImg, Literal1, file_Path, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } ImgUploadFunction.MakeThumbnail(file_Path, vfile_Path, 120, 90, "W"); ImgUploadFunction.MakeThumbnail(file_Path, vvfile_Path, 600, 450, "W"); System.IO.File.Delete(file_Path); ServiceNews news = new ServiceNews(); news.N_Title = "[" + vfileName + "]{" + vvfileName + "}"; news.N_Content = txtRemark.Text; news.N_SID = ((UserInfo)Session["ServiceUser"]).U_SID; news.N_Time = DateTime.Now; news.N_NewsType = "9"; news.N_From = "本站原创"; ServiceNewService.Insert_News(news); CommonFunction.AlertAndRedirect(Literal1, "操作成功", "CertificateMgr.aspx"); }
/// <summary> /// 上传服务队伍图片 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnFWDW_Click(object sender, ImageClickEventArgs e) { string fileName = CommonFunction.Get_DynamicString() + FileUploadFWDW.FileName; string vfileName = "v_" + fileName; string filePath = Server.MapPath("~/ServiceImg/" + fileName); string vfilePath = Server.MapPath("~/ServiceImg/" + vfileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadFWDW, Literal1, filePath, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } ImgUploadFunction.MakeThumbnail(filePath, vfilePath, 600, 480, "W"); System.IO.File.Delete(filePath); ServiceInfoService.Update_ServiceImage(Convert.ToInt32(ViewState["S_ID"]), "S_FWDWImage", vfileName); ImgFWDW.ImageUrl = "../ServiceImg/" + vfileName; }
protected void btnSaveImage_Click(object sender, ImageClickEventArgs e) { if (ViewState["strAction"].ToString() == "add" || FileUploadImg.HasFile) { string fileName = CommonFunction.Get_DynamicString() + FileUploadImg.FileName; string vfileName = "v_" + fileName; string vvfileName = "vv_" + fileName; string filePath = Server.MapPath("~/newsImages/" + fileName); string vfilePath = Server.MapPath("~/newsImages/" + vfileName); string vvfilePath = Server.MapPath("~/newsImages/" + vvfileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadImg, Literal1, filePath, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } ImgUploadFunction.MakeThumbnail(filePath, vfilePath, 150, 112, "W"); ImgUploadFunction.MakeThumbnail(filePath, vvfilePath, 600, 480, "W"); System.IO.File.Delete(filePath); ViewState["VImgURL"] = vfileName; ViewState["VVImgURL"] = vvfileName; } string strContent = Request.Form["t_contents"].ToString(); string strTitle = "(" + txtTitle.Text + ")[" + ViewState["VImgURL"].ToString() + "]{" + ViewState["VVImgURL"].ToString() + "}"; ServiceNews news = new ServiceNews(); news.N_Title = strTitle; news.N_Content = strContent; news.N_From = "本站原创"; news.N_SID = ((UserInfo)Session["ServiceUser"]).U_SID; news.N_NewsType = "6"; news.N_Time = DateTime.Parse(txtdate.Text.Trim()); if (ViewState["strAction"].ToString() == "update") { news.N_ID = Convert.ToInt32(ViewState["nid"]); ServiceNewService.Update_News(news); } else if (ViewState["strAction"].ToString() == "add") { ServiceNewService.Insert_News(news); } CommonFunction.AlertAndRedirect(Literal1, "操作成功", "blank.aspx"); }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { if (FileUploadImgA.HasFile) { string fileName = CommonFunction.Get_DynamicString() + FileUploadImgA.FileName; string vfileName = "v_" + fileName; string file_Path = Server.MapPath("~/newspaper/" + fileName); string vfile_Path = Server.MapPath("~/newspaper/" + vfileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadImgA, Literal1, file_Path, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } ImgUploadFunction.MakeThumbnail(file_Path, vfile_Path, 152, 225, "HW"); ViewState["strAImg"] = fileName; ViewState["strAImgView"] = vfileName; } if (FileUploadImgB.HasFile) { string fileName = CommonFunction.Get_DynamicString() + FileUploadImgB.FileName; string vfileName = "v_" + fileName; string file_Path = Server.MapPath("~/newspaper/" + fileName); string vfile_Path = Server.MapPath("~/newspaper/" + vfileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadImgB, Literal1, file_Path, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } ImgUploadFunction.MakeThumbnail(file_Path, vfile_Path, 152, 225, "HW"); ViewState["strBImg"] = fileName; ViewState["strBImgView"] = vfileName; } if (FileUploadImgC.HasFile) { string fileName = CommonFunction.Get_DynamicString() + FileUploadImgC.FileName; string vfileName = "v_" + fileName; string file_Path = Server.MapPath("~/newspaper/" + fileName); string vfile_Path = Server.MapPath("~/newspaper/" + vfileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadImgC, Literal1, file_Path, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } ImgUploadFunction.MakeThumbnail(file_Path, vfile_Path, 152, 225, "HW"); ViewState["strCImg"] = fileName; ViewState["strCImgView"] = vfileName; } if (FileUploadImgD.HasFile) { string fileName = CommonFunction.Get_DynamicString() + FileUploadImgD.FileName; string vfileName = "v_" + fileName; string file_Path = Server.MapPath("~/newspaper/" + fileName); string vfile_Path = Server.MapPath("~/newspaper/" + vfileName); if (!CommonFunction.Is_FileUploadSuccessfully(FileUploadImgD, Literal1, file_Path, new string[] { ".gif", ".jpg", ".jpeg" })) { return; } ImgUploadFunction.MakeThumbnail(file_Path, vfile_Path, 152, 225, "HW"); ViewState["strDImg"] = fileName; ViewState["strDImgView"] = vfileName; } NewsPaper paper = new NewsPaper(); paper.N_Title = txtTitle.Text; paper.N_Time = txtTime.Text; paper.N_AImg = ViewState["strAImg"].ToString(); paper.N_AImgView = ViewState["strAImgView"].ToString(); paper.N_BImg = ViewState["strBImg"].ToString(); paper.N_BImgView = ViewState["strBImgView"].ToString(); paper.N_CImg = ViewState["strCImg"].ToString(); paper.N_CImgView = ViewState["strCImgView"].ToString(); paper.N_DImg = ViewState["strDImg"].ToString(); paper.N_DImgView = ViewState["strDImgView"].ToString(); if (ViewState["strAction"].ToString() == "update") { paper.N_ID = Convert.ToInt32(ViewState["nid"]); NewsPaperService.Update_NewsPaper(paper); } else if (ViewState["strAction"].ToString() == "add") { NewsPaperService.Insert_NewsPaper(paper); } CommonFunction.AlertAndRedirect(Literal1, "操作成功", "NewsPaperMgr.aspx"); }