public bool add(SBSGD sbqyd) { 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[5]; param[0] = new SqlParameter("@SBMC", sbqyd.Sbmc); param[1] = new SqlParameter("@SBXH", sbqyd.Sbxh); param[2] = new SqlParameter("@SGYY", sbqyd.Sgyy); param[3] = new SqlParameter("@SGR_ID", sbqyd.SgrId); param[4] = new SqlParameter("@SGSJ", sbqyd.Sgsj); foreach (DbParameter p in param) cmd.Parameters.Add(p); row = cmd.ExecuteNonQuery(); } } return row > 0; }
public SBSGD getEntity(int id) { SBSGD sbqyd = 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()) { sbqyd = new SBSGD(); sbqyd.Sbmc = reader["SBMC"].ToString(); sbqyd.Sbxh = reader["SBXH"].ToString(); sbqyd.Sgyy = reader["SGYY"].ToString(); sbqyd.SgrId = reader["SGR_ID"].ToString(); if (reader["SGSJ"] != null && reader["SGSJ"].ToString().Length > 0) sbqyd.Sgsj = DateTime.Parse(reader["SGSJ"].ToString()); sbqyd.Id = id; } } } } return sbqyd; }
public bool update(SBSGD entity) { return dao.update(entity); }
public bool add(SBSGD entity) { return dao.add(entity); }