|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using Mesnac.Codd.Session;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.Default.Purview.BasRole
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加角色业务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class InsertAction : DefaultAction, IAction
|
|
|
|
|
{
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime); //必须调用
|
|
|
|
|
ICSharpCode.Core.LoggingService<InsertAction>.Debug("角色信息-添加...");
|
|
|
|
|
|
|
|
|
|
FrmInsert frmInsert = new FrmInsert();
|
|
|
|
|
DialogResult result = frmInsert.ShowDialog();
|
|
|
|
|
if (result == DialogResult.OK)
|
|
|
|
|
{
|
|
|
|
|
string guid = Guid.NewGuid().ToString().ToUpper();
|
|
|
|
|
int seqIndex = GetNextSeqIndex();
|
|
|
|
|
string roleName = frmInsert.RoleName;
|
|
|
|
|
string strSql = @"insert into BasRole(GUID, SeqIndex, RoleName, DeleteFlag)
|
|
|
|
|
values(@GUID, @SeqIndex, @RoleName, @DeleteFlag)";
|
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandType = System.Data.CommandType.Text;
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
|
|
dbHelper.AddParameter("@GUID", guid);
|
|
|
|
|
dbHelper.AddParameter("@SeqIndex", seqIndex);
|
|
|
|
|
dbHelper.AddParameter("@RoleName", roleName);
|
|
|
|
|
dbHelper.AddParameter("@DeleteFlag", "0");
|
|
|
|
|
dbHelper.ExecuteNonQuery();
|
|
|
|
|
|
|
|
|
|
//刷新DataGridView数据
|
|
|
|
|
DbMCControl dgBasRole = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "BasRole").FirstOrDefault();
|
|
|
|
|
if (dgBasRole == null || !(dgBasRole.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InsertAction>.Warn("{角色信息-添加} 缺少角色DataGridView控件...");
|
|
|
|
|
runtime.IsReturn = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DataTable table = dbHelper.GetDataTableBySql(dgBasRole.BaseControl.ActionDataSource);
|
|
|
|
|
dgBasRole.BaseControl.BindDataSource = table;
|
|
|
|
|
|
|
|
|
|
#region 记录操作日志
|
|
|
|
|
|
|
|
|
|
string logContent = String.Format("SeqIndex={0}, RoleName={1}", seqIndex, roleName);
|
|
|
|
|
base.DBLog(logContent);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取下一个可用的角色序号
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>返回可用的用户序号</returns>
|
|
|
|
|
public int GetNextSeqIndex()
|
|
|
|
|
{
|
|
|
|
|
string strSql = "select MAX(SeqIndex) from BasRole";
|
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
|
|
|
dbHelper.ClearParameter();
|
|
|
|
|
dbHelper.CommandText = strSql;
|
|
|
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
|
object result = dbHelper.ToScalar();
|
|
|
|
|
if (result != null && result != System.DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
string SeqIndex = result.ToString();
|
|
|
|
|
int intSeqIndex = 1;
|
|
|
|
|
if (int.TryParse(SeqIndex, out intSeqIndex))
|
|
|
|
|
{
|
|
|
|
|
intSeqIndex++;
|
|
|
|
|
return intSeqIndex;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|