use crate::com::{FromDispatchNew, SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
#[derive(Debug)]
pub struct TiersAutre {
pub dispatch: IDispatch,
}
impl TiersAutre {
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
pub fn ct_num(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CT_Num", &[])?
.to_string()
}
pub fn set_ct_num(&self, numero: &str) -> SageResult<()> {
let param = SafeVariant::from_string(numero);
self.dispatch().call_method_by_name("SetCT_Num", &[param])?;
Ok(())
}
pub fn ct_intitule(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CT_Intitule", &[])?
.to_string()
}
pub fn set_ct_intitule(&self, intitule: &str) -> SageResult<()> {
let param = SafeVariant::from_string(intitule);
self.dispatch()
.call_method_by_name("SetCT_Intitule", &[param])?;
Ok(())
}
pub fn ct_type(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("CT_Type", &[])?
.to_i32()
}
pub fn ct_classement(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("CT_Classement", &[])?
.to_string()
}
pub fn set_ct_classement(&self, classement: &str) -> SageResult<()> {
let param = SafeVariant::from_string(classement);
self.dispatch()
.call_method_by_name("SetCT_Classement", &[param])?;
Ok(())
}
pub fn write(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Write", &[])?;
Ok(())
}
pub fn remove(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Remove", &[])?;
Ok(())
}
pub fn description(&self) -> SageResult<String> {
let numero = self.ct_num()?;
let intitule = self.ct_intitule()?;
Ok(format!("TiersAutre: {} - {}", numero, intitule))
}
}
impl FromDispatchNew for TiersAutre {
fn from_dispatch_new(dispatch: IDispatch) -> SageResult<Self> {
Ok(Self { dispatch })
}
}