public bool add(BZSGDX bzsgdx) { 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[3]; param[0] = new SqlParameter("@BZH", bzsgdx.Bzh); param[1] = new SqlParameter("@BZMC", bzsgdx.Bzmc); param[2] = new SqlParameter("@SGD_ID", bzsgdx.SgdId); foreach (DbParameter p in param) cmd.Parameters.Add(p); row = cmd.ExecuteNonQuery(); } } return row > 0; }
public BZSGDX getEntity(int id) { BZSGDX bzsgdx = 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()) { bzsgdx = new BZSGDX(); bzsgdx.Bzh = reader["BZH"].ToString(); bzsgdx.Bzmc = reader["BZMC"].ToString(); bzsgdx.SgdId = int.Parse(reader["SGD_ID"].ToString()); bzsgdx.Id = id; } } } } return bzsgdx; }
public bool update(BZSGDX bzsgdx) { return dao.update(bzsgdx); }
public bool add(BZSGDX bzsgdx) { return dao.add(bzsgdx); }