128 lines
3.8 KiB
Plaintext
128 lines
3.8 KiB
Plaintext
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.ComponentModel;
|
||
|
|
using System.Data;
|
||
|
|
using System.Drawing;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Windows.Forms;
|
||
|
|
using WinformGeneralDeveloperFrame;
|
||
|
|
using WinformGeneralDeveloperFrame.Commons;
|
||
|
|
using DevExpress.XtraLayout;
|
||
|
|
using ${NameSpace}.Entity;
|
||
|
|
using System.Data.Entity.Migrations;
|
||
|
|
using System.Data.Entity;
|
||
|
|
namespace ${NameSpace}.Form
|
||
|
|
{
|
||
|
|
public partial class Frm${tableName} : FrmBaseForm
|
||
|
|
{
|
||
|
|
private Dictionary<string, string> fieldDictionary = new Dictionary<string, string>();
|
||
|
|
public Frm${tableName}()
|
||
|
|
{
|
||
|
|
InitializeComponent();
|
||
|
|
}
|
||
|
|
private void Frm${tableName}_Load(object sender, EventArgs e)
|
||
|
|
{
|
||
|
|
|
||
|
|
InitFrom(xtraTabControl1,grdList,grdListView,new LayoutControlGroup[]{layoutControlGroup1},new ${tableName}Info());
|
||
|
|
}
|
||
|
|
private void Init()
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#foreach($info in $EntityList)
|
||
|
|
#if(${info.controlType}=="LookUpEdit"||${info.controlType}=="TreeListLookUpEdit"||${info.controlType}=="CheckedComboBoxEdit"||${info.controlType}=="ComboBoxEdit")
|
||
|
|
#if(${info.controlType}=="LookUpEdit")
|
||
|
|
#if(${info.isEdit})
|
||
|
|
${info.controlName}.Properties.DataSource = GetDataTableUtils.SqlTable("${info.DataTableName}");
|
||
|
|
#end
|
||
|
|
repositoryItem${info.controlName}.DataSource= GetDataTableUtils.SqlTable("${info.DataTableName}");
|
||
|
|
#elseif(${info.controlType}=="TreeListLookUpEdit")
|
||
|
|
#if(${info.isEdit})
|
||
|
|
${info.controlName}.Properties.DataSource = GetDataTableUtils.SqlTable("${info.DataTableName}");
|
||
|
|
#end
|
||
|
|
repositoryItemTreeList${info.controlName}.DataSource= GetDataTableUtils.SqlTable("${info.DataTableName}");
|
||
|
|
#elseif(${info.controlType}=="CheckedComboBoxEdit")
|
||
|
|
#if(${info.isEdit})
|
||
|
|
${info.controlName}.Properties.DataSource = GetDataTableUtils.SqlTable("${info.DataTableName}");
|
||
|
|
#end
|
||
|
|
#else
|
||
|
|
#if(${info.isEdit})
|
||
|
|
foreach (DataRow info in GetDataTableUtils.SqlTable("${info.DataTableName}").Rows)
|
||
|
|
{
|
||
|
|
${info.controlName}.Properties.Items.Add(info.ItemArray[0].ToString());
|
||
|
|
}
|
||
|
|
#end
|
||
|
|
#end
|
||
|
|
#end
|
||
|
|
#end
|
||
|
|
#foreach($info in $EntityList)
|
||
|
|
#if(${info.isSearch})
|
||
|
|
fieldDictionary.Add("${info.controlLabelName}","${info.dataBaseFieldName");
|
||
|
|
#end
|
||
|
|
#end
|
||
|
|
|
||
|
|
}
|
||
|
|
public override bool SaveFunction()
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
${tableName}Info info= (${tableName}Info)this.ControlDataToModel(new ${tableName}Info());
|
||
|
|
using (var db = new ${NameSpace}DB())
|
||
|
|
{
|
||
|
|
db.${tableName}Info.AddOrUpdate(info);
|
||
|
|
db.SaveChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
ex.Message.ShowError();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
public override void InitgrdListDataSource()
|
||
|
|
{
|
||
|
|
using (var con=new ${NameSpace}DB())///
|
||
|
|
{
|
||
|
|
grdList.DataSource=con.${tableName}Info.ToList();
|
||
|
|
}
|
||
|
|
Init();
|
||
|
|
}
|
||
|
|
|
||
|
|
public override bool CheckInput()
|
||
|
|
{
|
||
|
|
#foreach($info in $EntityList)
|
||
|
|
#if(!${info.isKey}&&${info.isCheck})
|
||
|
|
if(string.IsNullOrEmpty(${info.controlName}.EditValue.ToString()))
|
||
|
|
{
|
||
|
|
"${info.controlLabelName}不能为空".ShowWarning();
|
||
|
|
${info.controlName}.Focus();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
#end
|
||
|
|
#end
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
public override bool DelFunction()
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
${tableName}Info info = (${tableName}Info)this.ControlDataToModel(new ${tableName}Info());
|
||
|
|
using (var db = new ${NameSpace}DB())
|
||
|
|
{
|
||
|
|
db.Entry(info).State=EntityState.Deleted;
|
||
|
|
db.SaveChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (Exception ex)
|
||
|
|
{
|
||
|
|
ex.Message.ShowError();
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|