基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
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 Lskj.Control;
|
||||
using Lskj.Business.Impl;
|
||||
using Lskj.Model;
|
||||
using Lskj.Control.Model;
|
||||
using Lskj.Data;
|
||||
|
||||
namespace Lskj.MesStart
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫码界面
|
||||
/// </summary>
|
||||
public partial class FrmScan : BaseForm
|
||||
{
|
||||
public string MenuCode;
|
||||
public string ScanCode;
|
||||
public string PopupID;
|
||||
public DataTable RightMenuTable = new DataTable();
|
||||
|
||||
/// <summary>
|
||||
/// 表格列
|
||||
/// </summary>
|
||||
private DataTable _gridColumns = new DataTable();
|
||||
|
||||
public FrmScan()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
void OnBtnOkClick(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
string scanCode = this.txtScan.Text;
|
||||
|
||||
string insertSql = string.Empty;
|
||||
DataRow[] tmRows = RightMenuTable.Select(string.Format("id='{0}'", PopupID));
|
||||
if (tmRows == null || tmRows.Length == 0)
|
||||
{
|
||||
MessageUtil.Show("未找到右键菜单配置.");
|
||||
return;
|
||||
}
|
||||
DataRow tmRow = tmRows[0];
|
||||
if (string.IsNullOrEmpty(tmRow["dllpar1"] + "") || string.IsNullOrEmpty(tmRow["dllpar2"] + ""))
|
||||
{
|
||||
MessageUtil.Show("扫码右键菜单未配置参数1或参数2.");
|
||||
return;
|
||||
}
|
||||
|
||||
string menuCode = tmRow["dllpar1"] + "";
|
||||
string scanField = (tmRow["dllpar2"] + "").Replace("{", "").Replace("}", "");
|
||||
string scanValue = scanCode;
|
||||
string fields = string.Empty;
|
||||
string values = string.Empty;
|
||||
ModuleModel scanModel = new ModuleModel(MainImpl.GetSystemdllTab(menuCode));
|
||||
string primaryKey = BaseImpl.GetBasePrimaryKey(menuCode);
|
||||
string primaryValue = string.Empty;
|
||||
DataTable colTable = BaseModuleImpl.GetBaseGridColumns(menuCode);
|
||||
|
||||
foreach (DataRow rowItem in colTable.Rows)
|
||||
{
|
||||
GridColumnModel model = new GridColumnModel(rowItem);
|
||||
string fieldName = model.FieldName;
|
||||
string fieldValue = model.FieldName.Equals(scanField, StringComparison.OrdinalIgnoreCase) ? scanValue : BaseImpl.GetDefaultValue(model.DefaultValue);
|
||||
|
||||
if (fieldName.Equals(primaryKey))
|
||||
primaryValue = fieldValue;
|
||||
|
||||
if (fieldName.Equals("id")) continue;
|
||||
|
||||
fields += fieldName + ",";
|
||||
values += string.IsNullOrEmpty(fieldValue) ? "NULL," : "'" + fieldValue + "',";
|
||||
}
|
||||
|
||||
string execSql = string.Format("insert into {0}({1}) values ({2})", scanModel.MenuTable, fields.TrimEnd(','), values.TrimEnd(','));
|
||||
BaseSaveModel saveModel = new BaseSaveModel
|
||||
{
|
||||
BaseSaveType = SaveType.Add,
|
||||
BaseSql = execSql,
|
||||
KeyField = primaryKey,
|
||||
FieldValue = primaryValue,
|
||||
MenuCode = menuCode,
|
||||
TableName = scanModel.MenuTable,
|
||||
NewVer = scanModel.NewVer
|
||||
};
|
||||
int result = BaseModuleImpl.SaveBasePanelData(saveModel);
|
||||
|
||||
if (result == 1)
|
||||
{
|
||||
MessageUtil.Show("操作成功!");
|
||||
this.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lblTip.Text = "提示:" + saveModel.FaultMsg;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//MessageUtil.Show(ex);
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
void OnTxtScanKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
this.ScanCode = this.txtScan.Text;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
void OnFrmScanLoad(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
this._gridColumns = BaseModuleImpl.GetBaseGridColumns(this.MenuCode);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string Message = ErrorMessage.PromptErrorMessage(ex);
|
||||
MessageUtil.Show(Message,ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user