Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string idValue = Request.Params["id"];
         if (idValue != null)
         {
             int id = Convert.ToInt32(idValue);
             LMessageBB messageBB = new LMessageBB();
             try
             {
                 LMessageData messageData = new LMessageData();
                 messageData = messageBB.GetModel(id);
                 //����й��������˴�Ҫ��֤�Ƿ�����ɾ��
                 if (this.ValidateDataPermission(messageData.isrtEmpId))
                 {
                     messageBB.DeleteRecord(id);
                 }
                 this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
             }
             catch (Exception ex)
             {
                 this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3)", true);
                 return;
             }
             finally
             {
                 messageBB.Dispose();
             }
         }
     }
 }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(LMessageData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into LMessage(");
            strSql.Append(@"sort,title,content,fileId,level,isIndexShow,author,isrtDt,isrtEmpId)");
            strSql.Append(" values (");
            strSql.Append(@"@sort,@title,@content,@fileId,@level,@isIndexShow,@author,@isrtDt,@isrtEmpId)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@sort", SqlDbType.Int),
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@content", SqlDbType.NText),
                    new SqlParameter("@fileId", SqlDbType.NVarChar,100),
                    new SqlParameter("@level", SqlDbType.NVarChar,1),
                    new SqlParameter("@isIndexShow", SqlDbType.Bit),
                    new SqlParameter("@author", SqlDbType.NVarChar,10),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int)
                };
            parameters[0].Value = model.sort;
            parameters[1].Value = model.title;
            parameters[2].Value = model.content;
            parameters[3].Value = model.fileId;
            parameters[4].Value = model.level;
            parameters[5].Value = model.isIndexShow;
            parameters[6].Value = model.author;
            parameters[7].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[8].Value = model.isrtEmpId;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Пример #3
0
 /// <summary>
 /// չʾ����
 /// </summary>
 /// <param name="id">��¼Id</param>
 private void ShowInfo(int id)
 {
     SFileBB fileBB = new SFileBB();
     LMessageBB messageBB = new LMessageBB();
     LMessageData model = new LMessageData();
     try
     {
         model = messageBB.GetModel(id);
         this.title.Text = model.title;
         this.content.Value = model.content;
         this.fileId.Value = model.fileId;
         this.fileNm.Text = fileBB.GetBatchFileNm(model.fileId);
         if (this.sort.Items.FindByValue(model.sort.ToString()) != null)
         {
             this.sort.SelectedValue = model.sort.ToString();
         }
         this.author.Text = model.author;
         this.isIndexShow.Checked = model.isIndexShow;
     }
     finally
     {
         fileBB.Dispose();
         messageBB.Dispose();
     }
 }
Пример #4
0
 /// <summary>
 /// ʵ���ำֵ
 /// </summary>
 /// <param name="model">ʵ����ʵ��</param>
 private void SetModel(ref LMessageData model)
 {
     model.title = this.title.Text;
     model.content = this.content.Value;
     model.fileId = this.fileId.Value;
     if (this.sort.SelectedValue != "")
     {
         model.sort = Convert.ToInt32(this.sort.SelectedValue);
     }
     model.author = this.author.Text;
     model.isIndexShow = this.isIndexShow.Checked;
 }
Пример #5
0
    /// <summary>
    /// ���ݱ���
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        LMessageData model = new LMessageData();
        LMessageBB messageBB = new LMessageBB();
        try
        {
            if (this.State == "1")
            {
                //�����֤

                this.SetModel(ref model);
                model.isrtDt = DateTime.Now.ToString();
                model.isrtEmpId = this.currentUser.empId;
                this.IdValue = messageBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                //�����֤
                //if (this.isIndexShow.SelectedValue == "1")
                //{
                //    //���������֪ͨ�Ѿ�ѡ������ҳ��ʾ����ʾ�û�
                //    if (messageBB.GetList("isIndexShow=1 and id <>" + this.IdValue.ToString()).Tables[0].Rows.Count >= 5)
                //    {
                //        this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"�Ѿ���5��֪ͨѡ���˷�����������޸�!\");", true);
                //        return;
                //    }
                //}

                model = messageBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                messageBB.ModifyRecord(model);
            }
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3)", true);
            return;
        }
        finally
        {
            messageBB.Dispose();
        }

        Response.Redirect("LMessageList.aspx?itemNo=" + this.itemNo + "&pTypeNo=main", false);
    }
Пример #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(LMessageData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update LMessage set ");
            strSql.Append("sort=@sort,");
            strSql.Append("title=@title,");
            strSql.Append("content=@content,");
            strSql.Append("fileId=@fileId,");
            strSql.Append("level=@level,");
            strSql.Append("isIndexShow=@isIndexShow,");
            strSql.Append("author=@author,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("isrtEmpId=@isrtEmpId");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@sort", SqlDbType.Int),
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@content", SqlDbType.NText),
                    new SqlParameter("@fileId", SqlDbType.NVarChar,100),
                    new SqlParameter("@level", SqlDbType.NVarChar,1),
                    new SqlParameter("@isIndexShow", SqlDbType.Bit),
                    new SqlParameter("@author", SqlDbType.NVarChar,10),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.sort;
            parameters[2].Value = model.title;
            parameters[3].Value = model.content;
            parameters[4].Value = model.fileId;
            parameters[5].Value = model.level;
            parameters[6].Value = model.isIndexShow;
            parameters[7].Value = model.author;
            parameters[8].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[9].Value = model.isrtEmpId;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Пример #7
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public LMessageData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,sort,title,content,fileId,level,isIndexShow,author,isrtDt,isrtEmpId from LMessage");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            LMessageData model = new LMessageData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["sort"] != DBNull.Value)
                {
                    model.sort = Convert.ToInt32(row["sort"]);
                }
                if (row["title"] != DBNull.Value)
                {
                    model.title = Convert.ToString(row["title"]);
                }
                if (row["content"] != DBNull.Value)
                {
                    model.content = Convert.ToString(row["content"]);
                }
                if (row["fileId"] != DBNull.Value)
                {
                    model.fileId = Convert.ToString(row["fileId"]);
                }
                if (row["level"] != DBNull.Value)
                {
                    model.level = Convert.ToString(row["level"]);
                }
                if (row["isIndexShow"] != DBNull.Value)
                {
                    model.isIndexShow = Convert.ToBoolean(row["isIndexShow"]);
                }
                if (row["author"] != DBNull.Value)
                {
                    model.author = Convert.ToString(row["author"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Пример #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(LMessageData model)
 {
     return this.messageDB.ModifyRecord(model);
 }
Пример #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(LMessageData model)
 {
     return this.messageDB.AddRecord(model);
 }