432 lines
12 KiB
C#
432 lines
12 KiB
C#
using System;
|
|
using System.Xml;
|
|
using System.IO;
|
|
|
|
namespace AyaNova.PlugIn.PTI
|
|
{
|
|
/// <summary>
|
|
/// Case 299
|
|
/// PTIDataEx replaces original PTIData which was not
|
|
/// designed for expansion
|
|
/// </summary>
|
|
[Serializable]
|
|
public class PTIDataEx
|
|
{
|
|
|
|
|
|
#region fields
|
|
private Guid _PreWOStatus=Guid.Empty;
|
|
private Guid _PostWOStatus=Guid.Empty;
|
|
private string _OutsideServiceChargeAs="";
|
|
private string _WorkorderItemLoanChargeAs="";
|
|
private string _MiscExpenseChargeAs="";
|
|
//private string _PTInvoiceTemplate="";
|
|
private bool _SetMemoField=true;
|
|
//private string _TransactionClass="";
|
|
//private bool _ToBePrinted=true;
|
|
private string _InvoiceHeaderTemplate="";
|
|
private string _InvoiceFooterTemplate="";
|
|
private string _InvoiceUnitTemplate="";
|
|
private string _InvoiceServiceTemplate="";
|
|
private string _InvoiceTravelTemplate="";
|
|
private string _InvoiceOutsideServiceTemplate="";
|
|
private string _InvoiceMiscExpenseTemplate="";
|
|
private string _InvoiceLoanItemTemplate="";
|
|
|
|
//Case 7
|
|
private bool _AutoClose = true;
|
|
|
|
public bool IsDirty=false;
|
|
#endregion
|
|
|
|
#region Properties
|
|
public Guid PreWOStatus
|
|
{
|
|
get { return _PreWOStatus; }
|
|
set
|
|
{
|
|
if(_PreWOStatus!=value)
|
|
{
|
|
_PreWOStatus = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public Guid PostWOStatus
|
|
{
|
|
get { return _PostWOStatus; }
|
|
set
|
|
{
|
|
if(_PostWOStatus!=value)
|
|
{
|
|
_PostWOStatus = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string OutsideServiceChargeAs
|
|
{
|
|
get { return _OutsideServiceChargeAs; }
|
|
set
|
|
{
|
|
if(_OutsideServiceChargeAs!=value)
|
|
{
|
|
_OutsideServiceChargeAs = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
public string MiscExpenseChargeAs
|
|
{
|
|
get { return _MiscExpenseChargeAs; }
|
|
set
|
|
{
|
|
if(_MiscExpenseChargeAs!=value)
|
|
{
|
|
_MiscExpenseChargeAs = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string WorkorderItemLoanChargeAs
|
|
{
|
|
get { return _WorkorderItemLoanChargeAs; }
|
|
set
|
|
{
|
|
if(_WorkorderItemLoanChargeAs!=value)
|
|
{
|
|
_WorkorderItemLoanChargeAs = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
//public string PTInvoiceTemplate
|
|
//{
|
|
// get { return _PTInvoiceTemplate; }
|
|
// set
|
|
// {
|
|
// if(_PTInvoiceTemplate!=value)
|
|
// {
|
|
// _PTInvoiceTemplate = value;
|
|
// IsDirty=true;
|
|
// }
|
|
// }
|
|
//}
|
|
public bool SetMemoField
|
|
{
|
|
get { return _SetMemoField; }
|
|
set
|
|
{
|
|
if(_SetMemoField!=value)
|
|
{
|
|
_SetMemoField = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
//public string TransactionClass
|
|
//{
|
|
// get { return _TransactionClass; }
|
|
// set
|
|
// {
|
|
// if(_TransactionClass!=value)
|
|
// {
|
|
// _TransactionClass = value;
|
|
// IsDirty=true;
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
//public bool ToBePrinted
|
|
//{
|
|
// get { return _ToBePrinted; }
|
|
// set
|
|
// {
|
|
// if(_ToBePrinted!=value)
|
|
// {
|
|
// _ToBePrinted = value;
|
|
// IsDirty=true;
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
public string InvoiceHeaderTemplate
|
|
{
|
|
get { return _InvoiceHeaderTemplate; }
|
|
set
|
|
{
|
|
if(_InvoiceHeaderTemplate!=value)
|
|
{
|
|
_InvoiceHeaderTemplate = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string InvoiceFooterTemplate
|
|
{
|
|
get { return _InvoiceFooterTemplate; }
|
|
set
|
|
{
|
|
if(_InvoiceFooterTemplate!=value)
|
|
{
|
|
_InvoiceFooterTemplate = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string InvoiceUnitTemplate
|
|
{
|
|
get { return _InvoiceUnitTemplate; }
|
|
set
|
|
{
|
|
if(_InvoiceUnitTemplate!=value)
|
|
{
|
|
_InvoiceUnitTemplate = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string InvoiceServiceTemplate
|
|
{
|
|
get { return _InvoiceServiceTemplate; }
|
|
set
|
|
{
|
|
if(_InvoiceServiceTemplate!=value)
|
|
{
|
|
_InvoiceServiceTemplate = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string InvoiceTravelTemplate
|
|
{
|
|
get { return _InvoiceTravelTemplate; }
|
|
set
|
|
{
|
|
if(_InvoiceTravelTemplate!=value)
|
|
{
|
|
_InvoiceTravelTemplate = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string InvoiceOutsideServiceTemplate
|
|
{
|
|
get { return _InvoiceOutsideServiceTemplate; }
|
|
set
|
|
{
|
|
if(_InvoiceOutsideServiceTemplate!=value)
|
|
{
|
|
_InvoiceOutsideServiceTemplate = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string InvoiceMiscExpenseTemplate
|
|
{
|
|
get { return _InvoiceMiscExpenseTemplate; }
|
|
set
|
|
{
|
|
if(_InvoiceMiscExpenseTemplate!=value)
|
|
{
|
|
_InvoiceMiscExpenseTemplate = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public string InvoiceLoanItemTemplate
|
|
{
|
|
get { return _InvoiceLoanItemTemplate; }
|
|
set
|
|
{
|
|
if(_InvoiceLoanItemTemplate!=value)
|
|
{
|
|
_InvoiceLoanItemTemplate = value;
|
|
IsDirty=true;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public bool HasInvoiceHeaderTemplate
|
|
{
|
|
get
|
|
{
|
|
return _InvoiceHeaderTemplate!="";
|
|
}
|
|
}
|
|
|
|
public bool HasAnyInvoiceFooterTemplateFields
|
|
{
|
|
get
|
|
{
|
|
if(this._InvoiceFooterTemplate!="" ||
|
|
this._InvoiceUnitTemplate!="" ||
|
|
this._InvoiceServiceTemplate!="" ||
|
|
this._InvoiceTravelTemplate!="" ||
|
|
this._InvoiceLoanItemTemplate!="" ||
|
|
this._InvoiceMiscExpenseTemplate!="" ||
|
|
this._InvoiceOutsideServiceTemplate!=""
|
|
)
|
|
return true;
|
|
else
|
|
return false;
|
|
|
|
}
|
|
}
|
|
|
|
//Case 7
|
|
public bool AutoClose
|
|
{
|
|
get { return _AutoClose; }
|
|
set
|
|
{
|
|
if (_AutoClose != value)
|
|
{
|
|
_AutoClose = value;
|
|
IsDirty = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// Flag indicating whether user has configured
|
|
/// PTI at all yet, this is used to present a description
|
|
/// of the configuration that is about to take place to the user
|
|
///
|
|
/// If this is false then any missing option is considered a one-off
|
|
/// and no general initial description is given to the user about setting
|
|
/// up PTI
|
|
/// </summary>
|
|
public bool NothingSet
|
|
{
|
|
get
|
|
{
|
|
if(_PreWOStatus==Guid.Empty &&
|
|
_PostWOStatus==Guid.Empty &&
|
|
_OutsideServiceChargeAs=="" &&
|
|
_WorkorderItemLoanChargeAs=="" &&
|
|
_MiscExpenseChargeAs=="" ) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
}
|
|
#endregion props
|
|
|
|
public PTIDataEx()
|
|
{
|
|
//
|
|
// TODO: Add constructor logic here
|
|
//
|
|
}
|
|
|
|
|
|
#region XML in/out
|
|
|
|
/// <summary>
|
|
/// Set - Sets the fields in this object based on the contents of the xml string
|
|
/// Get - Get's the fields of this object in the format of an xml string
|
|
/// </summary>
|
|
public string XMLData
|
|
{
|
|
get
|
|
{
|
|
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
|
|
|
System.Xml.XmlTextWriter w = new System.Xml.XmlTextWriter(new StringWriter(sb));
|
|
w.Formatting = System.Xml.Formatting.Indented;
|
|
|
|
w.WriteStartDocument(true);
|
|
w.WriteStartElement("PTISettings");
|
|
|
|
w.WriteElementString("PreWOStatus", XmlConvert.ToString(_PreWOStatus));
|
|
w.WriteElementString("PostWOStatus", XmlConvert.ToString(_PostWOStatus));
|
|
w.WriteElementString("OutsideServiceChargeAs", _OutsideServiceChargeAs);
|
|
w.WriteElementString("WorkorderItemLoanChargeAs", _WorkorderItemLoanChargeAs);
|
|
w.WriteElementString("MiscExpenseChargeAs", _MiscExpenseChargeAs);
|
|
//w.WriteElementString("PTInvoiceTemplate", _PTInvoiceTemplate);
|
|
w.WriteElementString("SetMemoField", XmlConvert.ToString(_SetMemoField));
|
|
// w.WriteElementString("TransactionClass", _TransactionClass);
|
|
// w.WriteElementString("ToBePrinted", XmlConvert.ToString(_ToBePrinted));
|
|
w.WriteElementString("InvoiceHeaderTemplate", _InvoiceHeaderTemplate);
|
|
w.WriteElementString("InvoiceFooterTemplate", _InvoiceFooterTemplate);
|
|
w.WriteElementString("InvoiceUnitTemplate", _InvoiceUnitTemplate);
|
|
w.WriteElementString("InvoiceServiceTemplate", _InvoiceServiceTemplate);
|
|
w.WriteElementString("InvoiceTravelTemplate", _InvoiceTravelTemplate);
|
|
w.WriteElementString("InvoiceOutsideServiceTemplate", _InvoiceOutsideServiceTemplate);
|
|
w.WriteElementString("InvoiceMiscExpenseTemplate", _InvoiceMiscExpenseTemplate);
|
|
w.WriteElementString("InvoiceLoanItemTemplate", _InvoiceLoanItemTemplate);
|
|
|
|
//Case 7
|
|
w.WriteElementString("AutoClose", XmlConvert.ToString(_AutoClose));
|
|
|
|
w.WriteEndElement();
|
|
w.WriteEndDocument();
|
|
w.Flush();
|
|
w.Close();
|
|
|
|
return sb.ToString();
|
|
}
|
|
set
|
|
{
|
|
// Load the signed XML license file.
|
|
XmlDocument xmldoc = new XmlDocument();
|
|
try
|
|
{
|
|
xmldoc.LoadXml(value);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new ApplicationException("Error: exception in PTIDataEx::XMLData.set()->LoadXml:\r\n." + ex.Message, ex.InnerException);
|
|
|
|
}
|
|
|
|
_PreWOStatus = XmlConvert.ToGuid(xmldoc.SelectSingleNode("/PTISettings/PreWOStatus").InnerText);
|
|
_PostWOStatus = XmlConvert.ToGuid(xmldoc.SelectSingleNode("/PTISettings/PostWOStatus").InnerText);
|
|
_OutsideServiceChargeAs = xmldoc.SelectSingleNode("/PTISettings/OutsideServiceChargeAs").InnerText;
|
|
_WorkorderItemLoanChargeAs = xmldoc.SelectSingleNode("/PTISettings/WorkorderItemLoanChargeAs").InnerText;
|
|
_MiscExpenseChargeAs = xmldoc.SelectSingleNode("/PTISettings/MiscExpenseChargeAs").InnerText;
|
|
//_PTInvoiceTemplate = xmldoc.SelectSingleNode("/PTISettings/PTInvoiceTemplate").InnerText;
|
|
_SetMemoField = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/PTISettings/SetMemoField").InnerText);
|
|
//_TransactionClass = xmldoc.SelectSingleNode("/PTISettings/TransactionClass").InnerText;
|
|
//_ToBePrinted = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/PTISettings/ToBePrinted").InnerText);
|
|
_InvoiceHeaderTemplate = xmldoc.SelectSingleNode("/PTISettings/InvoiceHeaderTemplate").InnerText;
|
|
_InvoiceFooterTemplate = xmldoc.SelectSingleNode("/PTISettings/InvoiceFooterTemplate").InnerText;
|
|
_InvoiceUnitTemplate = xmldoc.SelectSingleNode("/PTISettings/InvoiceUnitTemplate").InnerText;
|
|
_InvoiceServiceTemplate = xmldoc.SelectSingleNode("/PTISettings/InvoiceServiceTemplate").InnerText;
|
|
_InvoiceTravelTemplate = xmldoc.SelectSingleNode("/PTISettings/InvoiceTravelTemplate").InnerText;
|
|
_InvoiceOutsideServiceTemplate = xmldoc.SelectSingleNode("/PTISettings/InvoiceOutsideServiceTemplate").InnerText;
|
|
_InvoiceMiscExpenseTemplate = xmldoc.SelectSingleNode("/PTISettings/InvoiceMiscExpenseTemplate").InnerText;
|
|
_InvoiceLoanItemTemplate = xmldoc.SelectSingleNode("/PTISettings/InvoiceLoanItemTemplate").InnerText;
|
|
|
|
//Case 7
|
|
_AutoClose = XmlConvert.ToBoolean(xmldoc.SelectSingleNode("/PTISettings/AutoClose").InnerText);
|
|
|
|
|
|
//FUTURE: items are going to have to check for presence of nodes before attempting to retrieve them
|
|
}
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|