示例#1
0
        public static int Add(LoaiSachDto loaiSach)
        {
            OleDbConnection cn;
            cn = DataProvider.ConnectionData();

            string strSQL;
            strSQL = "Insert into LoaiSach(MLoaiSach,TenLoaiSach) values (?,?)";
            OleDbCommand cmd = new OleDbCommand(strSQL, cn);
            cmd.Parameters.Add("@MLoaiSach", OleDbType.Integer);
            cmd.Parameters.Add("@TenLoaiSach", OleDbType.WChar);
            cmd.Parameters["@MLoaiSach"].Value = loaiSach.MLoaiSach;
            cmd.Parameters["@TenLoaiSach"].Value = loaiSach.TenLoaiSach;

            cmd.ExecuteNonQuery();
            strSQL = "Select @@IDENTITY";
            cmd = new OleDbCommand(strSQL, cn);
            loaiSach.MLoaiSach = (int)cmd.ExecuteScalar();
            cn.Close();
            return loaiSach.MLoaiSach;
        }
示例#2
0
 public static IList GetList()
 {
     ArrayList ds = new ArrayList();
     OleDbConnection cn;
     cn = DataProvider.ConnectionData();
     string strSQL;
     strSQL = "Select * From LoaiSach";
     OleDbCommand cmd = new OleDbCommand(strSQL, cn);
     OleDbDataReader dr;
     dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         LoaiSachDto loaiSach = new LoaiSachDto();
         loaiSach.MLoaiSach = (int)dr["MLoaiSach"];
         loaiSach.TenLoaiSach = (String)dr["TenLoaiSach"];
         ds.Add(loaiSach);
     }
     dr.Close();
     cn.Close();
     return ds;
 }
示例#3
0
 public static LoaiSachDto Search(int maLoaiSach)
 {
     LoaiSachDto loaiSach = null;
     OleDbConnection cn;
     cn = DataProvider.ConnectionData();
     string strSQL;
     strSQL = "Select * From LoaiSach Where MLoaiSach= ? ";
     OleDbCommand cmd = new OleDbCommand(strSQL, cn);
     cmd.Parameters.Add("@MLoaiSach", OleDbType.Integer);
     cmd.Parameters["@MLoaiSach"].Value = maLoaiSach;
     OleDbDataReader dr;
     dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         loaiSach = new LoaiSachDto();
         loaiSach.MLoaiSach = (int)dr["MLoaiSach"];
         loaiSach.TenLoaiSach = (String)dr["TenLoaiSach"];
     }
     dr.Close();
     cn.Close();
     return loaiSach;
 }
示例#4
0
        public static void Update(LoaiSachDto loaiSach)
        {
            OleDbConnection cn;

            cn = DataProvider.ConnectionData();
            string strSQL;
            strSQL = "Update LoaiSach Set MLoaiSach = ? , TenLoaiSach = ? Where MLoaiSach = ?";
            OleDbCommand cmd = new OleDbCommand(strSQL, cn);
            cmd.Parameters.Add("@MLoaiSach", OleDbType.Integer);
            cmd.Parameters.Add("@TenLoaiSach", OleDbType.WChar);

            cmd.Parameters["@MLoaiSach"].Value = loaiSach.MLoaiSach;
            cmd.Parameters["@TenLoaiSach"].Value = loaiSach.TenLoaiSach;

            cmd.ExecuteNonQuery();
            cn.Close();
        }
示例#5
0
 public static void Update(LoaiSachDto loaiSach)
 {
     LoaiSachDao.Update(loaiSach);
 }
示例#6
0
 public static int Add(LoaiSachDto loaiSach)
 {
     return LoaiSachDao.Add(loaiSach);
 }