public int UpdateRing(RingEntity t_Ring) { SqlParameter[] p=new SqlParameter[]{ new SqlParameter("@Ring_id",t_Ring.Ring_id), new SqlParameter("@Ring_name",t_Ring.Ring_name) }; int i=SqlDBHelp.GetExecute("update Ring set ring_id=@Ring_id,ring_name=@Ring_name where ring_id=@Ring_id", p) ; return i; }
//根据外键进行查询 //插入操作 public int InsertRing(RingEntity t_Ring) { //定义插入数据的参数数组 SqlParameter[] p=new SqlParameter[]{ new SqlParameter("@Ring_id",t_Ring.Ring_id), new SqlParameter("@Ring_name",t_Ring.Ring_name) }; int i=SqlDBHelp.GetExecute("insert into Ring values (@Ring_id,@Ring_name)", p) ; return i; }
//根据外键进行查询 //插入操作 public static int InsertRing(RingEntity t_Ring) { int i=-1; //定义插入数据的参数数组 try { i=dal.InsertRing(t_Ring); } catch(Exception ex) { throw new Exception(ex.Message); } return i; }
public RingEntity SelectRingByID(int t_ring_id) { RingEntity t_Ring= new RingEntity(); SqlDataReader sdr=null; using(sdr=SqlDBHelp.GetReader("select * from Ring where ring_id="+t_ring_id)) { if(sdr.Read()) { t_Ring.Ring_id=(int)sdr.GetValue(0); t_Ring.Ring_name=(string)sdr.GetValue(1); } } sdr.Close(); return t_Ring; }
//根据主键查询整个表 public IList<RingEntity> GetAllRing() { IList<RingEntity> t_Rings = new List<RingEntity>(); SqlDataReader sdr = null; using(sdr=SqlDBHelp.GetReader("select * from Ring")) { while(sdr.Read()) { RingEntity t_Ring= new RingEntity(); t_Ring.Ring_id=(int)sdr.GetValue(0); t_Ring.Ring_name=(string)sdr.GetValue(1); t_Rings.Add(t_Ring); } sdr.Close(); } return t_Rings; }