Пример #1
0
        public int xoaPhong(phong ph)
        {
            //string sqlstr = " delete Phong where MaPhong = '" + ph.getMaPhong + "' ";
            //cmd.ExcuteNonQuery(sqlstr);
            SqlConnection con = Config.getConnect();
            DataTable     dt  = new DataTable();

            if (con.State == ConnectionState.Closed)
            {
                con.Open();// mo ket noi sql
            }
            string     sqlstr = "delete Phong where MaPhong = '" + ph.getMaPhong() + "' ";
            SqlCommand cmd    = new SqlCommand(sqlstr, con);

            try
            {
                int rm = cmd.ExecuteNonQuery();

                con.Close();
                return(rm);
            }
            catch
            {
                throw;
            }
        }
Пример #2
0
        public int sua(phong ph)
        {
            SqlConnection con = Config.getConnect();
            DataTable     dt  = new DataTable();

            if (con.State == ConnectionState.Closed)
            {
                con.Open();// mo ket noi sql
            }
            string     sqlstr = "update Phong set TinhTrang = '" + ph.getTinhTrang() + "',GiaPhong = " + ph.getGiaPhong() + ",LoaiPhong = '" + ph.getLoaiPhong() + "' where MaPhong = '" + ph.getMaPhong() + "'";
            SqlCommand cmd    = new SqlCommand(sqlstr, con);

            try
            {
                int sa = cmd.ExecuteNonQuery();

                con.Close();
                return(sa);
            }
            catch
            {
                throw;
            }
        }
Пример #3
0
        public int themPhong(phong ph)
        {
            SqlConnection con = Config.getConnect();
            DataTable     dt  = new DataTable();

            if (con.State == ConnectionState.Closed)
            {
                con.Open();// mo ket noi sql
            }
            string     sqlstr = "INSERT INTO Phong values ('" + ph.getMaPhong() + "', '" + ph.getTinhTrang() + "', " + ph.getGiaPhong() + ",'" + ph.getLoaiPhong() + "')";
            SqlCommand cmd    = new SqlCommand(sqlstr, con);

            try
            {
                int add = cmd.ExecuteNonQuery();

                con.Close();
                return(add);
            }
            catch
            {
                throw;
            }
        }