/// <summary> /// 增加一条数据 /// </summary> public int Add(IPSP.Model.T_LawItem model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into T_LawItem("); strSql.Append("s_Code,s_FilePath,s_Creator,dt_CreateDate,n_FileID)"); strSql.Append(" values ("); strSql.Append("@s_Code,@s_FilePath,@s_Creator,@dt_CreateDate,@n_FileID)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@s_Code", SqlDbType.NVarChar, 50), new SqlParameter("@s_FilePath", SqlDbType.NVarChar, 500), new SqlParameter("@s_Creator", SqlDbType.NVarChar, 50), new SqlParameter("@dt_CreateDate", SqlDbType.DateTime), new SqlParameter("@n_FileID", SqlDbType.Int, 4) }; parameters[0].Value = model.s_Code; parameters[1].Value = model.s_FilePath; parameters[2].Value = model.s_Creator; parameters[3].Value = model.dt_CreateDate; parameters[4].Value = model.n_FileID; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public IPSP.Model.T_LawItem DataRowToModel(DataRow row) { IPSP.Model.T_LawItem model = new IPSP.Model.T_LawItem(); if (row != null) { if (row["n_ID"] != null && row["n_ID"].ToString() != "") { model.n_ID = int.Parse(row["n_ID"].ToString()); } if (row["s_Code"] != null) { model.s_Code = row["s_Code"].ToString(); } if (row["s_FilePath"] != null) { model.s_FilePath = row["s_FilePath"].ToString(); } if (row["s_Creator"] != null) { model.s_Creator = row["s_Creator"].ToString(); } if (row["dt_CreateDate"] != null && row["dt_CreateDate"].ToString() != "") { model.dt_CreateDate = DateTime.Parse(row["dt_CreateDate"].ToString()); } if (row["n_FileID"] != null && row["n_FileID"].ToString() != "") { model.n_FileID = int.Parse(row["n_FileID"].ToString()); } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(IPSP.Model.T_LawItem model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update T_LawItem set "); strSql.Append("s_Code=@s_Code,"); strSql.Append("s_FilePath=@s_FilePath,"); strSql.Append("s_Creator=@s_Creator,"); strSql.Append("dt_CreateDate=@dt_CreateDate"); strSql.Append(" where n_ID=@n_ID"); SqlParameter[] parameters = { new SqlParameter("@s_Code", SqlDbType.NVarChar, 50), new SqlParameter("@s_FilePath", SqlDbType.NVarChar, 500), new SqlParameter("@s_Creator", SqlDbType.NVarChar, 50), new SqlParameter("@dt_CreateDate", SqlDbType.DateTime), new SqlParameter("@n_ID", SqlDbType.Int, 4), new SqlParameter("@n_FileID", SqlDbType.Int, 4) }; parameters[0].Value = model.s_Code; parameters[1].Value = model.s_FilePath; parameters[2].Value = model.s_Creator; parameters[3].Value = model.dt_CreateDate; parameters[4].Value = model.n_ID; parameters[5].Value = model.n_FileID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public IPSP.Model.T_LawItem GetModel(int n_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 n_ID,s_Code,s_FilePath,s_Creator,dt_CreateDate,n_FileID from T_LawItem "); strSql.Append(" where n_ID=@n_ID"); SqlParameter[] parameters = { new SqlParameter("@n_ID", SqlDbType.Int, 4) }; parameters[0].Value = n_ID; IPSP.Model.T_LawItem model = new IPSP.Model.T_LawItem(); 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(IPSP.Model.T_LawItem model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(IPSP.Model.T_LawItem model) { return(dal.Add(model)); }