/// <summary> /// 保存 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { try { //输入校验 if (!Check()) { return; } string sTitle = txtTitle.Text; string sPeed = ddlSpead.SelectedValue; string sContent = newDesc.Value; string sWords = txtWordsCnt.Text; string sPhoto = ""; if (sWords == "") { sWords = sContent.Length.ToString(); } if (fileImg.HasFile) { string[] arrFile = fileImg.FileName.Split('.'); sPhoto = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "." + arrFile[arrFile.Length - 1]; string sPath = AppConfig.ImagePath + "test/"; if (Directory.Exists(sPath) == false) { Directory.CreateDirectory(sPath); } fileImg.SaveAs(sPath + sPhoto); ReSizeImageFile(sPath + sPhoto, 300, 400); } string sId = hidNewsId.Value; DBB100 db = new DBB100(); int iRet = 0; if (FC_Check.IsNotEmpty(sId))//修改 { iRet = db.Update(sId, sTitle, sPeed, sPhoto, sContent, sWords); } else//新建 { iRet = db.Insert(m_trainType, sTitle, sPeed, sPhoto, sContent, sWords); } if (iRet > 0) { Response.Redirect("B200.aspx"); } else { } } catch (Exception ex) { throw ex; } }