📄 addphoto.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class WebPage_AddPhoto : System.Web.UI.Page
{
string VirtualPath = "";
private void Page_Load(object sender, System.EventArgs e)
{
//验证用户功能-------------------------------------------------
this.ValidUserStation();
//-------------------------------------------------------------
//初始化功能权限列表(临时放在这里)
if (!IsPostBack)
{
string strID = Request["ID"]; //基本信息ID
string strFunID = Request["FunID"]; //功能ID(标识执行的状态,新建、查看并编辑)
if (strID == null || strID == "")
{
strID = "-1";
}
ViewState["strID"] = strID;
if (strFunID == null || strFunID == "")
{
if (strID == null || strID == "")
{ strFunID = "2"; }
else
{ strFunID = "1"; }
}
this.FunID.Value = strFunID;
setControlAttributes();
switch (strFunID.Trim())
{
case "1": //查看
EditData(strID); //获取当前照片数据,并初始化界面
break;
case "2": //新建
NewData(strID); //清空界面,为新建照片做准备
break;
default: //新建
NewData(strID); //清空界面,为新建照片做准备
break;
}
}
}
//初始控件选择状态
private void setControlAttributes()
{
}
#region 查看并编辑照片
/// <summary>
/// 查看并编辑照片
/// </summary>
/// <param name="str_ID">照片ID</param>
private void EditData(string str_ID)
{
DataSet ds = new DataSet();
DAL.boBusiness bo = new DAL.boBusiness();
DAL.MakeConnection Conn = new DAL.MakeConnection();
DAL.clsDBConnkey ConnKey = new DAL.clsDBConnkey();
ConnKey = bo.loadkey();//得到config数据库连接;
string m_strSQL = "Select * From PhotoAlbum where ID="+str_ID;
ds = (DataSet)Conn.MakeConnectionMethod(m_strSQL, ConnKey, DAL.executeMethod.execute_DataSet, DAL.EnumDBType.Sql, VirtualPath);
DataView m_DV = ds.Tables[0].DefaultView;
//-----------------------------------------------------------------------
//初始化新闻编辑界面-----------------------------------------------------
if (m_DV.Count > 0)
{
string PhotoExplain = "";
if (m_DV[0].Row["PhotoExplain"].ToString().Length > 10)
{
PhotoExplain = m_DV[0].Row["PhotoExplain"].ToString().Substring(0, 10) + "...";
}
this.labFunState.Text = "查看&编辑<font color='gray'>『" + PhotoExplain + "』</font>";
this.imgState.Src = "~/image/Face/Modify.gif";
//获取(ProuductionShow)数据-----------------------------------------------------------
this.FunID.Value = "1";
this.Table_ID.Value = str_ID;
this.WebImage.Value = m_DV[0].Row["PhotoUrl"].ToString();
string VirtualUrl = GetVirtualPath.getVirtualPath("../index.aspx");
if (this.WebImage.Value != "")
{
this.ImgData.Src = m_DV[0].Row["PhotoUrl"].ToString();
//this.ImgData.Src = VirtualUrl + "/image/DefaultNews.jpg";
}
else
{
this.ImgData.Src ="~/image/DefaultNews.jpg";
}
this.WebImage.Value = m_DV[0].Row["PhotoUrl"].ToString();
this.PhotoExplain.Text = "";
this.CheckBoxList1.Items[0].Selected=true;
this.CheckBoxList1.Items[0].Selected=true;
}
else
{
this.labFunState.Text = "查看&编辑<font color='gray'>『新闻信息』</font>";
this.imgState.Src = "~/image/Face/Modify.gif";
}
//-----------------------------------------------------------------------
}
#endregion
#region 新建照片
/// <summary>
/// 新建照片
/// </summary>
private void NewData(string str_ID)
{
//初始化照片编辑界面-------------------------
try
{
this.labFunState.Text = "新建<font color='gray'>『照片』</font>";
this.imgState.Src = "~/Images/Face/New.gif";
//获取(CarType_Info)数据-----------------------------------------------------------
//ID,CarTypeName,Brand,GeneralDescription,DetailDescription,User_ID,ReleaseTime
this.FunID.Value = "2";
this.Table_ID.Value = "";
string VirtualPath = GetVirtualPath.getVirtualPath("../index.aspx");
this.ImgData.Src = "~/image/DefaultNews.jpg";
this.WebImage.Value = "";
this.PhotoExplain.Text = "";
this.CheckBoxList1.Items[0].Selected=true;
this.CheckBoxList1.Items[0].Selected=true;
}
catch
{
}
//-------------------------------------------
}
#endregion
#region 保存[新建或更新]的照片
/// <summary>
/// 保存[新建或更新]的照片
/// </summary>
private void SaveData()
{
string m_strSQL = "";
bool m_blnCheckValue = true;
DataSet ds = new DataSet();
DAL.boBusiness bo = new DAL.boBusiness();
DAL.MakeConnection Conn = new DAL.MakeConnection();
DAL.clsDBConnkey ConnKey = new DAL.clsDBConnkey();
ConnKey = bo.loadkey();//得到config数据库连接;
bool IsNominate=true,IsAffiche=true;
if (this.CheckBoxList1.Items[0].Selected)
{
IsAffiche = true;
}
else
{
IsAffiche = false;
}
if(this.CheckBoxList1.Items[1].Selected)
{
IsNominate = true;
}
else
{
IsNominate = false;
}
SqlCommand o_CommData = new SqlCommand();
switch (this.FunID.Value.Trim())
{
case "1": //修改
//获取(SurveyQuestion)数据-----------------------------------------------------------
//Question_ID,QuestionTitle,IsHomepage,IsMultiplicity,User_ID,ReleaseTime
m_strSQL = "Update PhotoAlbum"
+ " set PhotoUrl=@PhotoUrl,PhotoExplain=@PhotoExplain"
+ ",IsAffiche=@IsAffiche,CreateTime=@CreateTime,IsNominate=@IsNominate " //UserID=@UserID,
+ " Where"
+ " ID=@ID";
o_CommData.CommandText = m_strSQL;
o_CommData.Parameters.Clear();
o_CommData.Parameters.Add("@ID", SqlDbType.Int).Value = Convert.ToInt32(ViewState["strID"]);
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;
case "2": //新建
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -