Пример #1
0
 public bool add(BZ bz)
 {
     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[10];
             param[0] = new SqlParameter("@BZH", bz.Bzh);
             param[1] = new SqlParameter("@BZMC", bz.Bzmc);
             param[2] = new SqlParameter("@FBSJ", bz.Fbsj);
             param[3] = new SqlParameter("@SSSJ", bz.Sssj);
             param[4] = new SqlParameter("@ZFSJ", bz.Zfsj);
             param[5] = new SqlParameter("@ZT", bz.Zt);
             param[6] = new SqlParameter("@TDBZ", bz.Tdbz);
             param[7] = new SqlParameter("@BZZY", bz.Bzzy);
             param[8] = new SqlParameter("@CJR_ID", bz.CjrId);
             param[9] = new SqlParameter("@CJSJ", bz.Cjsj);
             foreach (DbParameter p in param)
                 cmd.Parameters.Add(p);
             row = cmd.ExecuteNonQuery();
         }
     }
     return row > 0;
 }
Пример #2
0
 public bool update(BZ bz)
 {
     return bzdao.update(bz);
 }
Пример #3
0
 public BZ getEntity(int id)
 {
     BZ bz = 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())
                 {
                     bz = new BZ();
                     bz.Bzh = reader["BZH"].ToString();
                     bz.Bzmc = reader["BZMC"].ToString();
                     bz.Bzzy = reader["BZZY"].ToString();
                     bz.CjrId = reader["CJR_ID"].ToString();
                     if(reader["CJSJ"] != null && reader["CJSJ"].ToString().Length >0)
                         bz.Cjsj = DateTime.Parse(reader["CJSJ"].ToString());
                     if (reader["FBSJ"] != null && reader["FBSJ"].ToString().Length > 0)
                         bz.Fbsj = DateTime.Parse(reader["FBSJ"].ToString());
                     bz.Id = id;
                     if (reader["SSSJ"] != null && reader["SSSJ"].ToString().Length > 0)
                         bz.Sssj = DateTime.Parse(reader["SSSJ"].ToString());
                     bz.Tdbz = reader["TDBZ"].ToString();
                     if (reader["ZFSJ"] != null && reader["ZFSJ"].ToString().Length > 0)
                         bz.Zfsj = DateTime.Parse(reader["ZFSJ"].ToString());
                     bz.Zt = int.Parse(reader["ZT"].ToString());
                 }
             }
         }
     }
     return bz;
 }
Пример #4
0
 public bool add(BZ bz)
 {
     return bzdao.add(bz);
 }