using system;
namespace vavic
{
/// <summary>
/// 当信息更改是通知其他的窗口重新加载数据
/// 使用方法为:1)通知信息更改
/// notify.instance().sendmessage(100, "form1 activate test notify event");
/// 其中第一个参数为信息号,第二个参数为信息描述
/// 2)收取信息
/// 使用方法,在每个formload事件中加入如下语句
/// notify.instance().onnotifyevent += new notify.notifyevent(onnotifyevent);
/// 同时编写如下的方法用于重新加载数据
///protected void onnotifyevent(object sender, notify.notifyeventargs e)
///{
/// if (e.code == notify.companyinfo)
/// system.diagnostics.debug.writeline(string.format(" form1 code={0}, message = {1}", e.code,e.message));
///}
/// </summary>
public class notify
{
protected static notify m_notify = null;
public delegate void notifyevent(object sender, notifyeventargs e);
public event notifyevent onnotifyevent;
protected notify()
{
//
// todo: 在此处添加构造函数逻辑
//
}
public static notify instance()
{
if (m_notify == null)
m_notify = new notify();
return m_notify;
}
public void sendmessage(int code, string message)
{
notifyeventargs e = new notifyeventargs(code, message);
if ( onnotifyevent != null)
onnotifyevent(this, e);
}
public class notifyeventargs : system.eventargs
{
public notifyeventargs(int code, string message)
{
m_ncode = code;
m_strmessage = message;
}
public notifyeventargs()
{
}
protected int m_ncode;
public int code
{
get { return m_ncode;}
set { m_ncode = value;}
}
protected string m_strmessage = string.empty;
public string message
{
get { return m_strmessage;}
set
{
m_strmessage = value;
if (m_strmessage == null)
m_strmessage = string.empty;
}
}
}
#region common infomation
public const int companyinfo = 1;
public const int projectinfo = 2;
public const int taskinfo = 3;
public const int opportunity = 4;
public const int contactor = 5;
public const int employeeinfo = 6;
public const int departmentinfo = 7;
public const int advcityinfo = 8;
#endregion
}
}
