public bool add(SBWJ sbwj) { int row = 0; using (DbConnection conn = new SqlConnection(SQLString.connString)) { conn.Open(); using (DbCommand cmd = conn.CreateCommand()) { cmd.CommandText = ADD; cmd.CommandType = CommandType.Text; DbParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@SB_ID", sbwj.SbId); param[1] = new SqlParameter("@WJ", sbwj.Wj); foreach (DbParameter p in param) cmd.Parameters.Add(p); row = cmd.ExecuteNonQuery(); } } return row > 0; }
public SBWJ getEntity(int id) { SBWJ sbwj = null; using (DbConnection conn = new SqlConnection(SQLString.connString)) { conn.Open(); using (DbCommand cmd = conn.CreateCommand()) { cmd.CommandText = GET_ENTITY; cmd.CommandType = CommandType.Text; DbParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@ID", id); foreach (DbParameter p in param) cmd.Parameters.Add(p); DbDataReader reader = cmd.ExecuteReader(); using (reader) { if (reader.Read()) { sbwj = new SBWJ(); sbwj.SbId = int.Parse(reader["SB_ID"].ToString()); sbwj.Wj = reader["WJ"].ToString(); sbwj.Id = id; } } } } return sbwj; }
public bool update(SBWJ entity) { return dao.update(entity); }
public bool add(SBWJ entity) { return dao.add(entity); }