<#if table??>
================================= List Page Begin ====================================
${table.entityName}ListPage.xaml
--------------------------------------------------------------------------------------
<Page x:Class="app.view.${table.entityName}ListPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:app="clr-namespace:app.component"
Title="${table.entityName}ListPage" Loaded="Page_Loaded">
<Page.Resources>
<Style TargetType="Label">
<Setter Property="Width" Value="75" />
<Setter Property="HorizontalContentAlignment" Value="Right" />
<Setter Property="Padding" Value="10 5" />
</Style>
<Style TargetType="WrapPanel" x:Key="fieldWPStyle">
<Setter Property="Margin" Value="0 0 0 5" />
<Setter Property="Height" Value="25" />
</Style>
</Page.Resources>
<Border BorderThickness="1" BorderBrush="Silver">
<DockPanel>
<DockPanel DockPanel.Dock="Top">
<StackPanel Orientation="Vertical">
<WrapPanel Margin="0 5 0 0">
<#list table.columns as column>
<#if column.columName != "id">
<WrapPanel Name="search_${column.attributeName}Wp" Style="{StaticResource fieldWPStyle}" Visibility="Collapsed">
<Label Name="search_${column.attributeName}Lb" Content="${column.columComment}"/>
<TextBox Height="23" Name="search_${column.attributeName}Tb" Width="120" />
</WrapPanel>
</#if>
</#list>
<WrapPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="查询" Height="23" Width="50" Margin="15 0 10 0" Click="SearchBtn_Click"/>
<Button Content="清空" Height="23" Width="50" Click="Search_CleanUpBtn_Click" />
</WrapPanel>
</WrapPanel>
<Separator/>
</StackPanel>
</DockPanel>
<DockPanel DockPanel.Dock="Bottom">
<app:Pager x:Name="pager" PageSize="5" GetDataDelegateHandler="LoadData" />
</DockPanel>
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Grid.RowDefinitions>
<RowDefinition Height="35" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ToolBar Grid.Row="0" ToolBarTray.IsLocked="True" Loaded="ToolBar_Loaded">
<Button Content="新增" Click="Button_Click_AddNew"></Button>
<Button Content="修改" Click="Button_Click_Modify"></Button>
<Button Content="详情" Click="Button_Click_Info"></Button>
<Button Content="删除" Click="Button_Click_Del"></Button>
</ToolBar>
<DataGrid x:Name="dataGrid" Grid.Row="1" ItemsSource="{Binding}" IsReadOnly="True" Style="{StaticResource recordListDGStyle}" AutoGenerateColumns="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" SelectionMode="Single">
<DataGrid.Columns>
<#list table.columns as column>
<DataGridTextColumn x:Name="${column.attributeName}DGTC" Header="${column.columComment}" Width="100" Binding="{Binding ${column.attributeNameFLU}}"/>
</#list>
</DataGrid.Columns>
</DataGrid>
</Grid>
</DockPanel>
</Border>
</Page>
======================================================================================
${table.entityName}ListPage.xaml.cs
--------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using app.util;
using net.yeetop.csutils;
using net.yeetop.csutils.attribute;
using app.service;
using net.yeetop.csbase.entity;
using app.entity;
using System.Collections.ObjectModel;
using app.context;
using System.Globalization;
namespace app.view {
/// <summary>
/// ${table.entityName}ListPage.xaml 的交互逻辑
/// </summary>
public partial class ${table.entityName}ListPage : Page {
[Resource(Name = "${table.entityNameFLL}Service")]
private I${table.entityName}Service ${table.entityNameFLL}Service;
private bool hasInited = false;
public ${table.entityName}ListPage() {
InitializeComponent();
SimpleAnnotation.DependencyInject(this);
// 表格自动生成行号
ViewUtils4WPF.ShowDataGridLineNumberDefault(this.dataGrid);
this.dataGrid.MouseDoubleClick += new MouseButtonEventHandler((sender, args) => {
ShowDetailPage(IConstant.DetailWinMode.INFO, (sender as DataGrid).SelectedItem as ${table.entityName});
});
}
/// <summary>
/// 分页控件回调函数,返回总记录数
/// </summary>
/// <param name="pageNo">页码,由分页控件传入</param>
/// <param name="pageSize">页面记录大小,由分页控件传入</param>
/// <returns></returns>
private int LoadData(int pageNo, int pageSize) {
try {
${table.entityName} filter = new ${table.entityName}();
<#list table.columns as column>
<#if column.columName != "id">
<#if column.columType?lower_case == "int">
filter.${column.attributeNameFLU} = Convert.ToInt32(this.search_${column.attributeName}Tb.Text);
<#elseif column.columType?lower_case == "bigint">
filter.${column.attributeNameFLU} = Convert.ToInt64(this.search_${column.attributeName}Tb.Text);
<#elseif column.columType?lower_case == "decimal">
filter.${column.attributeNameFLU} = Convert.ToDecimal(this.search_${column.attributeName}Tb.Text);
<#else>
filter.${column.attributeNameFLU} = this.search_${column.attributeName}Tb.Text;
</#if>
</#if>
</#list>
Page<${table.entityName}> page = this.${table.entityNameFLL}Service.Get${table.entityName}List(pageNo, pageSize, "asc", "id", filter);
ObservableCollection<${table.entityName}> items = new ObservableCollection<${table.entityName}>();
foreach (${table.entityName} item in page.ResultList) {
if (item != null) {
items.Add(item);
} else {
items.Add(new ${table.entityName}() {
Id = -1
});
}
}
this.dataGrid.DataContext = items;
return page.Total;
} catch (Exception e) {
MessageBox.Show("系统出错[${table.entityName}ListPage#LoadData, " + e.Message + "],请联系管理员!", "出错!", MessageBoxButton.OK, MessageBoxImage.Error);
return 0;
}
}
/// <summary>
/// 刷新DataGrid并跳转到PageNoFlag标识的页
/// </summary>
/// <param name="pageNoFlag"></param>
private void RefreshDataGrid(IConstant.PageNoFlag pageNoFlag) {
switch (pageNoFlag) {
case IConstant.PageNoFlag.CURRENT:
this.pager.Refresh();
break;
case IConstant.PageNoFlag.FIRST:
this.pager.GotoFirstPage();
break;
case IConstant.PageNoFlag.LAST:
this.pager.GotoLastPage();
if (this.dataGrid.Items.Count == this.pager.PageSize) {
this.pager.GotoLastPage(); // 确保跳转到最后一页
}
break;
default:
break;
}
}
private void Page_Loaded(object sender, RoutedEventArgs e) {
if (!hasInited) {
hasInited = true;
}
}
private void ToolBar_Loaded(object sender, RoutedEventArgs e) {
// 去除工具条右侧扩展下拉三角按钮
ToolBar toolBar = sender as ToolBar;
ViewUtils4WPF.DelToolBarRightExtendButton(toolBar);
}
// 按键事件
private void Button_Click_AddNew(object sender, RoutedEventArgs e) {
try {
ShowDetailPage(IConstant.DetailWinMode.ADD_NEW, null);
} catch (Exception ex) {
MessageBox.Show("打开添加窗口按钮事件出错,请联系技术人员![${table.entityName}ListPage, " + ex.Message + "]", "系统错误", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
private void Button_Click_Modify(object sender, RoutedEventArgs e) {
try {
${table.entityName} ${table.entityNameFLL} = ViewUtils4WPF.GetDataGridSel
没有合适的资源?快使用搜索试试~ 我知道了~
SimpleCodeGenerator简单MVC三层代码生成器
共43个文件
java:20个
jar:14个
properties:2个
4星 · 超过85%的资源 需积分: 50 54 下载量 91 浏览量
2017-09-28
09:54:38
上传
评论 2
收藏 6.16MB RAR 举报
温馨提示
简单MVC三层代码生成器,使用java开发,模版使用freemarker模版引擎。
资源推荐
资源详情
资源评论
收起资源包目录
SimpleCodeGenerator.rar (43个子文件)
SimpleCodeGenerator
logs
.gitkeep 0B
lib
ant.jar 1.26MB
simple-code-generator.jar 30KB
commons-beanutils.jar 160KB
commons-codec-1.4.jar 57KB
sqljdbc.jar 247KB
commons-configuration-1.10.jar 354KB
log4j-1.2.17.jar 478KB
freemarker-2.3.19.jar 909KB
mysql-connector-java-5.1.8-bin.jar 707KB
commons-dbcp-1.2.1.jar 105KB
.gitignore 41B
ojdbc14.jar 1.47MB
commons-logging-1.0.4.jar 37KB
commons-lang-2.6.jar 278KB
commons-collections-3.2.1.jar 562KB
template
说明 15B
csharp_demo
ActionTemplate.java 2KB
ServiceImplTemplate.java 4KB
DaoInterfaceTemplate.java 756B
EntityRowMapperTemplate.java 702B
EntityTemplate.java 905B
JspTemplate.java 21KB
ActionListTemplate.java 1KB
DaoImplTemplateJDBC.java 2KB
ServiceInterfaceTemplate.java 740B
DaoImplTemplate.java 1KB
java_demo
ActionTemplate.java 3KB
ServiceImplTemplate.java 2KB
DaoInterfaceTemplate.java 903B
EntityRowMapperTemplate.java 687B
EntityTemplate.java 2KB
JspTemplate.java 9KB
ActionListTemplate.java 1KB
DaoImplTemplateJDBC.java 2KB
ServiceInterfaceTemplate.java 849B
DaoImplTemplate.java 3KB
rsrc
icon.png 118KB
help.html 3KB
config.properties 478B
log4j.properties 517B
bin
server.bat 469B
startup.bat 16B
共 43 条
- 1
资源评论
- ym5205wangyifei2018-05-08不错不错哦
- 乐韬科技2020-08-10感谢分享!
- qq_371215852018-04-11还可以的样子
hellohorizon
- 粉丝: 24
- 资源: 22
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功