/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.NL_Picture model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into dbo.[NL_Picture]("); strSql.Append("ConsultId,Base64Code,ImgId,IsDeleted,CreateId,CreateDate,EditId,EditDate"); strSql.Append(") values ("); strSql.Append("@ConsultId,@Base64Code,@ImgId,@IsDeleted,@CreateId,@CreateDate,@EditId,@EditDate"); strSql.Append(") "); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@ConsultId", model.ConsultId), new SqlParameter("@Base64Code", model.Base64Code), new SqlParameter("@ImgId", model.ImgId), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@CreateDate", model.CreateDate), new SqlParameter("@EditId", model.EditId), new SqlParameter("@EditDate", model.EditDate) }; object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public BWJS.Model.NL_Picture GetModel(int PictiureId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select PictiureId, ConsultId, Base64Code, ImgId, IsDeleted, CreateId, CreateDate, EditId, EditDate "); strSql.Append(" from dbo.[NL_Picture] "); strSql.Append(" where PictiureId=@PictiureId"); SqlParameter[] parameters = { new SqlParameter("@PictiureId", SqlDbType.Int, 4) }; parameters[0].Value = PictiureId; BWJS.Model.NL_Picture model = new BWJS.Model.NL_Picture(); DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// datarow转成对象实体 /// </summary> public BWJS.Model.NL_Picture DataRowToModel(DataRow row) { BWJS.Model.NL_Picture model = new BWJS.Model.NL_Picture(); if (row != null) { if (row["PictiureId"].ToString() != "") { model.PictiureId = int.Parse(row["PictiureId"].ToString()); } if (row["ConsultId"].ToString() != "") { model.ConsultId = int.Parse(row["ConsultId"].ToString()); } model.Base64Code = row["Base64Code"].ToString(); model.ImgId = row["ImgId"].ToString(); if (row["IsDeleted"].ToString() != "") { model.IsDeleted = int.Parse(row["IsDeleted"].ToString()); } if (row["CreateId"].ToString() != "") { model.CreateId = int.Parse(row["CreateId"].ToString()); } if (row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["EditId"].ToString() != "") { model.EditId = int.Parse(row["EditId"].ToString()); } if (row["EditDate"].ToString() != "") { model.EditDate = DateTime.Parse(row["EditDate"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.NL_Picture model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dbo.[NL_Picture] set "); strSql.Append(" ConsultId = @ConsultId , "); strSql.Append(" Base64Code = @Base64Code , "); strSql.Append(" ImgId = @ImgId , "); strSql.Append(" IsDeleted = @IsDeleted , "); strSql.Append(" CreateId = @CreateId , "); strSql.Append(" CreateDate = @CreateDate , "); strSql.Append(" EditId = @EditId , "); strSql.Append(" EditDate = @EditDate "); strSql.Append(" where PictiureId=@PictiureId "); SqlParameter[] parameters = { new SqlParameter("@PictiureId", model.PictiureId), new SqlParameter("@ConsultId", model.ConsultId), new SqlParameter("@Base64Code", model.Base64Code), new SqlParameter("@ImgId", model.ImgId), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@CreateDate", model.CreateDate), new SqlParameter("@EditId", model.EditId), new SqlParameter("@EditDate", model.EditDate) }; int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.NL_Picture model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.NL_Picture model) { return(dal.Add(model)); }