- using System;
- using System.Collections;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Web;
- using System.Web.SessionState;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- namespace iWebOffice.ocx.c.net.BookMark
- {
- /// <summary>
- /// BookMarkEdit 的摘要说明。
- /// </summary>
- public class BookMarkEdit : System.Web.UI.Page
- {
- protected System.Web.UI.WebControls.Label Label1;
- protected System.Web.UI.HtmlControls.HtmlInputText BookMarkName;
- protected System.Web.UI.HtmlControls.HtmlInputText BookMarkDesc;
- protected System.Web.UI.HtmlControls.HtmlInputText BookMarkText;
- protected System.Web.UI.HtmlControls.HtmlInputHidden BookMarkID;
- iDBManage2000 DBAobj;
- private void Page_Load(object sender, System.EventArgs e)
- {
- // 在此处放置用户代码以初始化页面
- bool mResult=false;
- SqlCommand nCommand;
- DBAobj=(iDBManage2000)Session["DBDemo"];
- if (IsPostBack)
- {
- string mBookMarkID,mBookMarkName,mBookMarkDesc,mBookMarkText;
- mBookMarkID=BookMarkID.Value.ToString();
- mBookMarkName=BookMarkName.Value.ToString();
- mBookMarkDesc=BookMarkDesc.Value.ToString();
- mBookMarkText=BookMarkText.Value.ToString();
- //判断是否存在相同标签
- string strSelectCmd="select BookMarkName from BookMarks where BookMarkID <> " + mBookMarkID + " and BookMarkName='" + mBookMarkName + "'";
- SqlCommand mCommand = new SqlCommand(strSelectCmd,DBAobj.Connection);
- SqlDataReader mReader = mCommand.ExecuteReader();
- if (mReader.Read())
- {
- mReader.Close();
- Label1.Text= "保存失败,数据库中已存在相同的标签";
- mResult=false;
- }
- else
- {
- mReader.Close();
- strSelectCmd="Update BookMarks Set BookMarkName = '" + mBookMarkName + "',BookMarkDesc = '" + mBookMarkDesc + "',BookMarkText='" + mBookMarkText + "' where BookMarkID=" + mBookMarkID;
- nCommand = new SqlCommand(strSelectCmd, DBAobj.Connection);
- nCommand.ExecuteNonQuery();
- mResult=true;
- }
- if (mResult)
- {
- Response.Redirect("BookMarkList.aspx");
- }
- }
- else
- {
- string mBookMarkID;
- BookMarkID.Value =Request["BookMarkID"].ToString();
- mBookMarkID=BookMarkID.Value.ToString();
- //判断是否存在相同标签
- string strSelectCmd="select * from BookMarks where BookMarkID = " + mBookMarkID ;
- SqlCommand mCommand = new SqlCommand(strSelectCmd,DBAobj.Connection);
- SqlDataReader mReader = mCommand.ExecuteReader();
- if (mReader.Read())
- {
- BookMarkName.Value = mReader["BookMarkName"].ToString();
- BookMarkDesc.Value = mReader["BookMarkDesc"].ToString();
- BookMarkText.Value = mReader["BookMarkText"].ToString();
- mReader.Close();
- mResult=false;
- }
- else
- {
- mReader.Close();
- Label1.Text= "数据库中不存在该标签。";
- mResult=false;
- }
- if (mResult)
- {
- Response.Redirect("BookMarkList.aspx");
- }
- }
- }
- #region Web Form Designer generated code
- override protected void OnInit(EventArgs e)
- {
- //
- // CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
- //
- InitializeComponent();
- base.OnInit(e);
- }
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- this.Load += new System.EventHandler(this.Page_Load);
- }
- #endregion
- }
- }