コード例 #1
0
ファイル: EqptAttachment.cs プロジェクト: zfc317/mscd
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MSCD.Model.EqptAttachment DataRowToModel(DataRow row)
 {
     MSCD.Model.EqptAttachment model = new MSCD.Model.EqptAttachment();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["LayerName"] != null)
         {
             model.LayerName = row["LayerName"].ToString();
         }
         if (row["SmId"] != null && row["SmId"].ToString() != "")
         {
             model.SmId = int.Parse(row["SmId"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Attachment"] != null && row["Attachment"].ToString() != "")
         {
             model.Attachment = (byte[])row["Attachment"];
         }
     }
     return model;
 }
コード例 #2
0
ファイル: EqptAttachment.cs プロジェクト: zfc317/mscd
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MSCD.Model.EqptAttachment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update b_EqptAttachment set ");
            strSql.Append("LayerName=@LayerName,");
            strSql.Append("SmId=@SmId,");
            strSql.Append("Name=@Name,");
            strSql.Append("Attachment=@Attachment");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LayerName",  SqlDbType.VarChar,     50),
                new SqlParameter("@SmId",       SqlDbType.Int,          4),
                new SqlParameter("@Name",       SqlDbType.VarChar,    255),
                new SqlParameter("@Attachment", SqlDbType.VarBinary),
                new SqlParameter("@Id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.LayerName;
            parameters[1].Value = model.SmId;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Attachment;
            parameters[4].Value = model.Id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: EqptAttachment.cs プロジェクト: zfc317/mscd
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MSCD.Model.EqptAttachment model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into b_EqptAttachment(");
            strSql.Append("LayerName,SmId,Name,Attachment)");
            strSql.Append(" values (");
            strSql.Append("@LayerName,@SmId,@Name,@Attachment)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@LayerName",  SqlDbType.VarChar,  50),
                new SqlParameter("@SmId",       SqlDbType.Int,       4),
                new SqlParameter("@Name",       SqlDbType.VarChar, 255),
                new SqlParameter("@Attachment", SqlDbType.VarBinary)
            };
            parameters[0].Value = model.LayerName;
            parameters[1].Value = model.SmId;
            parameters[2].Value = model.Name;
            parameters[3].Value = model.Attachment;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
ファイル: EqptAttachment.cs プロジェクト: zfc317/mscd
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MSCD.Model.EqptAttachment DataRowToModel(DataRow row)
 {
     MSCD.Model.EqptAttachment model = new MSCD.Model.EqptAttachment();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["LayerName"] != null)
         {
             model.LayerName = row["LayerName"].ToString();
         }
         if (row["SmId"] != null && row["SmId"].ToString() != "")
         {
             model.SmId = int.Parse(row["SmId"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["Attachment"] != null && row["Attachment"].ToString() != "")
         {
             model.Attachment = (byte[])row["Attachment"];
         }
     }
     return(model);
 }
コード例 #5
0
ファイル: EqptAttachment.cs プロジェクト: zfc317/mscd
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MSCD.Model.EqptAttachment GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,LayerName,SmId,Name,Attachment from b_EqptAttachment ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

            MSCD.Model.EqptAttachment model = new MSCD.Model.EqptAttachment();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #6
0
ファイル: EqptAttachment.cs プロジェクト: zfc317/mscd
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MSCD.Model.EqptAttachment GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,LayerName,SmId,Name,Attachment from b_EqptAttachment ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            MSCD.Model.EqptAttachment model = new MSCD.Model.EqptAttachment();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }
コード例 #7
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(MSCD.Model.EqptAttachment model)
 {
     return(dal.Update(model));
 }
コード例 #8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(MSCD.Model.EqptAttachment model)
 {
     return(dal.Add(model));
 }