增加工具按钮权限
parent
e9f8f27864
commit
4440b7e6ba
Binary file not shown.
|
|
@ -4,6 +4,8 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DevExpress.Utils;
|
||||
using MES.Form;
|
||||
using WinformGeneralDeveloperFrame.Commons;
|
||||
namespace WinformGeneralDeveloperFrame
|
||||
{
|
||||
|
|
@ -30,7 +32,7 @@ namespace WinformGeneralDeveloperFrame
|
|||
return flag;
|
||||
}
|
||||
|
||||
public static System.Windows.Forms.Form LoadMdiForm(System.Windows.Forms.Form mainDialog, Type formType)
|
||||
public static System.Windows.Forms.Form LoadMdiForm(System.Windows.Forms.Form mainDialog, Type formType,string code)
|
||||
{
|
||||
|
||||
bool flag = false;
|
||||
|
|
@ -47,11 +49,15 @@ namespace WinformGeneralDeveloperFrame
|
|||
|
||||
if (!flag)
|
||||
{
|
||||
|
||||
form = (System.Windows.Forms.Form)Activator.CreateInstance(formType);
|
||||
var dd = form.GetType().GetBaseType().GetField("menucode");
|
||||
dd.SetValue(form, code);
|
||||
form.MdiParent = mainDialog;
|
||||
form.Show();
|
||||
}
|
||||
|
||||
|
||||
form.BringToFront();
|
||||
form.Activate();
|
||||
return form;
|
||||
|
|
@ -75,7 +81,6 @@ namespace WinformGeneralDeveloperFrame
|
|||
{
|
||||
form = (System.Windows.Forms.Form)Activator.CreateInstance(formType);
|
||||
form.MdiParent = mainDialog;
|
||||
|
||||
}
|
||||
FrmShowForm frmShowForm = form as FrmShowForm;
|
||||
frmShowForm.Text = caption;
|
||||
|
|
|
|||
|
|
@ -17,8 +17,13 @@ namespace MES.Entity
|
|||
public string account{set;get;}
|
||||
[ModelBindControl("txtusername")]
|
||||
public string username{set;get;}
|
||||
|
||||
[ModelBindControl("txtpassword")]
|
||||
public string password{set;get;}
|
||||
public string password
|
||||
{
|
||||
set;
|
||||
get;
|
||||
} = MD5Utils.GetMD5_32("123456");
|
||||
[ModelBindControl("txtemail")]
|
||||
public string email{set;get;}
|
||||
[ModelBindControl("txtmobilephone")]
|
||||
|
|
|
|||
|
|
@ -102,8 +102,26 @@ namespace MES.Form
|
|||
sysMenuInfo info = (sysMenuInfo)this.ControlDataToModel(new sysMenuInfo());
|
||||
using (var db = new MESDB())
|
||||
{
|
||||
db.Entry(info).State=EntityState.Deleted;
|
||||
db.SaveChanges();
|
||||
using (var tran = db.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
db.Entry(info).State = EntityState.Deleted;
|
||||
db.SaveChanges();
|
||||
db.Database.ExecuteSqlCommand($"delete from sysRoleFunction where roleId={info.id}");
|
||||
db.Database.ExecuteSqlCommand($"delete from sysUserRole where roleId={info.id}");
|
||||
tran.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
ex.Message.ShowError();
|
||||
}
|
||||
finally
|
||||
{
|
||||
tran.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -83,11 +83,15 @@ namespace MES.Form
|
|||
|
||||
public override void gridControlMouseDoubleClickFunction(object sender, EventArgs e)
|
||||
{
|
||||
treeList1.DataSource = null;
|
||||
treeList1.DataSource = GetDataTableUtils.SqlTable("角色功能");
|
||||
treeList1.ExpandAll();
|
||||
|
||||
treeList2.DataSource = null;
|
||||
treeList2.DataSource = GetDataTableUtils.SqlTable("用户-角色");
|
||||
treeList2.ExpandAll();
|
||||
|
||||
gridControl1.DataSource = null;
|
||||
using (var db = new MESDB())
|
||||
{
|
||||
ids= db.Database.SqlQuery<int>($"select functionId from sysRoleFunction where roleId={txtid.Text}").ToListAsync().Result;
|
||||
|
|
@ -169,14 +173,16 @@ namespace MES.Form
|
|||
{
|
||||
sql += $"INSERT INTO sysRoleFunction VALUES ({info.id},{item});";
|
||||
}
|
||||
db.Database.ExecuteSqlCommand(sql);
|
||||
if (!string.IsNullOrEmpty(sql))
|
||||
db.Database.ExecuteSqlCommand(sql);
|
||||
var dd = gridControl1.DataSource as IEnumerable<sysUserInfo>;
|
||||
string sql2 = "";
|
||||
foreach (sysUserInfo item in dd)
|
||||
{
|
||||
sql2 += $"INSERT INTO sysUserRole VALUES ({item.id},{info.id});";
|
||||
}
|
||||
db.Database.ExecuteSqlCommand(sql2);
|
||||
if(!string.IsNullOrEmpty(sql2))
|
||||
db.Database.ExecuteSqlCommand(sql2);
|
||||
tran.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -275,8 +281,46 @@ namespace MES.Form
|
|||
sysRoleInfo info = (sysRoleInfo)this.ControlDataToModel(new sysRoleInfo());
|
||||
using (var db = new MESDB())
|
||||
{
|
||||
db.Entry(info).State=EntityState.Deleted;
|
||||
db.SaveChanges();
|
||||
|
||||
using (var tran = db.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
db.Entry(info).State = EntityState.Deleted;
|
||||
db.SaveChanges();
|
||||
|
||||
|
||||
db.sysRoleInfo.AddOrUpdate(info);
|
||||
db.SaveChanges();
|
||||
db.Database.ExecuteSqlCommand($"delete from sysRoleFunction where roleId={info.id}");
|
||||
db.Database.ExecuteSqlCommand($"delete from sysUserRole where roleId={info.id}");
|
||||
|
||||
string sql = "";
|
||||
foreach (var item in ids)
|
||||
{
|
||||
sql += $"INSERT INTO sysRoleFunction VALUES ({info.id},{item});";
|
||||
}
|
||||
db.Database.ExecuteSqlCommand(sql);
|
||||
var dd = gridControl1.DataSource as IEnumerable<sysUserInfo>;
|
||||
string sql2 = "";
|
||||
foreach (sysUserInfo item in dd)
|
||||
{
|
||||
sql2 += $"INSERT INTO sysUserRole VALUES ({item.id},{info.id});";
|
||||
}
|
||||
db.Database.ExecuteSqlCommand(sql2);
|
||||
tran.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
tran.Rollback();
|
||||
ex.Message.ShowError();
|
||||
}
|
||||
finally
|
||||
{
|
||||
tran.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
|
|
@ -50,6 +51,8 @@ namespace MES.Form
|
|||
sysUserInfo info = (sysUserInfo)this.ControlDataToModel(new sysUserInfo());
|
||||
using (var db = new MESDB())
|
||||
{
|
||||
db.Set<sysUserInfo>().Attach(info);
|
||||
db.Entry<sysUserInfo>(info).Property("password").IsModified = false;
|
||||
db.sysUserInfo.AddOrUpdate(info);
|
||||
db.SaveChanges();
|
||||
}
|
||||
|
|
@ -84,12 +87,12 @@ namespace MES.Form
|
|||
txtusername.Focus();
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtpassword.EditValue.ToString()))
|
||||
{
|
||||
"密码不能为空".ShowWarning();
|
||||
txtpassword.Focus();
|
||||
return false;
|
||||
}
|
||||
//if (string.IsNullOrEmpty(txtpassword.EditValue.ToString()))
|
||||
//{
|
||||
// "密码不能为空".ShowWarning();
|
||||
// txtpassword.Focus();
|
||||
// return false;
|
||||
//}
|
||||
if (string.IsNullOrEmpty(txtemail.EditValue.ToString()))
|
||||
{
|
||||
"邮件不能为空".ShowWarning();
|
||||
|
|
@ -174,5 +177,23 @@ namespace MES.Form
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public override bool DelFunction()
|
||||
{
|
||||
try
|
||||
{
|
||||
sysUserInfo info = (sysUserInfo)this.ControlDataToModel(new sysUserInfo());
|
||||
using (var db = new MESDB())
|
||||
{
|
||||
db.Entry(info).State = EntityState.Deleted;
|
||||
db.SaveChanges();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.Message.ShowError();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -60,7 +60,6 @@ namespace MES.Form
|
|||
this.txtid = new DevExpress.XtraEditors.TextEdit();
|
||||
this.txtaccount = new DevExpress.XtraEditors.TextEdit();
|
||||
this.txtusername = new DevExpress.XtraEditors.TextEdit();
|
||||
this.txtpassword = new DevExpress.XtraEditors.TextEdit();
|
||||
this.txtemail = new DevExpress.XtraEditors.TextEdit();
|
||||
this.txtmobilephone = new DevExpress.XtraEditors.TextEdit();
|
||||
this.txtisEnabled = new DevExpress.XtraEditors.CheckEdit();
|
||||
|
|
@ -76,7 +75,6 @@ namespace MES.Form
|
|||
this.layoutControlItem9 = new DevExpress.XtraLayout.LayoutControlItem();
|
||||
this.layoutControlItem11 = new DevExpress.XtraLayout.LayoutControlItem();
|
||||
this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem();
|
||||
this.layoutControlItem4 = new DevExpress.XtraLayout.LayoutControlItem();
|
||||
this.layoutControlItem6 = new DevExpress.XtraLayout.LayoutControlItem();
|
||||
this.layoutControlItem10 = new DevExpress.XtraLayout.LayoutControlItem();
|
||||
this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
|
||||
|
|
@ -100,7 +98,6 @@ namespace MES.Form
|
|||
((System.ComponentModel.ISupportInitialize)(this.txtid.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtaccount.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtusername.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtpassword.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtemail.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtmobilephone.Properties)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtisEnabled.Properties)).BeginInit();
|
||||
|
|
@ -118,7 +115,6 @@ namespace MES.Form
|
|||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem9)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem11)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem6)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
|
||||
|
|
@ -155,8 +151,6 @@ namespace MES.Form
|
|||
this.gridColumn4.Caption = "密码";
|
||||
this.gridColumn4.FieldName = "password";
|
||||
this.gridColumn4.Name = "gridColumn4";
|
||||
this.gridColumn4.Visible = true;
|
||||
this.gridColumn4.VisibleIndex = 2;
|
||||
this.gridColumn4.Width = 201;
|
||||
//
|
||||
// gridColumn5
|
||||
|
|
@ -165,7 +159,7 @@ namespace MES.Form
|
|||
this.gridColumn5.FieldName = "email";
|
||||
this.gridColumn5.Name = "gridColumn5";
|
||||
this.gridColumn5.Visible = true;
|
||||
this.gridColumn5.VisibleIndex = 3;
|
||||
this.gridColumn5.VisibleIndex = 2;
|
||||
this.gridColumn5.Width = 201;
|
||||
//
|
||||
// gridColumn6
|
||||
|
|
@ -174,7 +168,7 @@ namespace MES.Form
|
|||
this.gridColumn6.FieldName = "mobilephone";
|
||||
this.gridColumn6.Name = "gridColumn6";
|
||||
this.gridColumn6.Visible = true;
|
||||
this.gridColumn6.VisibleIndex = 4;
|
||||
this.gridColumn6.VisibleIndex = 3;
|
||||
this.gridColumn6.Width = 201;
|
||||
//
|
||||
// gridColumn7
|
||||
|
|
@ -184,7 +178,7 @@ namespace MES.Form
|
|||
this.gridColumn7.FieldName = "deptId";
|
||||
this.gridColumn7.Name = "gridColumn7";
|
||||
this.gridColumn7.Visible = true;
|
||||
this.gridColumn7.VisibleIndex = 5;
|
||||
this.gridColumn7.VisibleIndex = 4;
|
||||
this.gridColumn7.Width = 201;
|
||||
//
|
||||
// repositoryItemtxtdeptId
|
||||
|
|
@ -202,7 +196,7 @@ namespace MES.Form
|
|||
this.gridColumn8.FieldName = "isEnabled";
|
||||
this.gridColumn8.Name = "gridColumn8";
|
||||
this.gridColumn8.Visible = true;
|
||||
this.gridColumn8.VisibleIndex = 6;
|
||||
this.gridColumn8.VisibleIndex = 5;
|
||||
this.gridColumn8.Width = 201;
|
||||
//
|
||||
// gridColumn9
|
||||
|
|
@ -212,7 +206,7 @@ namespace MES.Form
|
|||
this.gridColumn9.FieldName = "creatorId";
|
||||
this.gridColumn9.Name = "gridColumn9";
|
||||
this.gridColumn9.Visible = true;
|
||||
this.gridColumn9.VisibleIndex = 7;
|
||||
this.gridColumn9.VisibleIndex = 6;
|
||||
this.gridColumn9.Width = 201;
|
||||
//
|
||||
// repositoryItemtxtcreatorId
|
||||
|
|
@ -232,7 +226,7 @@ namespace MES.Form
|
|||
this.gridColumn10.FieldName = "createTime";
|
||||
this.gridColumn10.Name = "gridColumn10";
|
||||
this.gridColumn10.Visible = true;
|
||||
this.gridColumn10.VisibleIndex = 8;
|
||||
this.gridColumn10.VisibleIndex = 7;
|
||||
this.gridColumn10.Width = 201;
|
||||
//
|
||||
// gridColumn11
|
||||
|
|
@ -242,7 +236,7 @@ namespace MES.Form
|
|||
this.gridColumn11.FieldName = "editorId";
|
||||
this.gridColumn11.Name = "gridColumn11";
|
||||
this.gridColumn11.Visible = true;
|
||||
this.gridColumn11.VisibleIndex = 9;
|
||||
this.gridColumn11.VisibleIndex = 8;
|
||||
this.gridColumn11.Width = 201;
|
||||
//
|
||||
// repositoryItemtxteditorId
|
||||
|
|
@ -262,7 +256,7 @@ namespace MES.Form
|
|||
this.gridColumn12.FieldName = "editTime";
|
||||
this.gridColumn12.Name = "gridColumn12";
|
||||
this.gridColumn12.Visible = true;
|
||||
this.gridColumn12.VisibleIndex = 10;
|
||||
this.gridColumn12.VisibleIndex = 9;
|
||||
this.gridColumn12.Width = 201;
|
||||
//
|
||||
// xtraTabControl1
|
||||
|
|
@ -337,7 +331,6 @@ namespace MES.Form
|
|||
this.layoutControl1.Controls.Add(this.txtid);
|
||||
this.layoutControl1.Controls.Add(this.txtaccount);
|
||||
this.layoutControl1.Controls.Add(this.txtusername);
|
||||
this.layoutControl1.Controls.Add(this.txtpassword);
|
||||
this.layoutControl1.Controls.Add(this.txtemail);
|
||||
this.layoutControl1.Controls.Add(this.txtmobilephone);
|
||||
this.layoutControl1.Controls.Add(this.txtisEnabled);
|
||||
|
|
@ -402,14 +395,6 @@ namespace MES.Form
|
|||
this.txtusername.StyleController = this.layoutControl1;
|
||||
this.txtusername.TabIndex = 3;
|
||||
//
|
||||
// txtpassword
|
||||
//
|
||||
this.txtpassword.Location = new System.Drawing.Point(341, 36);
|
||||
this.txtpassword.Name = "txtpassword";
|
||||
this.txtpassword.Size = new System.Drawing.Size(224, 20);
|
||||
this.txtpassword.StyleController = this.layoutControl1;
|
||||
this.txtpassword.TabIndex = 4;
|
||||
//
|
||||
// txtemail
|
||||
//
|
||||
this.txtemail.Location = new System.Drawing.Point(63, 60);
|
||||
|
|
@ -420,7 +405,7 @@ namespace MES.Form
|
|||
//
|
||||
// txtmobilephone
|
||||
//
|
||||
this.txtmobilephone.Location = new System.Drawing.Point(341, 60);
|
||||
this.txtmobilephone.Location = new System.Drawing.Point(341, 36);
|
||||
this.txtmobilephone.Name = "txtmobilephone";
|
||||
this.txtmobilephone.Size = new System.Drawing.Size(224, 20);
|
||||
this.txtmobilephone.StyleController = this.layoutControl1;
|
||||
|
|
@ -512,7 +497,6 @@ namespace MES.Form
|
|||
this.layoutControlItem9,
|
||||
this.layoutControlItem11,
|
||||
this.layoutControlItem2,
|
||||
this.layoutControlItem4,
|
||||
this.layoutControlItem6,
|
||||
this.layoutControlItem10,
|
||||
this.emptySpaceItem1,
|
||||
|
|
@ -593,23 +577,13 @@ namespace MES.Form
|
|||
this.layoutControlItem2.Text = "工号";
|
||||
this.layoutControlItem2.TextSize = new System.Drawing.Size(48, 14);
|
||||
//
|
||||
// layoutControlItem4
|
||||
//
|
||||
this.layoutControlItem4.Control = this.txtpassword;
|
||||
this.layoutControlItem4.CustomizationFormText = "密码";
|
||||
this.layoutControlItem4.Location = new System.Drawing.Point(278, 24);
|
||||
this.layoutControlItem4.Name = "layoutControlItem4";
|
||||
this.layoutControlItem4.Size = new System.Drawing.Size(279, 24);
|
||||
this.layoutControlItem4.Text = "密码";
|
||||
this.layoutControlItem4.TextSize = new System.Drawing.Size(48, 14);
|
||||
//
|
||||
// layoutControlItem6
|
||||
//
|
||||
this.layoutControlItem6.Control = this.txtmobilephone;
|
||||
this.layoutControlItem6.CustomizationFormText = "电话";
|
||||
this.layoutControlItem6.Location = new System.Drawing.Point(278, 48);
|
||||
this.layoutControlItem6.Location = new System.Drawing.Point(278, 24);
|
||||
this.layoutControlItem6.Name = "layoutControlItem6";
|
||||
this.layoutControlItem6.Size = new System.Drawing.Size(279, 24);
|
||||
this.layoutControlItem6.Size = new System.Drawing.Size(279, 48);
|
||||
this.layoutControlItem6.Text = "电话";
|
||||
this.layoutControlItem6.TextSize = new System.Drawing.Size(48, 14);
|
||||
//
|
||||
|
|
@ -678,7 +652,6 @@ namespace MES.Form
|
|||
((System.ComponentModel.ISupportInitialize)(this.txtid.Properties)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtaccount.Properties)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtusername.Properties)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtpassword.Properties)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtemail.Properties)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtmobilephone.Properties)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.txtisEnabled.Properties)).EndInit();
|
||||
|
|
@ -696,7 +669,6 @@ namespace MES.Form
|
|||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem9)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem11)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem4)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem6)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.layoutControlItem10)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
|
||||
|
|
@ -736,8 +708,6 @@ namespace MES.Form
|
|||
///////////////////////////////
|
||||
private DevExpress.XtraEditors.TextEdit txtusername;
|
||||
///////////////////////////////
|
||||
private DevExpress.XtraEditors.TextEdit txtpassword;
|
||||
///////////////////////////////
|
||||
private DevExpress.XtraEditors.TextEdit txtemail;
|
||||
///////////////////////////////
|
||||
private DevExpress.XtraEditors.TextEdit txtmobilephone;
|
||||
|
|
@ -758,7 +728,6 @@ namespace MES.Form
|
|||
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1;
|
||||
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2;
|
||||
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem3;
|
||||
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem4;
|
||||
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem5;
|
||||
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem6;
|
||||
private DevExpress.XtraLayout.LayoutControlItem layoutControlItem8;
|
||||
|
|
|
|||
|
|
@ -30,90 +30,17 @@ namespace WinformGeneralDeveloperFrame
|
|||
private void InitializeComponent()
|
||||
{
|
||||
this.panelControl1 = new DevExpress.XtraEditors.PanelControl();
|
||||
this.btnDel = new DevExpress.XtraEditors.SimpleButton();
|
||||
this.btnCanel = new DevExpress.XtraEditors.SimpleButton();
|
||||
this.btnSearch = new DevExpress.XtraEditors.SimpleButton();
|
||||
this.btnSave = new DevExpress.XtraEditors.SimpleButton();
|
||||
this.btnEdit = new DevExpress.XtraEditors.SimpleButton();
|
||||
this.btnAdd = new DevExpress.XtraEditors.SimpleButton();
|
||||
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).BeginInit();
|
||||
this.panelControl1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panelControl1
|
||||
//
|
||||
this.panelControl1.Controls.Add(this.btnDel);
|
||||
this.panelControl1.Controls.Add(this.btnCanel);
|
||||
this.panelControl1.Controls.Add(this.btnSearch);
|
||||
this.panelControl1.Controls.Add(this.btnSave);
|
||||
this.panelControl1.Controls.Add(this.btnEdit);
|
||||
this.panelControl1.Controls.Add(this.btnAdd);
|
||||
this.panelControl1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panelControl1.Location = new System.Drawing.Point(0, 0);
|
||||
this.panelControl1.Name = "panelControl1";
|
||||
this.panelControl1.Size = new System.Drawing.Size(1245, 34);
|
||||
this.panelControl1.TabIndex = 0;
|
||||
//
|
||||
// btnDel
|
||||
//
|
||||
this.btnDel.Location = new System.Drawing.Point(247, 5);
|
||||
this.btnDel.Name = "btnDel";
|
||||
this.btnDel.PaintStyle = DevExpress.XtraEditors.Controls.PaintStyles.Light;
|
||||
this.btnDel.Size = new System.Drawing.Size(42, 23);
|
||||
this.btnDel.TabIndex = 6;
|
||||
this.btnDel.Text = "删除";
|
||||
this.btnDel.Click += new System.EventHandler(this.btnDel_Click);
|
||||
//
|
||||
// btnCanel
|
||||
//
|
||||
this.btnCanel.Location = new System.Drawing.Point(151, 5);
|
||||
this.btnCanel.Name = "btnCanel";
|
||||
this.btnCanel.PaintStyle = DevExpress.XtraEditors.Controls.PaintStyles.Light;
|
||||
this.btnCanel.Size = new System.Drawing.Size(42, 23);
|
||||
this.btnCanel.TabIndex = 5;
|
||||
this.btnCanel.Text = "取消";
|
||||
this.btnCanel.Click += new System.EventHandler(this.btnCanel_Click);
|
||||
//
|
||||
// btnSearch
|
||||
//
|
||||
this.btnSearch.Location = new System.Drawing.Point(103, 5);
|
||||
this.btnSearch.Name = "btnSearch";
|
||||
this.btnSearch.PaintStyle = DevExpress.XtraEditors.Controls.PaintStyles.Light;
|
||||
this.btnSearch.Size = new System.Drawing.Size(42, 23);
|
||||
this.btnSearch.TabIndex = 4;
|
||||
this.btnSearch.Text = "搜索";
|
||||
this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
this.btnSave.Location = new System.Drawing.Point(199, 5);
|
||||
this.btnSave.Name = "btnSave";
|
||||
this.btnSave.PaintStyle = DevExpress.XtraEditors.Controls.PaintStyles.Light;
|
||||
this.btnSave.Size = new System.Drawing.Size(42, 23);
|
||||
this.btnSave.TabIndex = 2;
|
||||
this.btnSave.Text = "保存";
|
||||
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||
//
|
||||
// btnEdit
|
||||
//
|
||||
this.btnEdit.Location = new System.Drawing.Point(60, 5);
|
||||
this.btnEdit.Name = "btnEdit";
|
||||
this.btnEdit.PaintStyle = DevExpress.XtraEditors.Controls.PaintStyles.Light;
|
||||
this.btnEdit.Size = new System.Drawing.Size(42, 23);
|
||||
this.btnEdit.TabIndex = 1;
|
||||
this.btnEdit.Text = "编辑";
|
||||
this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
|
||||
//
|
||||
// btnAdd
|
||||
//
|
||||
this.btnAdd.Location = new System.Drawing.Point(12, 5);
|
||||
this.btnAdd.Name = "btnAdd";
|
||||
this.btnAdd.PaintStyle = DevExpress.XtraEditors.Controls.PaintStyles.Light;
|
||||
this.btnAdd.Size = new System.Drawing.Size(42, 23);
|
||||
this.btnAdd.TabIndex = 0;
|
||||
this.btnAdd.Text = "新增";
|
||||
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
|
||||
//
|
||||
// FrmBaseForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F);
|
||||
|
|
@ -124,7 +51,6 @@ namespace WinformGeneralDeveloperFrame
|
|||
this.Text = "FrmBaseForm";
|
||||
this.Load += new System.EventHandler(this.FrmBaseForm_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.panelControl1)).EndInit();
|
||||
this.panelControl1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
|
@ -132,11 +58,5 @@ namespace WinformGeneralDeveloperFrame
|
|||
#endregion
|
||||
|
||||
private DevExpress.XtraEditors.PanelControl panelControl1;
|
||||
private DevExpress.XtraEditors.SimpleButton btnAdd;
|
||||
private DevExpress.XtraEditors.SimpleButton btnSave;
|
||||
private DevExpress.XtraEditors.SimpleButton btnEdit;
|
||||
private DevExpress.XtraEditors.SimpleButton btnCanel;
|
||||
private DevExpress.XtraEditors.SimpleButton btnSearch;
|
||||
private DevExpress.XtraEditors.SimpleButton btnDel;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,15 +8,19 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DevExpress.Utils.Extensions;
|
||||
using DevExpress.XtraEditors.Controls;
|
||||
using DevExpress.XtraGrid;
|
||||
using DevExpress.XtraGrid.Views.Grid;
|
||||
using DevExpress.XtraLayout;
|
||||
using DevExpress.XtraTab;
|
||||
using MES.Entity;
|
||||
using WinformGeneralDeveloperFrame.Commons;
|
||||
using MES;
|
||||
|
||||
namespace WinformGeneralDeveloperFrame
|
||||
{
|
||||
public partial class FrmBaseForm : DevExpress.XtraEditors.XtraForm
|
||||
public partial class FrmBaseForm : XtraForm
|
||||
{
|
||||
public string ID = string.Empty; // 主键
|
||||
private XtraTabControl xtraTab;
|
||||
|
|
@ -24,7 +28,7 @@ namespace WinformGeneralDeveloperFrame
|
|||
private GridView gridView;
|
||||
private LayoutControlGroup[] controlGroups;
|
||||
private object DataType;
|
||||
|
||||
public string menucode;
|
||||
public FrmBaseForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
|
@ -32,6 +36,7 @@ namespace WinformGeneralDeveloperFrame
|
|||
|
||||
public void InitFrom(XtraTabControl xtraTab, GridControl gridControl, GridView gridView, LayoutControlGroup[] controlGroups, object DataType)
|
||||
{
|
||||
initTools();
|
||||
InitFrom(xtraTab, gridControl, gridView, controlGroups);
|
||||
this.DataType = DataType;
|
||||
}
|
||||
|
|
@ -117,13 +122,58 @@ namespace WinformGeneralDeveloperFrame
|
|||
if (CheckInput()&&SaveFunction())
|
||||
{
|
||||
"保存成功!".ShowTips();
|
||||
|
||||
InitToolBtntatus(EFormStatus.eView);
|
||||
InitgrdListDataSource();
|
||||
SetControlStatus(controlGroups, true);
|
||||
}
|
||||
|
||||
}
|
||||
public void initTools()
|
||||
{
|
||||
|
||||
List<sysDictTypeInfo> list = null;
|
||||
using (var db=new MESDB())
|
||||
{
|
||||
list = db.sysDictTypeInfo.Where(p => p.pid == 10).ToList();
|
||||
}
|
||||
//List<MenuInfo> list = BLLFactory<Menu>.Instance.GetAll().Where(p => p.IsToolBtn == true).ToList();
|
||||
int i = 1;
|
||||
int width = 0;
|
||||
foreach (sysDictTypeInfo info in list)
|
||||
{
|
||||
if (AppInfo.FunctionList.Contains(menucode+"-"+info.remark))
|
||||
{
|
||||
SimpleButton button = new SimpleButton();
|
||||
button.Name = "btn" + info.remark;
|
||||
button.Text = info.name;
|
||||
button.Location = new Point(width, 5);
|
||||
button.PaintStyle = PaintStyles.Light;
|
||||
button.AutoSize = true;
|
||||
// button.ImageOptions.Image = Image.FromFile(Application.StartupPath + "\\" + info.Icon);
|
||||
button.Click += (sender, e) =>
|
||||
{
|
||||
ToolFunction(sender, e);
|
||||
};
|
||||
this.panelControl1.AddControl(button);
|
||||
width += button.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
public virtual void ToolFunction(object sender, EventArgs e)
|
||||
{
|
||||
string FunctionId = ((SimpleButton)sender).Name;
|
||||
switch (FunctionId)
|
||||
{
|
||||
case "btnAdd": btnAdd_Click(sender,e); break;
|
||||
case "btnEdit": btnEdit_Click(sender, e); break;
|
||||
case "btnSearch": btnSearch_Click(sender, e); break;
|
||||
case "btnCanle": btnCanel_Click(sender, e); break;
|
||||
case "btnSave": btnSave_Click(sender,e); break;
|
||||
case "btnDel": btnDel_Click(sender, e); break;
|
||||
|
||||
}
|
||||
}
|
||||
public virtual void InitgrdListDataSource()
|
||||
{
|
||||
|
||||
|
|
@ -184,75 +234,140 @@ namespace WinformGeneralDeveloperFrame
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void InitToolBtntatus(EFormStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case EFormStatus.eInit:
|
||||
{
|
||||
btnAdd.Enabled = true;
|
||||
btnDel.Enabled = false;
|
||||
btnEdit.Enabled = false;
|
||||
btnSearch.Enabled = true;
|
||||
btnCanel.Enabled = false;
|
||||
btnSave.Enabled = false;
|
||||
}; break;
|
||||
{
|
||||
foreach (var button in panelControl1.Controls)
|
||||
{
|
||||
if (button.GetType().Name == "SimpleButton")
|
||||
{
|
||||
var btn = (SimpleButton)button;
|
||||
if (btn.Name == "btnAdd" || btn.Name == "btnSearch" )
|
||||
{
|
||||
btn.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}; break;
|
||||
case EFormStatus.eView:
|
||||
{
|
||||
btnAdd.Enabled = true;
|
||||
btnDel.Enabled = true;
|
||||
btnEdit.Enabled = true;
|
||||
btnSearch.Enabled = false;
|
||||
btnCanel.Enabled = false;
|
||||
btnSave.Enabled = false;
|
||||
}; break;
|
||||
{
|
||||
foreach (var button in panelControl1.Controls)
|
||||
{
|
||||
if (button.GetType().Name == "SimpleButton")
|
||||
{
|
||||
var btn = (SimpleButton)button;
|
||||
if (btn.Name == "btnAdd" || btn.Name == "btnDel" || btn.Name == "btnEdit")
|
||||
{
|
||||
btn.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}; break;
|
||||
case EFormStatus.eViewTab:
|
||||
{
|
||||
btnAdd.Enabled = true;
|
||||
btnDel.Enabled = false;
|
||||
btnEdit.Enabled = false;
|
||||
btnSearch.Enabled = false;
|
||||
btnCanel.Enabled = false;
|
||||
btnSave.Enabled = false;
|
||||
}; break;
|
||||
{
|
||||
foreach (var button in panelControl1.Controls)
|
||||
{
|
||||
if (button.GetType().Name == "SimpleButton")
|
||||
{
|
||||
var btn = (SimpleButton)button;
|
||||
if (btn.Name == "btnAdd")
|
||||
{
|
||||
btn.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}; break;
|
||||
case EFormStatus.eAdd:
|
||||
{
|
||||
btnAdd.Enabled = false;
|
||||
btnDel.Enabled = false;
|
||||
btnEdit.Enabled = false;
|
||||
btnSearch.Enabled = false;
|
||||
btnCanel.Enabled = true;
|
||||
btnSave.Enabled = true;
|
||||
}; break;
|
||||
{
|
||||
foreach (var button in panelControl1.Controls)
|
||||
{
|
||||
if (button.GetType().Name == "SimpleButton")
|
||||
{
|
||||
var btn = (SimpleButton)button;
|
||||
if (btn.Name == "btnCanel" || btn.Name == "btnSave" )
|
||||
{
|
||||
btn.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}; break;
|
||||
case EFormStatus.eDelete:
|
||||
{
|
||||
btnAdd.Enabled = true;
|
||||
btnDel.Enabled = false;
|
||||
btnEdit.Enabled = false;
|
||||
btnSearch.Enabled = true;
|
||||
btnCanel.Enabled = false;
|
||||
btnSave.Enabled = false;
|
||||
} ;break;
|
||||
{
|
||||
foreach (var button in panelControl1.Controls)
|
||||
{
|
||||
if (button.GetType().Name == "SimpleButton")
|
||||
{
|
||||
var btn = (SimpleButton)button;
|
||||
if (btn.Name == "btnAdd" || btn.Name == "btnSearch" )
|
||||
{
|
||||
btn.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}; break;
|
||||
case EFormStatus.eEdit:
|
||||
{
|
||||
btnAdd.Enabled = false;
|
||||
btnDel.Enabled = false;
|
||||
btnEdit.Enabled = false;
|
||||
btnSearch.Enabled = false;
|
||||
btnCanel.Enabled = true;
|
||||
btnSave.Enabled = true;
|
||||
{
|
||||
foreach (var button in panelControl1.Controls)
|
||||
{
|
||||
if (button.GetType().Name == "SimpleButton")
|
||||
{
|
||||
var btn = (SimpleButton)button;
|
||||
if (btn.Name == "btnCanle" || btn.Name == "btnSave")
|
||||
{
|
||||
btn.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}; break;
|
||||
case EFormStatus.eCanel:
|
||||
{
|
||||
btnAdd.Enabled = true;
|
||||
btnDel.Enabled = true;
|
||||
btnEdit.Enabled = true;
|
||||
btnSearch.Enabled = false;
|
||||
btnCanel.Enabled = false;
|
||||
btnSave.Enabled = false;
|
||||
} ;break;
|
||||
{
|
||||
foreach (var button in panelControl1.Controls)
|
||||
{
|
||||
if (button.GetType().Name == "SimpleButton")
|
||||
{
|
||||
var btn = (SimpleButton)button;
|
||||
if (btn.Name == "btnAdd" || btn.Name == "btnDel"||btn.Name== "btnEdit")
|
||||
{
|
||||
btn.Enabled = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.Enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}; break;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLayoutControlReadOnly(bool flag, LayoutControlGroup col)
|
||||
{
|
||||
foreach (var con1 in col.Items)
|
||||
|
|
|
|||
|
|
@ -117,4 +117,10 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="panelControl1.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
|
|
@ -24,50 +24,6 @@ namespace WinformGeneralDeveloperFrame
|
|||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void simpleButton1_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChildWinManagement.LoadMdiForm(mainform,typeof(XtraForm1));
|
||||
}
|
||||
|
||||
private void simpleButton2_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysDataTable));
|
||||
|
||||
}
|
||||
|
||||
private void simpleButton3_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysDataBase));
|
||||
|
||||
}
|
||||
|
||||
private void simpleButton4_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChildWinManagement.LoadMdiForm(mainform, typeof(frmSelectDataBase));
|
||||
|
||||
}
|
||||
|
||||
private void simpleButton5_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysMenu));
|
||||
}
|
||||
|
||||
private void simpleButton6_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChildWinManagement.LoadMdiForm(mainform, typeof(MES.Form.FrmsysUser));
|
||||
}
|
||||
|
||||
private void simpleButton8_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysDictType));
|
||||
}
|
||||
|
||||
private void simpleButton7_Click(object sender, EventArgs e)
|
||||
{
|
||||
ChildWinManagement.LoadMdiForm(mainform, typeof(FrmsysDictData));
|
||||
}
|
||||
|
||||
private void FrmShowForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
|
@ -105,7 +61,7 @@ namespace WinformGeneralDeveloperFrame
|
|||
if (tempAssembly != null)
|
||||
{
|
||||
Type objType = tempAssembly.GetType(type);
|
||||
ChildWinManagement.LoadMdiForm(mainform, objType);
|
||||
ChildWinManagement.LoadMdiForm(mainform, objType,item.functionCode);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ using WinformGeneralDeveloperFrame.Commons;
|
|||
|
||||
namespace MES.Form
|
||||
{
|
||||
public partial class FrmsysDataBase : XtraForm
|
||||
public partial class FrmsysDataBase : FrmBaseForm
|
||||
{
|
||||
private string _strConnectionString = "Server={0};Database={1};User Id = {2}; Password={3};Connect Timeout = 2";
|
||||
public sysDataBase dbEntity;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ using WinformGeneralDeveloperFrame.Commons;
|
|||
|
||||
namespace MES.Form
|
||||
{
|
||||
public partial class FrmsysDataTable : XtraForm
|
||||
public partial class FrmsysDataTable : FrmBaseForm
|
||||
{
|
||||
public FrmsysDataTable()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -108,9 +108,11 @@ namespace Login
|
|||
if (user == null)
|
||||
{
|
||||
"账号不存在!".ShowTips();
|
||||
return;
|
||||
}else if (!user.password.Equals(MD5Utils.GetMD5_32(Password.Text)))
|
||||
{
|
||||
"密码错误!!".ShowTips();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -118,8 +120,8 @@ namespace Login
|
|||
AppInfo.LoginUserInfo = user;
|
||||
}
|
||||
}
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private bool CheckInput()
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@
|
|||
this.User.Name = "User";
|
||||
this.User.Size = new System.Drawing.Size(215, 17);
|
||||
this.User.TabIndex = 30;
|
||||
this.User.Text = "0010498";
|
||||
this.User.WaterColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(127)))), ((int)(((byte)(127)))));
|
||||
this.User.WaterFont = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.User.WaterText = "请输入账号";
|
||||
|
|
@ -222,6 +223,7 @@
|
|||
this.Password.PasswordChar = '*';
|
||||
this.Password.Size = new System.Drawing.Size(215, 17);
|
||||
this.Password.TabIndex = 20;
|
||||
this.Password.Text = "123456";
|
||||
this.Password.WaterColor = System.Drawing.Color.FromArgb(((int)(((byte)(127)))), ((int)(((byte)(127)))), ((int)(((byte)(127)))));
|
||||
this.Password.WaterFont = new System.Drawing.Font("微软雅黑", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.Password.WaterText = "请输入密码";
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -12,7 +12,7 @@ using WinformGeneralDeveloperFrame.Commons;
|
|||
|
||||
namespace WinformGeneralDeveloperFrame
|
||||
{
|
||||
public partial class frmSelectDataBase : DevExpress.XtraEditors.XtraForm
|
||||
public partial class frmSelectDataBase : FrmBaseForm
|
||||
{
|
||||
public frmSelectDataBase()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue