- 积分
- 25
- 在线时间
- 74 小时
- 主题
- 15
- 注册时间
- 2017-5-10
- 帖子
- 59
- 最后登录
- 2022-7-29
- 帖子
- 59
- 软币
- 379
- 在线时间
- 74 小时
- 注册时间
- 2017-5-10
|
此控件非本人所写
来自于网络,我只是将控件的DEV 版本升级到了17.1.如果你觉得好请支持正版!
说明文档
文档说明.rar
(2.75 MB, 下载次数: 983)
控件下载
load事件中添加如下代码添加事件:
[C#] 纯文本查看 复制代码 {
BindData();
this.winGridViewPager1.OnPageChanged += new EventHandler(winGridViewPager1_OnPageChanged);
this.winGridViewPager1.OnStartExport += new EventHandler(winGridViewPager1_OnStartExport);
this.winGridViewPager1.OnEditSelected += new EventHandler(winGridViewPager1_OnEditSelected);
this.winGridViewPager1.OnDeleteSelected += new EventHandler(winGridViewPager1_OnDeleteSelected);
this.winGridViewPager1.OnRefresh += new EventHandler(winGridViewPager1_OnRefresh);
this.winGridViewPager1.OnAddNew += new EventHandler(winGridViewPager1_OnAddNew);
this.winGridViewPager1.AppendedMenu = this.contextMenuStrip1;
}
事件执行代码的实现如下所示,包含分页事件、刷新事件、删除事件、编辑事件、新增事件、导出Excel事件等。
[C#] 纯文本查看 复制代码 private void winGridViewPager1_OnPageChanged(object sender, EventArgs e)
{
BindData();
}
private void winGridViewPager1_OnRefresh(object sender, EventArgs e)
{
BindData();
}
private void winGridViewPager1_OnDeleteSelected(object sender, EventArgs e)
{
if (MessageUtil.ShowYesNoAndTips("您确定删除选定的记录么?") == DialogResult.No)
{
return;
}
DataGridView grid = sender as DataGridView;
if (grid != null)
{
foreach (DataGridViewRow row in grid.SelectedRows)
{
BLLFactory<Customer>.Instance.Delete(row.Cells[0].Value.ToString());
}
BindData();
}
}
private void winGridViewPager1_OnEditSelected(object sender, EventArgs e)
{
DataGridView grid = sender as DataGridView;
if (grid != null)
{
foreach (DataGridViewRow row in grid.SelectedRows)
{
FrmEditCustomer dlg = new FrmEditCustomer();
dlg.ID = row.Cells[0].Value.ToString();
if (DialogResult.OK == dlg.ShowDialog())
{
BindData();
}
break;
}
}
}
private void winGridViewPager1_OnAddNew(object sender, EventArgs e)
{
btnAddNew_Click(null, null);
}
private void winGridViewPager1_OnStartExport(object sender, EventArgs e)
{
string where = GetSearchSql();
this.winGridViewPager1.AllToExport = BLLFactory<Customer>.Instance.FindToTable(where);
}
private void BindData()
{
#region 添加别名解析
this.winGridViewPager1.AddColumnAlias("ID", "编号");
this.winGridViewPager1.AddColumnAlias("Number", "客户编号");
this.winGridViewPager1.AddColumnAlias("Name", "客户名称");
this.winGridViewPager1.AddColumnAlias("Type", "客户类型");
this.winGridViewPager1.AddColumnAlias("Area", "客户地区");
this.winGridViewPager1.AddColumnAlias("Company", "客户单位");
this.winGridViewPager1.AddColumnAlias("Address", "客户地址");
this.winGridViewPager1.AddColumnAlias("Telephone1", "电话1");
this.winGridViewPager1.AddColumnAlias("Telephone2", "电话2");
this.winGridViewPager1.AddColumnAlias("Telephone3", "电话3");
this.winGridViewPager1.AddColumnAlias("Telephone4", "电话4");
this.winGridViewPager1.AddColumnAlias("Telephone5", "电话5");
this.winGridViewPager1.AddColumnAlias("CreateDate", "开户日期");
this.winGridViewPager1.AddColumnAlias("Shop_ID", "分店ID");
this.winGridViewPager1.AddColumnAlias("Note", "备注");
this.winGridViewPager1.AddColumnAlias("LastUpdated", "更新日期");
#endregion
string where = GetSearchSql();
this.winGridViewPager1.DataSource = BLLFactory<Customer>.Instance.Find(where, this.winGridViewPager1.PagerInfo);
this.winGridViewPager1.dataGridView1.Refresh();
}
如果不想把所有的实体类属性或者表字段都显示处理(默认全部显示),那么可以设置属性DisplayColumns即可。
[C#] 纯文本查看 复制代码 this.winGridViewPager1.DisplayColumns = "ID,ItemNo,ItemName,Manufacture,MapNo,Specification,StockQuantity,AlarmQuantity,WareHouse";
报表标题如下所示:
[C#] 纯文本查看 复制代码 this.winGridViewPager1.PrintTitle = Portal.gc.gAppUnit + " -- " + "备件信息报表";
绑定自定义Datatable对象的实现:
[C#] 纯文本查看 复制代码 private void BindData()
{
this.winGridViewPager1.DisplayColumns = "ID,ItemNo,ItemName,Manufacture,MapNo,Specification,Material,ItemBigType,ItemType,
Unit,Price,Source,StoragePos,UsagePos,StockQuantity,AlarmQuantity,Note,Dept,WareHouse";
#region 添加别名解析
this.winGridViewPager1.AddColumnAlias("ID", "编号");
this.winGridViewPager1.AddColumnAlias("ItemNo", "项目编号");
this.winGridViewPager1.AddColumnAlias("ItemName", "项目名称");
this.winGridViewPager1.AddColumnAlias("Manufacture", "供货商");
this.winGridViewPager1.AddColumnAlias("MapNo", "图号");
this.winGridViewPager1.AddColumnAlias("Specification", "规格型号");
this.winGridViewPager1.AddColumnAlias("Material", "材质");
this.winGridViewPager1.AddColumnAlias("ItemBigType", "备件属类");
this.winGridViewPager1.AddColumnAlias("ItemType", "备件类别");
this.winGridViewPager1.AddColumnAlias("Unit", "单位");
this.winGridViewPager1.AddColumnAlias("Price", "单价");
this.winGridViewPager1.AddColumnAlias("Source", "来源");
this.winGridViewPager1.AddColumnAlias("StoragePos", "库位");
this.winGridViewPager1.AddColumnAlias("UsagePos", "使用位置");
this.winGridViewPager1.AddColumnAlias("StockQuantity", "当前库存");
this.winGridViewPager1.AddColumnAlias("WareHouse", "所属库房");
this.winGridViewPager1.AddColumnAlias("Dept", "所属部门");
this.winGridViewPager1.AddColumnAlias("Note", "备注");
#endregion
string where = GetConditionSql();
List<ItemDetailInfo> list = BLLFactory<ItemDetail>.Instance.Find(where, this.winGridViewPager1.PagerInfo);
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);
DataRow dr = null;
foreach (ItemDetailInfo info in list)
{
dr = dt.NewRow();
dr["ID"] = info.ID;
dr["ItemBigType"] = info.ItemBigType;
dr["ItemName"] = info.ItemName;
dr["ItemNo"] = info.ItemNo;
dr["ItemType"] = info.ItemType;
dr["Manufacture"] = info.Manufacture;
dr["MapNo"] = info.MapNo;
dr["Material"] = info.Material;
dr["Note"] = info.Note;
dr["Price"] = info.Price;
dr["Source"] = info.Source;
dr["Specification"] = info.Specification;
dr["StoragePos"] = info.StoragePos;
dr["Unit"] = info.Unit;
dr["UsagePos"] = info.UsagePos;
dr["WareHouse"] = info.WareHouse;
dr["Dept"] = info.Dept;
StockInfo stockInfo = BLLFactory<Stock>.Instance.FindByItemNo(info.ItemNo);
int quantity = 0;
if (stockInfo != null)
{
quantity = stockInfo.StockQuantity;
}
dr["StockQuantity"] = quantity;
dt.Rows.Add(dr);
}
this.winGridViewPager1.DataSource = dt.DefaultView;//new WHC.Pager.WinControl.SortableBindingList<ItemDetailInfo>(list);
this.winGridViewPager1.PrintTitle = Portal.gc.gAppUnit + " -- " + "备件信息报表";
}
部分效果图
|
评分
-
查看全部评分
|