ab56a9bcf7
SVN-Revision: r240
976 lines
40 KiB
C#
976 lines
40 KiB
C#
using DevExpress.LookAndFeel;
|
|
using Lskj.AutoUpdate;
|
|
using Lskj.Business;
|
|
using Lskj.Business.Impl;
|
|
using Lskj.Control;
|
|
using Lskj.Control.Model;
|
|
using Lskj.Core;
|
|
using Lskj.Data;
|
|
using Lskj.Main;
|
|
using Lskj.Model;
|
|
using Lskj.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using System.Xml;
|
|
|
|
namespace Lskj.BsMes
|
|
{
|
|
public partial class FrmMain : BaseForm
|
|
{
|
|
private DevExpress.XtraEditors.ComboBoxEdit cbLedger
|
|
{
|
|
get
|
|
{
|
|
return this._cbLedger.ComboBoxEdit;
|
|
}
|
|
}
|
|
private DevExpress.XtraEditors.ComboBoxEdit cbCJ
|
|
{
|
|
get
|
|
{
|
|
return this._cbCJ.ComboBoxEdit;
|
|
}
|
|
}
|
|
private DevExpress.XtraEditors.ComboBoxEdit cbJT
|
|
{
|
|
get
|
|
{
|
|
return this._cbJT.ComboBoxEdit;
|
|
}
|
|
}
|
|
private DevExpress.XtraEditors.ComboBoxEdit cbBZ
|
|
{
|
|
get
|
|
{
|
|
return this._cbBZ.ComboBoxEdit;
|
|
}
|
|
}
|
|
private Lskj.Control.AutoGridLookUp txtUserName
|
|
{
|
|
get
|
|
{
|
|
return this._txtUserName.AutoGridLookUp;
|
|
}
|
|
}
|
|
private DevExpress.XtraEditors.TextEdit txtPassword
|
|
{
|
|
get
|
|
{
|
|
return this._txtPassword.TextBoxEdit;
|
|
}
|
|
}
|
|
private string MesLoginConfig = "MesLoginConfig.ini";
|
|
private string MesUserInputBefore = "P_MesLoginBefore ";
|
|
private DataTable mUserTable, mLedgerTable, mWorkTable, mJTTable, mBZTable;
|
|
private static string Logobg = @"Mes\logo.png";
|
|
/// <summary>
|
|
/// 用户下拉框数据源
|
|
/// </summary>
|
|
private DataTable _userTable;
|
|
/// <summary>
|
|
/// 鼠标位置
|
|
/// </summary>
|
|
private Point point;
|
|
public FrmMain()
|
|
{
|
|
InitializeComponent();
|
|
this._txtUserName.TextChanged += new EventHandler(OnTxtUserNameLostFocus);
|
|
this.Load += new EventHandler(OnFrmMain_Load);
|
|
}
|
|
#region 事件
|
|
/// <summary>
|
|
/// 窗体初始化
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnFrmMain_Load(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
InitFormStyle();
|
|
string iniPath = Path.Combine(new string[] { PubUtil.AbsolutelyPath, MesLoginConfig });
|
|
if (!File.Exists(iniPath))
|
|
{
|
|
File.Create(iniPath);
|
|
}
|
|
//this.BackgroundImage = getBitmap();
|
|
this.cbBZ.SelectedIndex = 0;
|
|
this.SetUsers();
|
|
this.SetLedgers();
|
|
this.mUserTable = MainImpl.GetEmployeeList();
|
|
this.SetCJ();
|
|
this.SetJT();
|
|
this.SetBZ();
|
|
this.SetLocalCongfig();
|
|
if (string.IsNullOrEmpty(this._txtUserName.Text))
|
|
{
|
|
this._txtUserName.Focus();
|
|
}
|
|
else
|
|
{
|
|
this._txtPassword.Focus();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
#endregion
|
|
#region 方法
|
|
/// <summary>
|
|
/// 窗体属性设置
|
|
/// </summary>
|
|
private void InitFormStyle()
|
|
{
|
|
this._cbCJ.ImageLabel.Appearance.Image = global::Lskj.BsMes.Properties.Resources.cj;
|
|
this._cbCJ.ComboBoxEdit.Properties.NullValuePrompt = "请选择车间";
|
|
this._cbCJ.ComboBoxEdit.Properties.NullValuePromptShowForEmptyValue = true;
|
|
this._cbJT.ImageLabel.Appearance.Image = global::Lskj.BsMes.Properties.Resources.jt;
|
|
this._cbJT.ComboBoxEdit.Properties.NullValuePrompt = "请选择机台";
|
|
this._cbJT.ComboBoxEdit.Properties.NullValuePromptShowForEmptyValue = true;
|
|
this._cbBZ.ImageLabel.Appearance.Image = global::Lskj.BsMes.Properties.Resources.bc;
|
|
this._cbBZ.ComboBoxEdit.Properties.NullValuePrompt = "请选择班次";
|
|
this._cbBZ.ComboBoxEdit.Properties.NullValuePromptShowForEmptyValue = true;
|
|
this._txtUserName.ImageLabel.Appearance.Image = global::Lskj.BsMes.Properties.Resources.user;
|
|
this._txtUserName.AutoGridLookUp.Properties.NullValuePrompt = "请输入用户名";
|
|
this._txtUserName.AutoGridLookUp.Properties.NullValuePromptShowForEmptyValue = true;
|
|
this._txtPassword.ImageLabel.Appearance.Image = global::Lskj.BsMes.Properties.Resources.password;
|
|
this._txtPassword.TextBoxEdit.Properties.NullValuePrompt = "密码";
|
|
this._txtPassword.TextBoxEdit.Properties.NullValuePromptShowForEmptyValue = true;
|
|
this._txtPassword.TextBoxEdit.Properties.PasswordChar = '●';
|
|
|
|
this.btnClose.Click += new EventHandler(btnClose_Click);
|
|
this.btnLogin.Click += new EventHandler(OnLoginClick);
|
|
this.txtPassword.KeyDown += new KeyEventHandler(OnPasswordKeyDown);
|
|
this.cbJT.SelectedIndexChanged += new EventHandler(JTSelectedIndexChanged);
|
|
this.cbCJ.SelectedIndexChanged += new EventHandler(cbCJ_SelectedIndexChanged);
|
|
|
|
this.imageCarouseBox.MouseDown += new MouseEventHandler(OnImageCarouseBox_MouseDown);
|
|
this.imageCarouseBox.MouseUp += new MouseEventHandler(OnImageCarouseBox_MouseUp);
|
|
this.imageCarouseBox.MouseMove += new MouseEventHandler(OnImageCarouseBox_MouseMove);
|
|
this.imageCarouseBox.ImageFrameHeight = this.imageCarouseBox.Height;
|
|
this.imageCarouseBox.ImageFrameWidth = this.imageCarouseBox.Width;
|
|
this.imageCarouseBox.AnimationTime = 200;
|
|
this.imageCarouseBox.IntervalTime = 4000;
|
|
string[] titles = new string[] { "装饰新材料行业", "装饰新材料行业一", "装饰新材料行业二" };
|
|
string[] mainStrs = new string[] { "朗速软件 “印刷新材料行业ERP一体化管理平台” 是从原纸、印刷纸、浸胶纸、饰面板、PVC板等行业涉及HR人力、CRM客户关系、新产品研发、销售管理、采购管理、智能仓库、智能排产、品质监控、MES生产过程、帐务成本、版辊、钢板固定资产设备全系列软件产品、多维度一体化综合管理平台。", "朗速软件 “印刷新材料行业ERP一体化管理平台” 是从原纸、印刷纸、浸胶纸、饰面板、PVC板等行业涉及HR人力、CRM客户关系、新产品研发、销售管理、采购管理、智能仓库、智能排产、品质监控、MES生产过程、帐务成本、版辊、钢板固定资产设备全系列软件产品、多维度一体化综合管理平台。", "朗速软件 “印刷新材料行业ERP一体化管理平台” 是从原纸、印刷纸、浸胶纸、饰面板、PVC板等行业涉及HR人力、CRM客户关系、新产品研发、销售管理、采购管理、智能仓库、智能排产、品质监控、MES生产过程、帐务成本、版辊、钢板固定资产设备全系列软件产品、多维度一体化综合管理平台。" };
|
|
for (int i = 0; i < 3; i++)
|
|
{
|
|
string title = titles[i];
|
|
string mainStr = mainStrs[i];
|
|
string infoStr = "Copyright @ 2013-2018";
|
|
ImageCarouselExt.ImageItem image = new ImageCarouselExt.ImageItem();
|
|
Image imageFile = global::Lskj.BsMes.Properties.Resources.bkImag;
|
|
Image iconFile = global::Lskj.BsMes.Properties.Resources.logo;
|
|
//写入文字
|
|
Graphics g = Graphics.FromImage(imageFile);
|
|
Font titleFont = new Font("微软雅黑", 34, FontStyle.Underline | FontStyle.Bold);
|
|
RectangleF titleRect = new RectangleF();
|
|
titleRect.Location = new PointF((float)imageFile.Width * (float)0.1, (float)imageFile.Height * (float)0.7);
|
|
titleRect.Size = new SizeF((float)imageFile.Width * (float)0.5, (float)imageFile.Height * (float)0.5);
|
|
Font mainStrFont = new Font("微软雅黑", 18);
|
|
RectangleF mainStrRect = new RectangleF();
|
|
mainStrRect.Location = new PointF((float)imageFile.Width * (float)0.1, (float)imageFile.Height * (float)0.8);
|
|
mainStrRect.Size = new SizeF((float)imageFile.Width * (float)0.5, (float)imageFile.Height * (float)0.5);
|
|
RectangleF infoRect = new RectangleF();
|
|
infoRect.Size = new SizeF((float)imageFile.Width * (float)0.5, mainStrFont.Height);
|
|
infoRect.Location = new PointF((imageFile.Width - infoRect.Size.Width) / 2, imageFile.Height - 50);
|
|
SolidBrush sbrush = new SolidBrush(System.Drawing.Color.White);
|
|
g.DrawString(title, titleFont, sbrush, titleRect);
|
|
g.DrawString(mainStr, mainStrFont, sbrush, mainStrRect);
|
|
StringFormat StringFormat = new StringFormat();
|
|
StringFormat.Alignment = StringAlignment.Center;//居中显示
|
|
g.DrawString(infoStr, mainStrFont, sbrush, infoRect, StringFormat);
|
|
g.DrawImage(iconFile, new Point(100, 100));
|
|
//
|
|
image.Image = imageFile;
|
|
this.imageCarouseBox.Images.Add(image);
|
|
}
|
|
this.imageCarouseBox.Play();
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置帐套信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-09 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetLedgers()
|
|
{
|
|
// 获取帐套信息
|
|
this.mUserTable = MainImpl.GetLedgerList();
|
|
cbLedger.Properties.Items.Clear();
|
|
|
|
if (this.mUserTable.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow item in this.mUserTable.Rows)
|
|
{
|
|
cbLedger.Properties.Items.Add(item["ShowName"]);
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(DBConfig.Instance.DataBook))
|
|
{
|
|
|
|
}
|
|
|
|
cbLedger.Text = string.IsNullOrEmpty(DBConfig.Instance.DataBook) || this.mUserTable.Rows.Cast<DataRow>().FirstOrDefault(x => DBConfig.Instance.DataBook.Equals(x["ShowName"] + "")) == null
|
|
? this.mUserTable.Rows[0]["ShowName"] + "" : DBConfig.Instance.DataBook;
|
|
}
|
|
else
|
|
{
|
|
cbLedger.Enabled = false;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置工作车间</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-07-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetCJ()
|
|
{
|
|
try
|
|
{
|
|
this.mWorkTable = MainImpl.MesGetCJ();
|
|
foreach (DataRow item in this.mWorkTable.Rows)
|
|
{
|
|
this.cbCJ.Properties.Items.Add(item["mc"] + "");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置机台数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetJT()
|
|
{
|
|
try
|
|
{
|
|
DataRow[] rows = this.mWorkTable.Select(string.Format("mc = '{0}'", this.cbCJ.SelectedItem + ""));
|
|
this.cbJT.Properties.Items.Clear();
|
|
|
|
if (rows != null && rows.Length > 0)
|
|
{
|
|
this.mJTTable = MainImpl.MesGetJT(rows[0]["dm"] + "");
|
|
foreach (DataRow item in this.mJTTable.Rows)
|
|
{
|
|
this.cbJT.Properties.Items.Add(item["mc"] + "");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置班组数据</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetBZ()
|
|
{
|
|
this.cbBZ.Properties.Items.Clear();
|
|
|
|
this.mBZTable = MainImpl.MesGetBZ();
|
|
this.cbBZ.Properties.Items.Add("");
|
|
foreach (DataRow item in this.mBZTable.Rows)
|
|
{
|
|
this.cbBZ.Properties.Items.Add(item["mc"] + "");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:加载本地信息</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期: </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetLocalCongfig()
|
|
{
|
|
this.cbCJ.SelectedItem = IniHelper.Read(MesLoginConfig, "CJ");
|
|
this.cbJT.SelectedItem = IniHelper.Read(MesLoginConfig, "JT");
|
|
this.cbBZ.SelectedItem = IniHelper.Read(MesLoginConfig, "BZ");
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:启动自动更新</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-02-23 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void StartAutoUpdate()
|
|
{
|
|
if (string.IsNullOrEmpty(SystemInfo.Instance.MesUpdateAddress))
|
|
{
|
|
//MessageUtil.Show(ResourceKeys.UpdateAddressIsNull);
|
|
return;
|
|
}
|
|
|
|
bool isUpdateSucess = false;
|
|
SystemInfo.Instance.MesUpdateAddress = "";
|
|
if (!string.IsNullOrEmpty(SystemInfo.Instance.MesUpdateAddress))
|
|
{
|
|
IAutoUpdater updater = new AutoUpdater(SystemInfo.Instance.MesUpdateAddress);
|
|
try
|
|
{
|
|
updater.Update();
|
|
isUpdateSucess = true;
|
|
}
|
|
catch (WebException ex)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ServerConnectionFault + "\r\n" + ex);
|
|
}
|
|
catch (XmlException ex)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DownLoadUpdateXmlFault + "\r\n" + ex);
|
|
}
|
|
catch (NotSupportedException ex)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UpdateXmlSettingFault + "\r\n" + ex);
|
|
}
|
|
catch (ArgumentException ex)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DownLoadUpdateFileFault + "\r\n" + ex);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UpdateError + "\r\n" + ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
}
|
|
finally
|
|
{
|
|
if (!isUpdateSucess)
|
|
{
|
|
try
|
|
{
|
|
updater.RollBack();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置delphi参数</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-03-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetDelphiDllParams()
|
|
{
|
|
try
|
|
{
|
|
StringBuilder sb1 = new StringBuilder();
|
|
sb1.Append(ERPInfo.Instance.UserName);
|
|
|
|
StringBuilder sb2 = new StringBuilder();
|
|
sb2.Append(ERPInfo.Instance.WindowName);
|
|
|
|
StringBuilder sb3 = new StringBuilder();
|
|
sb3.Append(ERPInfo.Instance.SkinName);
|
|
|
|
//给delphi库设置参数(用户id、子系统id、操作员名称、计算机名称)
|
|
DelphiHelper.Delphi_SetParams(Convert.ToInt32(ERPInfo.Instance.UserId), Convert.ToInt32(ERPInfo.Instance.SubSysId), sb1, sb2, sb3);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
LogHelper.Instance.WriteError(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:登陆</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void StartLogin()
|
|
{
|
|
try
|
|
{
|
|
string userCode = this.txtUserName.EditValue + "";
|
|
string userName = this.txtUserName.Text.Trim();
|
|
string password = this.txtPassword.Text.Trim();
|
|
|
|
DataTable table = MainImpl.GetEmployeeList();
|
|
DataRow[] drRows = table.Select("UserName='" + userName + "' or UserCode='" + userName + "'");
|
|
if ((drRows == null) || (drRows.Count() < 1))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.NameOrPasswordError);
|
|
return;
|
|
}
|
|
//找到多个操作员
|
|
if (drRows.Count() > 1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DuplicatedNameError);
|
|
return;
|
|
}
|
|
DataRow drRow = drRows[0];
|
|
//DataRow drRow = table.Rows.Cast<DataRow>().FirstOrDefault(x => userName.Equals(x["UserName"] + ""));
|
|
if (drRow != null)
|
|
{
|
|
userCode = drRow["userCode"] + "";
|
|
userName = drRow["UserName"] + "";
|
|
}
|
|
else
|
|
{
|
|
userCode = "";
|
|
}
|
|
if (string.IsNullOrWhiteSpace(userCode))
|
|
{
|
|
MessageUtil.Show(ResourceKeys.UserNotFound);
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(cbBZ.SelectedItem + ""))
|
|
{
|
|
MessageUtil.Show("请选择班次.");
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(userName))
|
|
{
|
|
this._txtUserName.Focus();
|
|
MessageUtil.Show(ResourceKeys.UserNameNotNull);
|
|
return;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(this.cbCJ.SelectedItem + ""))
|
|
{
|
|
MessageUtil.Show("当前用户未设置车间,请先设置.");
|
|
return;
|
|
}
|
|
|
|
// 检查Mac地址
|
|
if (SystemInfo.Instance.MacEnabled)
|
|
{
|
|
int result = MainImpl.CheckMacAddress(ERPInfo.Instance.MacAddress, userCode);
|
|
if (result == 0)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.LoginFault + ResourceKeys.UnKownMacAddress);
|
|
return;
|
|
}
|
|
if (result == -1)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.LoginFault + ResourceKeys.UnKownMacAddressTable);
|
|
return;
|
|
}
|
|
}
|
|
|
|
WaitForm.ShowForm(ResourceKeys.Logining);
|
|
|
|
int loginResult = MainImpl.MesLogin(userCode, password, true);
|
|
|
|
switch (loginResult)
|
|
{
|
|
case 0: // 登录成功
|
|
case 2:
|
|
DataRow rowItem = BaseImpl.GetDataRowResult(string.Format("select * from P_employeeTab where loginaccount='{0}'", userCode));
|
|
if (rowItem == null)
|
|
{
|
|
MessageUtil.Show("工号错误!");
|
|
return;
|
|
}
|
|
string userId = rowItem["employeeid"] + "";
|
|
// 登录成功后调用
|
|
string msg = string.Empty;
|
|
int result = LoginAfter(userId, out msg);
|
|
|
|
if (result == -1)
|
|
{
|
|
MessageUtil.Show(msg);
|
|
return;
|
|
}
|
|
|
|
string filepath = string.Empty;
|
|
string paramstr = string.Empty;
|
|
|
|
|
|
|
|
// 记录本地数据
|
|
IniHelper.Write(MesLoginConfig, "CJ", this.cbCJ.SelectedItem + "");
|
|
IniHelper.Write(MesLoginConfig, "JT", this.cbJT.SelectedItem + "");
|
|
IniHelper.Write(MesLoginConfig, "BZ", this.cbBZ.SelectedItem + "");
|
|
IniHelper.Write(MesLoginConfig, "UserName", userCode);
|
|
|
|
// 设置皮肤
|
|
DBConfig.Instance.BCName = cbBZ.SelectedItem + "";
|
|
DBConfig.Instance.NoticeUserID = userId;
|
|
DBConfig.Instance.NoticeUserName = userCode;
|
|
DBConfig.Instance.UpdateSet = true;
|
|
DBConfig.Instance.SmallClient = false;
|
|
DBConfig.Instance.DataBook = cbLedger.Text;
|
|
DBConfig.Instance.WriteConfig();
|
|
|
|
userName = rowItem["EmployeeName"] + "";
|
|
|
|
string skinName = MainImpl.GetUserSkin(userId);
|
|
skinName = string.IsNullOrEmpty(skinName) ? ERPInfo.Instance.SkinName : skinName;
|
|
UserLookAndFeel.Default.SetSkinStyle(skinName);
|
|
|
|
|
|
ERPInfo.Instance.UserId = userId;
|
|
ERPInfo.Instance.UserName = userName;
|
|
ERPInfo.Instance.Password = SHAHelper.EncryptPassword(password);
|
|
ERPInfo.Instance.SkinName = skinName;
|
|
ERPInfo.Instance.AccountBook = cbLedger.Text;
|
|
|
|
|
|
DataRow workItem = this.mWorkTable.Rows.Cast<DataRow>().FirstOrDefault(x => (this.cbCJ.SelectedItem + "").Equals(x["mc"] + ""));
|
|
if (workItem != null)
|
|
{
|
|
ERPInfo.Instance.WorkModid = workItem["dllcoid"] + "";
|
|
ERPInfo.Instance.WorkNo = workItem["no"] + "";
|
|
}
|
|
|
|
ERPInfo.Instance.WorkCJ = this.cbCJ.SelectedItem + "";
|
|
ERPInfo.Instance.WorkJT = this.cbJT.SelectedItem + "";
|
|
ERPInfo.Instance.WorkBZ = this.cbBZ.SelectedItem + "";
|
|
DataRow[] CJRows = this.mWorkTable.Select(string.Format("mc = '{0}'", this.cbCJ.SelectedItem + ""));
|
|
DataRow[] JTRows = this.mJTTable.Select(string.Format("mc = '{0}'", this.cbJT.SelectedItem + ""));
|
|
DataRow[] BZRows = this.mBZTable.Select(string.Format("mc = '{0}'", this.cbBZ.SelectedItem + ""));
|
|
ERPInfo.Instance.WorkCJId = CJRows != null & CJRows.Length > 0 ? CJRows[0]["dm"] + "" : "";
|
|
ERPInfo.Instance.WorkJTId = JTRows != null & JTRows.Length > 0 ? JTRows[0]["dm"] + "" : "";
|
|
ERPInfo.Instance.WorkBZId = BZRows != null & BZRows.Length > 0 ? BZRows[0]["dm"] + "" : "";
|
|
this.SetDelphiDllParams(); // 设置调用delphi参数
|
|
if (!string.IsNullOrEmpty(msg))
|
|
{
|
|
// 返回Msg值:tipmsg=我是提示信息;filepath=ccc.lsp;params=daskd
|
|
string[] msgs = msg.Split(';');
|
|
if (msgs != null && msgs.Length > 2)
|
|
{
|
|
msg = msgs[0].Replace("tipmsg=", "");
|
|
filepath = msgs[1].Replace("filepath=", "");
|
|
paramstr = msgs[2].Replace("params=", "");
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(msg))
|
|
MessageUtil.Show(msg);
|
|
if (filepath.Contains(".dll"))
|
|
{
|
|
|
|
GetMsgParamters(paramstr);
|
|
}
|
|
if (filepath.Contains(".lsp"))
|
|
{
|
|
DelphiHelper.LoadDelphiDll(PubUtil.AbsolutelyLibPath + filepath, "", "", paramstr, "", 0, "");
|
|
}
|
|
}
|
|
bool isStartMain = true;
|
|
|
|
if (isStartMain)
|
|
{
|
|
// 检查自动升级
|
|
WaitForm.ShowForm(ResourceKeys.AutoUpdating);
|
|
this.StartAutoUpdate();//暂时屏蔽自动更新
|
|
|
|
//// 启动小平台
|
|
//if (chkClient.Checked)
|
|
//{
|
|
// this.StartSmallClient();
|
|
//}
|
|
this.DialogResult = DialogResult.OK;
|
|
this.Close();
|
|
}
|
|
break;
|
|
case 1: // 密码不正确
|
|
MessageUtil.Show(ResourceKeys.NameOrPasswordError);
|
|
break;
|
|
//case 2: // 已有此用户登录
|
|
// MessageUtil.Show(ResourceKeys.AlreadyLogin);
|
|
// break;
|
|
case -1: // 登录失败
|
|
default:
|
|
MessageUtil.Show(ResourceKeys.LoginFault);
|
|
break;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogUtil.WriteError("登录出错!", ex);
|
|
//MessageUtil.Show("登录出错!" + ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:调用弹出dll</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-14 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void GetMsgParamters(string msgs)
|
|
{
|
|
if (msgs.Contains("module="))
|
|
{
|
|
string[] paramters = msgs.Split('=');
|
|
if (paramters.Length != 2)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ProcNameSettingFault);
|
|
return;
|
|
}
|
|
string[] defaultParams = paramters[1].Split('^');
|
|
if (defaultParams.Length < 4)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.ExcuteMoudleFail);
|
|
return;
|
|
}
|
|
string dllName = defaultParams[1];
|
|
string moduleTitle = defaultParams[2];
|
|
string saveState = defaultParams[3];
|
|
if ("lskj.pubadd3.dll".Equals(dllName) || "lskj.pubadd2.dll".Equals(dllName) || "lskj.pubadd4.dll".Equals(dllName))
|
|
dllName = "Lskj.PubAdd.dll";
|
|
|
|
List<string> paramList = new List<string>();
|
|
for (int i = 4; i < 14; i++)
|
|
{
|
|
paramList.Add(defaultParams.Length > i ? defaultParams[i] : "");
|
|
}
|
|
//执行dll
|
|
string[] str = {
|
|
moduleTitle,
|
|
ERPInfo.Instance.UserId,
|
|
ERPInfo.Instance.UserName,
|
|
"1",
|
|
ERPInfo.Instance.WorkModid,
|
|
paramList[0],
|
|
paramList[1],
|
|
paramList[2],
|
|
paramList[3],
|
|
paramList[4],
|
|
paramList[5],
|
|
paramList[6],
|
|
paramList[7],
|
|
paramList[8],
|
|
paramList[9],
|
|
"",
|
|
"",
|
|
saveState
|
|
};
|
|
IForm form = FormHelper.LoadDllForm(dllName, str);
|
|
if (form == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DyncmicDllNotFount);
|
|
return;
|
|
}
|
|
if (form.SubForm == null)
|
|
{
|
|
MessageUtil.Show(ResourceKeys.DyncmicDllInitFault);
|
|
return;
|
|
}
|
|
form.SubForm.WindowState = FormWindowState.Normal;
|
|
form.SubForm.StartPosition = FormStartPosition.CenterScreen;
|
|
form.SubForm.Text = moduleTitle;
|
|
DialogResult dr = form.SubForm.ShowDialog();
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取本地资源文件
|
|
/// </summary>
|
|
/// <param name="mapEnum"></param>
|
|
/// <returns></returns>
|
|
public static Bitmap getBitmap()
|
|
{
|
|
Bitmap bitmap = null;
|
|
try
|
|
{
|
|
FileStream fs = File.OpenRead(PubUtil.BitMapPath + Logobg); //OpenRead
|
|
int filelength = (int)fs.Length; //获得文件长度
|
|
Byte[] image = new Byte[filelength]; //建立一个字节数组
|
|
fs.Read(image, 0, filelength); //按字节流读取
|
|
Image result = Image.FromStream(fs);
|
|
fs.Close();
|
|
bitmap = new Bitmap(result);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
bitmap = Lskj.BsMes.Properties.Resources.bkImag;
|
|
}
|
|
return bitmap;
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:设置系统用户</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2020-04-13 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
private void SetUsers()
|
|
{
|
|
BaseImpl.HasExistsColumn("P_SystemTab", "LoginPopupFlag", "int");
|
|
// 设置登录用户信息
|
|
_userTable = MainImpl.GetEmployeeList();
|
|
|
|
|
|
txtUserName.ValueField = txtUserName.ValueMember = "UserCode";
|
|
txtUserName.TextMember = "UserName";
|
|
txtUserName.SourceSQL = "select EmployeeId UserId,LoginAccount UserCode,EmployeeName UserName from P_EmployeeTab WHERE sign=0 and UseFlag=1";
|
|
|
|
txtUserName.DataSource = _userTable;
|
|
txtUserName.AutoShowPopup = "1".Equals(BaseImpl.GetResult("SELECT LoginPopupFlag FROM P_SystemTab") + "");
|
|
|
|
|
|
DataRow[] rowItems = _userTable.Select(" UserCode = '" + IniHelper.Read(MesLoginConfig, "UserName") + "'");
|
|
if (rowItems != null && rowItems.Length > 0)
|
|
{
|
|
txtUserName.EditValue = rowItems[0][txtUserName.ValueField] + "";
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:服务器设置</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnSettingClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
FrmConfig config = new FrmConfig();
|
|
DialogResult result = config.ShowDialog();
|
|
if (result == DialogResult.OK)
|
|
{
|
|
SystemInfo.RefreshSystemParam();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageUtil.Show(ex);
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:登陆</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnLoginClick(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
this.StartLogin();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:键盘按下</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2018-11-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The sender.</param>
|
|
/// <param name="e">The <see cref="KeyEventArgs"/> instance containing the event data.</param>
|
|
private void OnPasswordKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (e.KeyCode == Keys.Enter)
|
|
{
|
|
this.StartLogin();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:失去焦点获取车间</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2019-07-29 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
|
|
private void OnTxtUserNameLostFocus(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
string userCode = this.txtUserName.EditValue + "";
|
|
string userName = this.txtUserName.Text.Trim();
|
|
if (!string.IsNullOrEmpty(userCode))
|
|
{
|
|
DataRow rowItem = BaseImpl.GetDataRowResult(string.Format("select * from P_employeeTab where loginaccount='{0}'", userCode));
|
|
string userId = rowItem["employeeid"] + "";
|
|
DataTable Logindt = SqlHelper.ExecuteDataTable(string.Format(" exec {0} {1},'{2}' ", MesUserInputBefore, userId, userName));
|
|
DataRow LoginRow = Logindt.Rows.Count > 0 ? Logindt.Rows[0] : null;
|
|
ERPInfo.Instance.ClassName = string.Empty;
|
|
if (LoginRow == null) return;
|
|
this.cbCJ.SelectedItem = LoginRow["mes_ws_Name"] + "";
|
|
this.cbJT.SelectedItem = LoginRow["JtName"] + "";
|
|
this.cbBZ.SelectedItem = LoginRow["ClassBc"] + "";
|
|
ERPInfo.Instance.ClassName = LoginRow["ClassName"] + "";
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
}
|
|
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
public int LoginAfter(string opertaorid, out string tipMsg)
|
|
{
|
|
try
|
|
{
|
|
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
|
|
pMsg.Direction = ParameterDirection.Output;
|
|
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
|
|
returnValue.Direction = ParameterDirection.ReturnValue;
|
|
SqlParameter[] param =
|
|
{
|
|
new SqlParameter("@operatorid",SqlDbType.VarChar),
|
|
new SqlParameter("@TypeID ",SqlDbType.Int),
|
|
pMsg,
|
|
returnValue
|
|
};
|
|
param[0].Value = opertaorid;
|
|
param[1].Value = cbBZ.SelectedIndex;
|
|
|
|
SqlHelper.ExecuteDataSet(CommandType.StoredProcedure, "P_Login_AfterPr", "P_Login_AfterPr", param);
|
|
tipMsg = pMsg.Value + "";
|
|
|
|
return Convert.ToInt32(returnValue.Value + "");
|
|
}
|
|
catch (Exception)
|
|
{
|
|
tipMsg = "";
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
private void cbCJ_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
SetJT();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 机台值改变时改变操作人
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void JTSelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
DevExpress.XtraEditors.ComboBoxEdit comboBox = sender as DevExpress.XtraEditors.ComboBoxEdit;
|
|
DataRow comRow = MainImpl.JTGetStaff(comboBox.SelectedItem + "");
|
|
if (comRow != null && comRow.Table.Columns.Contains("JzName"))
|
|
{
|
|
DataRow[] rowItems = _userTable.Select(" UserName = '" + comRow["JzName"] + "'");
|
|
if (rowItems != null && rowItems.Length > 0)
|
|
{
|
|
//txtUserName.EditValue = rowItems[0][txtUserName.ValueField] + "";
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
string Message = ErrorMessage.PromptErrorMessage(ex);
|
|
MessageUtil.Show(Message, ex.Message);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 拖拽移动窗体事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void OnImageCarouseBox_MouseDown(object sender, MouseEventArgs e)
|
|
{
|
|
point = e.Location;
|
|
}
|
|
private void OnImageCarouseBox_MouseUp(object sender, MouseEventArgs e)
|
|
{
|
|
point = e.Location;
|
|
}
|
|
private void OnImageCarouseBox_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
if (e.Button == System.Windows.Forms.MouseButtons.Left)
|
|
this.Location = new Point(this.Left + (e.X - point.X), this.Top + (e.Y - point.Y));
|
|
}
|
|
#endregion
|
|
}
|
|
}
|