コード例 #1
0
        public int suakhachhang(khachhang kh)
        {
            SqlConnection con = Config.getConnect();
            DataTable     dt  = new DataTable();

            if (con.State == ConnectionState.Closed)
            {
                con.Open();// mo ket noi sql
            }
            string     sqlstr = "update KhachHang set DiaChi = '" + kh.getDiaChi() + "',SDT = " + kh.getSDT() + ",MaPhong = '" + kh.getMaPhong() + "',NgayThue = '" + kh.getNgayThue() + "',NgayTra = '" + kh.getNgayTra() + "' where HoTen = '" + kh.getHoTen() + "'";
            SqlCommand cmd    = new SqlCommand(sqlstr, con);

            try
            {
                int sa = cmd.ExecuteNonQuery();

                con.Close();
                return(sa);
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
        public int themkhachhang(khachhang kh)
        {
            SqlConnection con = Config.getConnect();
            DataTable     dt  = new DataTable();

            if (con.State == ConnectionState.Closed)
            {
                con.Open();// mo ket noi sql
            }
            string     sqlstr = "INSERT INTO KhachHang values ('" + kh.getHoTen() + "', '" + kh.getDiaChi() + "', '" + kh.getSDT() + "','" + kh.getMaPhong() + "','" + kh.getNgayThue() + "','" + kh.getNgayTra() + "')";
            SqlCommand cmd    = new SqlCommand(sqlstr, con);

            try
            {
                int add = cmd.ExecuteNonQuery();

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