use crate::com::{FromDispatchNew, SafeDispatch, SafeVariant};
use crate::errors::SageResult;
use windows::Win32::System::Com::IDispatch;
#[derive(Debug)]
pub struct Reglement {
pub dispatch: IDispatch,
}
impl Reglement {
fn dispatch(&self) -> SafeDispatch<'_> {
SafeDispatch::new(&self.dispatch)
}
pub fn rg_code(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("RG_Code", &[])?
.to_string()
}
pub fn rg_intitule(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("RG_Intitule", &[])?
.to_string()
}
pub fn rg_type(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("RG_Type", &[])?
.to_i32()
}
pub fn rg_condition(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("RG_Condition", &[])?
.to_i32()
}
pub fn rg_nb_jour(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("RG_NbJour", &[])?
.to_i32()
}
pub fn rg_fin_mois(&self) -> SageResult<bool> {
self.dispatch()
.call_method_by_name("RG_FinMois", &[])?
.to_bool()
}
pub fn rg_jour(&self) -> SageResult<i32> {
self.dispatch()
.call_method_by_name("RG_Jour", &[])?
.to_i32()
}
pub fn rg_le(&self) -> SageResult<i32> {
self.dispatch().call_method_by_name("RG_Le", &[])?.to_i32()
}
pub fn rg_compte(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("RG_Compte", &[])?
.to_string()
}
pub fn rg_taux_escompte(&self) -> SageResult<f64> {
self.dispatch()
.call_method_by_name("RG_TauxEscompte", &[])?
.to_f64()
}
pub fn rg_compte_escompte(&self) -> SageResult<String> {
self.dispatch()
.call_method_by_name("RG_CompteEscompte", &[])?
.to_string()
}
pub fn set_rg_code(&mut self, value: &str) -> SageResult<()> {
let variant = SafeVariant::from_string(value);
self.dispatch().call_method_by_name("RG_Code", &[variant])?;
Ok(())
}
pub fn set_rg_intitule(&mut self, value: &str) -> SageResult<()> {
let variant = SafeVariant::from_string(value);
self.dispatch()
.call_method_by_name("RG_Intitule", &[variant])?;
Ok(())
}
pub fn set_rg_type(&mut self, value: i32) -> SageResult<()> {
let variant = SafeVariant::from_i32(value);
self.dispatch().call_method_by_name("RG_Type", &[variant])?;
Ok(())
}
pub fn set_rg_condition(&mut self, value: i32) -> SageResult<()> {
let variant = SafeVariant::from_i32(value);
self.dispatch()
.call_method_by_name("RG_Condition", &[variant])?;
Ok(())
}
pub fn set_rg_nb_jour(&mut self, value: i32) -> SageResult<()> {
let variant = SafeVariant::from_i32(value);
self.dispatch()
.call_method_by_name("RG_NbJour", &[variant])?;
Ok(())
}
pub fn set_rg_fin_mois(&mut self, value: bool) -> SageResult<()> {
let variant = SafeVariant::from_bool(value);
self.dispatch()
.call_method_by_name("RG_FinMois", &[variant])?;
Ok(())
}
pub fn set_rg_jour(&mut self, value: i32) -> SageResult<()> {
let variant = SafeVariant::from_i32(value);
self.dispatch().call_method_by_name("RG_Jour", &[variant])?;
Ok(())
}
pub fn set_rg_compte(&mut self, value: &str) -> SageResult<()> {
let variant = SafeVariant::from_string(value);
self.dispatch()
.call_method_by_name("RG_Compte", &[variant])?;
Ok(())
}
pub fn set_rg_taux_escompte(&mut self, value: f64) -> SageResult<()> {
let variant = SafeVariant::from_f64(value);
self.dispatch()
.call_method_by_name("RG_TauxEscompte", &[variant])?;
Ok(())
}
pub fn set_rg_le(&self, le: i32) -> SageResult<()> {
let le_variant = SafeVariant::from_i32(le);
self.dispatch().call_property_put("RG_Le", &[le_variant])?;
Ok(())
}
pub fn set_rg_compte_escompte(&self, compte: &str) -> SageResult<()> {
let compte_variant = SafeVariant::from_string(compte);
self.dispatch()
.call_property_put("RG_CompteEscompte", &[compte_variant])?;
Ok(())
}
pub fn is_persistant(&self) -> SageResult<bool> {
let result = self
.dispatch()
.call_method_by_name("IsPersistant", &[])?
.to_i32()?;
Ok(result != 0)
}
pub fn is_modified(&self) -> SageResult<bool> {
let result = self
.dispatch()
.call_method_by_name("IsModified", &[])?
.to_i32()?;
Ok(result != 0)
}
pub fn set_default(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("SetDefault", &[])?;
Ok(())
}
pub fn write(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Write", &[])?;
Ok(())
}
pub fn write_default(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("WriteDefault", &[])?;
Ok(())
}
pub fn read(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Read", &[])?;
Ok(())
}
pub fn remove(&self) -> SageResult<()> {
self.dispatch().call_method_by_name("Remove", &[])?;
Ok(())
}
}
impl Clone for Reglement {
fn clone(&self) -> Self {
Self {
dispatch: self.dispatch.clone(),
}
}
}
impl PartialEq for Reglement {
fn eq(&self, other: &Self) -> bool {
match (self.rg_code(), other.rg_code()) {
(Ok(code1), Ok(code2)) => code1 == code2,
_ => false,
}
}
}
impl FromDispatchNew for Reglement {
fn from_dispatch_new(dispatch: IDispatch) -> SageResult<Self> {
Ok(Self { dispatch })
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_reglement_documentation() {
}
}