Observer 在商业软件应用的研究
using System;
using System.Windows.Forms;
namespace CS
{
//---------------------------------------------
//各种操作
//---------------------------------------------
public interface IWork
{
void Update();
}
public class UpdateStock:IWork
{
public void Update()
{
MessageBox.Show("修改库存");
}
}
public class GroupSale_Work:IWork
{
public void Update()
{
MessageBox.Show("团购");
}
}
public class EntryStock_Work:IWork
{
public EntryStock_Work()
{
}
public void Update()
{
MessageBox.Show("生成入库报表");
}
}
public class Purchase_Work:IWork
{
public Purchase_Work()
{
}
public void Update()
{
MessageBox.Show("生成采购报表");
}
}
public class RetPurchase_Work:IWork
{
public RetPurchase_Work()
{
}
public void Update()
{
MessageBox.Show("生成退货报表");
}
}
public class Supplier_Account:IWork
{
public Supplier_Account()
{
}
public void Update()
{
MessageBox.Show("生成供应商结算报表");
}
}
//-------------------------------------------
//各种单据生成各种报表的过程
//-------------------------------------------
public abstract class Auditer
{
public Auditer()
{
}
private System.Collections.ArrayList Iwork=new System.Collections.ArrayList();
public void Add(IWork work)
{
Iwork.Add(work);
}
public void Remove(IWork work)
{
Iwork.Remove(work);
}
public void Audite()
{
foreach(IWork work in Iwork)
{
work.Update();
}
}
}
//------------------------------------------
//各种单据
//------------------------------------------
public class Entry_Bill:Auditer
{
public Entry_Bill()
{
}
}
//---------------------------------------
//举例说明
//---------------------------------------
// public class Cmain
// {
// public static void Main()
// {
// //入库过程
// CS.Entry_Bill Entry=new Entry_Bill();
// Entry.Add(new EntryStock_Work());//入库
// Entry.Add(new UpdateStock());//修改库存
// Entry.Add(new Supplier_Account());//供应商结算报表生成
// Entry.Audite();
// }
// }
}