/// <summary>
 /// չʾ����
 /// </summary>
 /// <param name="id">��¼Id</param>
 private void ShowInfo(int id)
 {
     SFileBB fileBB = new SFileBB();
     LMessageBB messageBB = new LMessageBB();
     vLMessageData model = new vLMessageData();
     try
     {
         model = messageBB.GetVModel(id);
         this.title.Text = model.title;
         this.content.Text = model.content;
         this.fileId.Text = fileBB.GetDownBatchFileNm(model.fileId);
         this.sort.Text = model.sortNm;
         this.author.Text = model.author;
     }
     finally
     {
         fileBB.Dispose();
         messageBB.Dispose();
     }
     //�����Ѷ��˴�
     SCommBB commBB = new SCommBB();
     try
     {
         string strSql = "select count(distinct empId) from LMessageReaded where messageId=" + id.ToString();
         this.readedEmpCount.Text = commBB.ExecuteScalar(strSql).ToString();
     }
     finally
     {
         commBB.Dispose();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 得到一个视图model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public vLMessageData GetVModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,title,content,fileId,isIndexShow,author,isrtDt,isrtEmpId,level,sort,sortNm,
                            isIndexShowDesc,downFileNm from vLMessage");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            vLMessageData model = new vLMessageData();
            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["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["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"]);
                }
                if (row["level"] != DBNull.Value)
                {
                    model.level = Convert.ToString(row["level"]);
                }
                if (row["sort"] != DBNull.Value)
                {
                    model.sort = Convert.ToInt32(row["sort"]);
                }
                if (row["sortNm"] != DBNull.Value)
                {
                    model.sortNm = Convert.ToString(row["sortNm"]);
                }
                if (row["isIndexShowDesc"] != DBNull.Value)
                {
                    model.isIndexShowDesc = Convert.ToString(row["isIndexShowDesc"]);
                }
                if (row["downFileNm"] != DBNull.Value)
                {
                    model.downFileNm = Convert.ToString(row["downFileNm"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }