/// <summary> /// 更新一条数据 /// </summary> public bool Update(MSCD.Model.EqptImage model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update b_EqptImage set "); strSql.Append("SmId=@SmId,"); strSql.Append("LayerName=@LayerName,"); strSql.Append("ImageName=@ImageName,"); strSql.Append("Image=@Image"); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@SmId", SqlDbType.Int, 4), new SqlParameter("@LayerName", SqlDbType.VarChar, 50), new SqlParameter("@ImageName", SqlDbType.VarChar, 255), new SqlParameter("@Image", SqlDbType.VarBinary), new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = model.SmId; parameters[1].Value = model.LayerName; parameters[2].Value = model.ImageName; parameters[3].Value = model.Image; parameters[4].Value = model.Id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MSCD.Model.EqptImage DataRowToModel(DataRow row) { MSCD.Model.EqptImage model = new MSCD.Model.EqptImage(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["SmId"] != null && row["SmId"].ToString() != "") { model.SmId = int.Parse(row["SmId"].ToString()); } if (row["LayerName"] != null) { model.LayerName = row["LayerName"].ToString(); } if (row["ImageName"] != null) { model.ImageName = row["ImageName"].ToString(); } if (row["Image"] != null && row["Image"].ToString() != "") { model.Image = (byte[])row["Image"]; } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MSCD.Model.EqptImage model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into b_EqptImage("); strSql.Append("SmId,LayerName,ImageName,Image)"); strSql.Append(" values ("); strSql.Append("@SmId,@LayerName,@ImageName,@Image)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@SmId", SqlDbType.Int, 4), new SqlParameter("@LayerName", SqlDbType.VarChar, 50), new SqlParameter("@ImageName", SqlDbType.VarChar, 255), new SqlParameter("@Image", SqlDbType.VarBinary) }; parameters[0].Value = model.SmId; parameters[1].Value = model.LayerName; parameters[2].Value = model.ImageName; parameters[3].Value = model.Image; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MSCD.Model.EqptImage DataRowToModel(DataRow row) { MSCD.Model.EqptImage model = new MSCD.Model.EqptImage(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = int.Parse(row["Id"].ToString()); } if (row["SmId"] != null && row["SmId"].ToString() != "") { model.SmId = int.Parse(row["SmId"].ToString()); } if (row["LayerName"] != null) { model.LayerName = row["LayerName"].ToString(); } if (row["ImageName"] != null) { model.ImageName = row["ImageName"].ToString(); } if (row["Image"] != null && row["Image"].ToString() != "") { model.Image = (byte[])row["Image"]; } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public MSCD.Model.EqptImage GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,SmId,LayerName,ImageName,Image from b_EqptImage "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; MSCD.Model.EqptImage model = new MSCD.Model.EqptImage(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public MSCD.Model.EqptImage GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Id,SmId,LayerName,ImageName,Image from b_EqptImage "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; MSCD.Model.EqptImage model = new MSCD.Model.EqptImage(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(MSCD.Model.EqptImage model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(MSCD.Model.EqptImage model) { return(dal.Add(model)); }