📄 addphoto.aspx.cs
字号:
//获取(SurveyQuestion)数据-----------------------------------------------------------
//Question_ID,QuestionTitle,IsHomepage,IsMultiplicity,User_ID,ReleaseTime
m_strSQL = "insert into PhotoAlbum"
+ " (PhotoUrl,PhotoExplain,IsAffiche,CreateTime,IsNominate) values (@PhotoUrl,@PhotoExplain,"
+ " @IsAffiche,@CreateTime,@IsNominate) ";
o_CommData.CommandText = m_strSQL;
o_CommData.Parameters.Clear();
o_CommData.Parameters.Add("@PhotoUrl", SqlDbType.NVarChar).Value = this.WebImage.Value.Trim();
o_CommData.Parameters.Add("@PhotoExplain", SqlDbType.NText).Value = this.PhotoExplain.Text;
o_CommData.Parameters.Add("@CreateTime", SqlDbType.DateTime).Value = System.DateTime.Now;
o_CommData.Parameters.Add("@IsAffiche", SqlDbType.Bit).Value = IsAffiche;
o_CommData.Parameters.Add("@IsNominate", SqlDbType.Bit).Value = IsNominate;
//----------------------------------------------------------
break;
}
string strErrMsg = "";
try
{
//执行保存(新建、更新)
if (m_blnCheckValue)
{
Conn.MakeConnectionSqlCommand(o_CommData, ConnKey,DAL.executeMethod.execute_NoneQuery,DAL.EnumDBType.Sql);
}
}
catch (Exception es)
{
strErrMsg = es.Message;
m_blnCheckValue = false;
}
finally
{
}
//当保存成功后刷新界面
if (m_blnCheckValue)
{
//if (this.FunID.Value.Trim() == "1")
//{
// Response.Redirect("SoftPublishList.aspx?FID=" + Session["CurrFunID"].ToString(), true);
//}
//else
//{
// Response.Redirect("AddSoftPublish.aspx?ID=&FunID=2", true);
//}
}
}
#endregion
////图片上传服务器
private void UpImage_Click(object sender, System.EventArgs e)
{
if (this.TxtLinkImgUrl.Value != "")
{
try
{
string strPath = (HttpContext.Current.Request.PhysicalApplicationPath + "\\upfiles\\ProductionImage\\");
string[] arrFileName = this.TxtLinkImgUrl.Value.Split("\\".ToCharArray());
string filename = arrFileName[arrFileName.Length - 1].ToString();
System.Web.HttpPostedFile file = this.TxtLinkImgUrl.PostedFile;
string VirtualPath = GetVirtualPath.getVirtualPath("../index.aspx");
file.SaveAs(VirtualPath + "upfiles\\ProductionImage\\" + filename);
this.WebImage.Value = "\\upfiles\\ProductionImage\\" + filename;
this.ImgData.Src = this.WebImage.Value;
string strUrl = "<script language='javascript'>"
+ "window.setTimeout(\"alert('上传文件成功!')\", 100);"
+ "</script>";
Response.Write(strUrl);
}
catch (System.Exception ex)
{
throw ex;
}
}
else
{
string strUrl = "<script language='javascript'>"
+ "window.setTimeout(\"alert('请选择本地图片路径!')\", 100);"
+ "</script>";
Response.Write(strUrl);
}
}
protected void btnSave_Click1(object sender, EventArgs e)
{
string strStateMsg = "";
if (this.FunID.Value.Trim() == "1")
{
//if (this.hidIsModify.Value.ToLower() != "modify")
//{ strStateMsg = "修改"; }
}
else if (this.FunID.Value.Trim() == "2")
{
//if (this.hidIsNew.Value.ToLower() != "new")
//{ strStateMsg = "新建"; }
}
else
{ return; }
SaveData();
}
protected void btnReturn_Click1(object sender, EventArgs e)
{
Response.Redirect("PhotoList.aspx", true);
}
protected void UpImage_Click1(object sender, EventArgs e)
{
if (this.TxtLinkImgUrl.Value != "")
{
try
{
string strPath = (HttpContext.Current.Request.PhysicalApplicationPath + "\\upfiles\\ProductionImage\\");
string[] arrFileName = this.TxtLinkImgUrl.Value.Split("\\".ToCharArray());
string filename = arrFileName[arrFileName.Length - 1].ToString();
System.Web.HttpPostedFile file = this.TxtLinkImgUrl.PostedFile;
string VirtualPath = GetVirtualPath.getVirtualPath("../index.aspx");
file.SaveAs(VirtualPath + "/upfiles/ProductionImage/" + filename);
this.WebImage.Value = "/upfiles/ProductionImage/" + filename;
this.ImgData.Src = this.WebImage.Value;
string strUrl = "<script language='javascript'>"
+ "window.setTimeout(\"alert('上传文件成功!')\", 100);"
+ "</script>";
Response.Write(strUrl);
}
catch (System.Exception ex)
{
throw ex;
}
}
else
{
string strUrl = "<script language='javascript'>"
+ "window.setTimeout(\"alert('请选择本地图片路径!')\", 100);"
+ "</script>";
Response.Write(strUrl);
}
}
#region 验证用户可使用的功能
/// <summary>
/// 验证用户身份
/// </summary>
/// <returns></returns>
private void ValidUserStation()
{
string userid = "";
HttpCookie Cookie = CheckLogin();
if (Cookie != null)
{
userid = Cookie["User_ID"].ToString();
}
else
{
Response.Write("<script language='javascript'>window.setTimeout(\" alert('您必须登陆才可以留言!')\",100);</script>");
return;
}
//如果用户账号和用户ID有一个为[Null],则说明当前Session已不可用或用户尚未登录,系统退回到登录页面
if (userid != "")
{
this.hidIsModify.Value = "modify";
this.hidIsNew.Value = "new";
}
else
{
ShowPrompt();
}
}
private void ShowPrompt()
{
string strUrl = "<script language='javascript'>"
+ "window.setTimeout(\"alert('系统检查到[会话已过期]或[您尚未登录],将自动转到登录页面!')\", 100);"
+ "</script>";
Response.Write(strUrl);
strUrl = "<script language='javascript'>"
+ "window.open("
+ "\"../ManageMain.aspx\","
+ "\"_top\","
+ "\"\""
+ ",true);"
+ "</script>";
Response.Write(strUrl);
Response.End();
return; ;
}
#endregion
#region CheckLogin()//个人用户是否登录<返回一个HttpCookie>
/// <summary>
/// 是否登录
/// </summary>
/// <returns></returns>
private HttpCookie CheckLogin()
{
HttpCookie Cookie = Request.Cookies["Message"];
HttpCookie retCookie = null;
if (Cookie == null || Cookie.ToString() == "")
{
return retCookie;
}
else
{
retCookie = Request.Cookies["Message"];
return retCookie;
}
}
#endregion
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -