CCalendar cal = new CCalendar();
this.lblCalendar.Text = cal.GetDateInfo(System.DateTime.Now).Fullinfo;
<?xml version="1.0" encoding="gb2312" ?>
<HELLO>
<!-- 公历节日开始 -->
<AD>
<feast day="0101" name="元旦" sayhello="yes">
<hello>新年好!祝您在新的一年里身体健康,事业进步!</hello>
<!-- 从网站根目录算起 -->
<img>./img/theme/0101.gif</img>
</feast>
<feast day="0202" name="世界湿地日" sayhello="no">
<img></img>
<hello></hello>
</feast>
<feast day="0210" name="国际气象节" sayhello="no">
<img></img>
<hello></hello>
</feast>
<feast day="0214" name="情人节" sayhello="yes">
<hello>祝天下有情人终成眷属!</hello>
<img>./img/theme/0214.gif</img>
</feast>
<feast day="0301" name="世界图书日" sayhello="no">
<img></img>
<hello></hello>
</feast>
.............
1、 本辅助类主要是用来方便动态设置托盘图标。该辅助类用于一些实时连接要求或者状态变化能够及时通过图表来显示的程序,通过闪动的图标及文本,可以有效提示用户相关的程序状态,提供用户的使用体验。
public partial class FrmMain : Form
{
private NotifyIconHelper notifyHelper;
private const string ClientName = "数据采集终端";//PC式采集器终端
public frmMain()
{
InitializeComponent();
this.Text = ClientName;
//初始化托盘图标
notifyHelper = new NotifyIconHelper(this.notifyIcon1);
notifyHelper.Icon_Conntected = Resources.Connected;
notifyHelper.Icon_Shrink1 = Resources.shrink1;
notifyHelper.Icon_Shrink2 = Resources.shrink2;
notifyHelper.Icon_UnConntect = Resources.unConnected;
notifyHelper.Text_Conntected = string.Format("{0}:终端已经连接", ClientName);
notifyHelper.Text_UnConntect = string.Format("{0}:终端未连接", ClientName);
notifyHelper.NotifyStatus = NotifyIconHelper.Status.TwinkleNotice;
}
/// <summary>
/// 设置托盘图标的状态
/// </summary>
/// <param name="status"></param>
public void SetNotifyStatus(NotifyIconHelper.Status status)
{
notifyHelper.NotifyStatus = status;
if (status == NotifyIconHelper.Status.Offline)
{
this.Invoke(new MethodInvoker(delegate()
{
this.Icon = notifyHelper.Icon_UnConntect;
}));
}
else if (status == NotifyIconHelper.Status.Online)
{
this.Invoke(new MethodInvoker(delegate()
{
this.Icon = notifyHelper.Icon_Conntected;
}));
}
}
复制代码
5、DataTable操作辅助类 DataTableHelper
实现效果
1、本辅助类主要是用来方便对DataTable进行相关操作的辅助类,该类是非常常用的工具类,常用与数据显示、转换和报表生成等操作中。
2、 提供的操作,包括有创建表、DataTable和实体类集合IList<T>相互转化、表排序、表过滤等操作,以求达到快速进行DataTable操作的目的。
实现代码
1、 根据字段创建表对象,多个列用逗号(,)分开,默认为表对象的列为string。
string columns = @"流水号,备注,供货商,操作员,库房名称,备件编号(pm码),备件名称,图号,规格型号,材质,备件属类,备件类别,
单位,最新单价(元),入库数量,总价,入库日期,来源,库位,部门,使用位置";
DataTable dt = DataTableHelper.CreateTable(columns);
复制代码
2、根据字段创建表对象,多个列用逗号(,)分开。如需要制定列的类型,在字段后加上“|int”格式的字符。
string tableColumns = "ID|int,ItemNo,ItemName,StockQuantity|int,Manufacture,MapNo,Specification,Material,ItemBigType,ItemType,
Unit,Price|decimal,Source,StoragePos,UsagePos,Note,WareHouse,Dept";
DataTable dt = DataTableHelper.CreateTable(tableColumns);
复制代码
3、 实体类转DataTable对象操作ListToDataTable,其对应的反操作函数DataTableToList使用方法类似。
string where = GetSearchSql();
IList<CustomerInfo> list = BLLFactory<Customer>.Instance.Find(where, this.winGridViewPager1.PagerInfo);
DataTable dt = DataTableHelper.ToDataTable<CustomerInfo>(list);
this.winGridViewPager1.DataSource = dt.DefaultView;
this.winGridViewPager1.dataGridView1.Refresh();
复制代码
4、 DataTable对象排序操作SortedTable,可对表多列进行排序操作。
string where = GetSearchSql();
IList<CustomerInfo> list = BLLFactory<Customer>.Instance.Find(where, this.winGridViewPager1.PagerInfo);
DataTable dt = DataTableHelper.ToDataTable<CustomerInfo>(list);
DataTable dtSort = DataTableHelper.SortedTable(dt, new string[]{"Number asc", "Type desc"});
复制代码