public bool add(SBWXSJD sbwxsjd) { 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[4]; param[0] = new SqlParameter("@SB_ID", sbwxsjd.SbId); param[1] = new SqlParameter("@GZMS", sbwxsjd.Gzms); param[2] = new SqlParameter("@SQR_ID", sbwxsjd.SqrId); param[3] = new SqlParameter("@SQSJ", sbwxsjd.Sqsj); foreach (DbParameter p in param) cmd.Parameters.Add(p); row = cmd.ExecuteNonQuery(); } } return row > 0; }
public bool update(SBWXSJD entity) { return dao.update(entity); }
public bool add(SBWXSJD entity) { return dao.add(entity); }
public SBWXSJD getEntity(int id) { SBWXSJD sbwxsjd = 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()) { sbwxsjd = new SBWXSJD(); sbwxsjd.SbId = int.Parse(reader["SB_ID"].ToString()); sbwxsjd.Gzms = reader["GZMS"].ToString(); sbwxsjd.SqrId = reader["SQR_ID"].ToString(); sbwxsjd.Gzms = reader["GZMS"].ToString(); if (reader["SQSJ"] != null && reader["SQSJ"].ToString().Length>0) sbwxsjd.Sqsj = DateTime.Parse(reader["SQSJ"].ToString()); sbwxsjd.Id = id; } } } } return sbwxsjd; }