use crate::com::{FromDispatchNew, SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
pub struct CompteA {
pub dispatch: IDispatch,
}
impl CompteA {
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
pub fn get_numero(&self) -> SageResult<String> {
let result = self.dispatch().get_property_by_name("Numero")?;
result.to_string()
}
pub fn get_intitule(&self) -> SageResult<String> {
let result = self.dispatch().get_property_by_name("Intitule")?;
result.to_string()
}
pub fn set_numero(&self, numero: &str) -> SageResult<()> {
let numero_variant = SafeVariant::from_string(numero);
self.dispatch()
.call_property_put("Numero", &[numero_variant])?;
Ok(())
}
pub fn set_intitule(&self, intitule: &str) -> SageResult<()> {
let intitule_variant = SafeVariant::from_string(intitule);
self.dispatch()
.call_property_put("Intitule", &[intitule_variant])?;
Ok(())
}
}
impl FromDispatchNew for CompteA {
fn from_dispatch_new(dispatch: IDispatch) -> SageResult<Self> {
Ok(Self { dispatch })
}
}