init lserp cs 5.0

This commit is contained in:
cyf
2026-07-10 15:25:05 +08:00
commit 90f3fda86a
3799 changed files with 976868 additions and 0 deletions
@@ -0,0 +1,150 @@
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 CommonLib;
using System.Data.SqlClient;
using CommonLib.data;
using DevExpress.XtraEditors;
using Lskj.Main.main;
namespace Lskj.Main.App_Code
{
/// <summary>
/// 登录基类
/// </summary>
public partial class FrmLoginBase : FormBase
{
public bool pwdForceChange = false;
public FrmLoginBase()
{
InitializeComponent();
}
private void FrmLoginBase_Load(object sender, EventArgs e)
{
}
/// <summary>
/// 获取软件打开模式
/// </summary>
/// <returns></returns>
protected int GetSoftOpenMode()
{
object obj = SqlHelper.ExecuteScalar(CommandType.Text, "select SoftOpenMode from p_employeetab where EmployeeId=" + ERPInfo.Instance.EmployeeId);
if (obj != null)
{
int openMode = Convert.ToInt32(obj);
ERPInfo.Instance.SoftOpenMode = openMode;
return openMode;
}
return 0;
}
/// <summary>
/// 用户登录
/// </summary>
/// <param name="strEmployeeId"></param>
/// <param name="strPwd"></param>
/// <param name="strName"></param>
/// <returns></returns>
protected bool Login(string strEmployeeId, string strPwd, string strName, bool qzLogin)
{
if (strEmployeeId == string.Empty)
{
XtraMessageBox.Show("请输入用户名称!");
return false;
}
int EmployeeId = 0;
string sPwd = strPwd;
if (int.TryParse(strEmployeeId, out EmployeeId) == false)
{
XtraMessageBox.Show("操作人员数据错误请与管理员联系");
return false;
}
strPwd = PubUtil.EncryptPassword(strPwd);
try
{
if (EmployeeId == 0)
{
XtraMessageBox.Show("操作人员数据错误,请与管理员联系!");
return false;
}
//强制登陆
if (qzLogin)
{
string tmpsql = "delete from p_LoginHostInfotab where OperatorId=" + EmployeeId + "";
SqlHelper.ExecuteNonQuery(CommandType.Text, tmpsql);
}
SqlParameter[] cmdParams = new SqlParameter[]
{
new SqlParameter("@ReturnValue",SqlDbType.Int),
new SqlParameter("@operatorid",SqlDbType.Int),
new SqlParameter("@pwd",SqlDbType.VarChar,100)
};
cmdParams[0].Direction = ParameterDirection.ReturnValue;
cmdParams[1].Value = EmployeeId;
cmdParams[2].Value = strPwd;
SqlHelper.ExecuteNonQuery(CommandType.StoredProcedure, "P_Login_pr", cmdParams);
int iRet = int.Parse(cmdParams[0].Value.ToString());
switch (iRet)
{
case -1:
{
XtraMessageBox.Show("登录失败!");
break;
}
case 0:
{
ERPInfo.Instance.EmployeeName = strName;
ERPInfo.Instance.OperatorName = strName;
ERPInfo.Instance.EmployeeId = EmployeeId;
//设置delphi公用库参数
ERPInfo.Instance.SetDephiDllParams();
//检测密码为空则强制设置密码
if ((sPwd == "")&&(pwdForceChange))
{
FrmChangePwd frmPwd = new FrmChangePwd();
frmPwd.loginUser = strName;
frmPwd.loginId = EmployeeId;
DialogResult dr = frmPwd.ShowDialog();
if (dr != System.Windows.Forms.DialogResult.OK)
{
return false;
}
}
return true;
}
case 1:
{
XtraMessageBox.Show("密码不正确,请重新输入!");
break;
}
case 2:
{
XtraMessageBox.Show("已经有该用户登陆,请换用户登陆!");
break;
}
}
}
catch (Exception ex)
{
PubUtil.WriteError("登录失败", ex.Message);
XtraMessageBox.Show("登陆失败!");
}
return false;
}
}
}
@@ -0,0 +1,53 @@
namespace Lskj.Main.App_Code
{
partial class FrmLoginBase
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmLoginBase));
this.SuspendLayout();
//
// FrmLoginBase
//
this.Appearance.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.Appearance.Options.UseFont = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(284, 262);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.LookAndFeel.SkinName = "Office 2010 Blue";
this.LookAndFeel.Style = DevExpress.LookAndFeel.LookAndFeelStyle.Office2003;
this.Name = "FrmLoginBase";
this.Text = "FrmLoginBase";
this.Load += new System.EventHandler(this.FrmLoginBase_Load);
this.ResumeLayout(false);
}
#endregion
}
}
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,221 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommonLib;
using System.Windows.Forms;
using DevExpress.XtraTab;
using DevExpress.Utils;
using System.Runtime.InteropServices;
using CommonLib.utils;
namespace Lskj.Main
{
public class ModuleManager
{
#region C#DLL相关调用
/// <summary>
/// 添加到选项卡
/// </summary>
/// <param name="TabMain"></param>
/// <param name="module"></param>
/// <param name="args"></param>
/// <param name="IsShowClose"></param>
public static void AddModuleToTab(XtraTabControl TabMain, DllModule module, string[] obj, bool IsShowClose)
{
//if (PubUtil.ModuleForms.ContainsKey(module.Id))
//{
// foreach (XtraTabPage item in TabMain.TabPages)
// {
// string id = item.Tag + "";
// if (id == module.Id)
// {
// TabMain.SelectedTabPage = item;
// break;
// }
// }
//}
//else
//{
try
{
IForm iform = PubUtil.LoadDllForm(module.DllName, obj);
Form form = iform.SubForm;
module.ModuleForm = form;
string guid = Guid.NewGuid().ToString();
XtraTabPage tp = new XtraTabPage();
tp.Text = module.Name;
//tp.Tag = module.Id;
tp.Tag = guid;
form.FormBorderStyle = FormBorderStyle.None;
//这个必须有不然会提示:"不能向tabControl中添加顶级控件"
form.TopLevel = false;
form.Dock = DockStyle.Fill;
//这个必须有,不然显示不出来
tp.Controls.Add(form);
if (IsShowClose)
tp.ShowCloseButton = DefaultBoolean.True;
TabMain.TabPages.Add(tp);
TabMain.SelectedTabPage = tp;
module.Tag = "1";
form.Show();
PubUtil.ModuleForms.Add(guid, module);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
//}
}
/// <summary>
/// Show模式打开
/// </summary>
/// <param name="module">模块信息</param>
/// <param name="args">参数</param>
public static void AddModuleToShow(DllModule module, string[] args)
{
if (PubUtil.ModuleForms.ContainsKey(module.Id))
{
Form form = PubUtil.ModuleForms[module.Id].ModuleForm;
if (form == null)
return;
form.Text = module.Name;
form.WindowState = FormWindowState.Normal;
form.Activate();
form.BringToFront();
form.Focus();
form.Show();
}
else
{
IForm iform = PubUtil.LoadDllForm(module.DllName, args);
if (iform == null)
return;
Form form = iform.SubForm;
module.Tag = "1";
module.ModuleForm = form;
form.Show();
PubUtil.ModuleForms.Add(module.Id, module);
}
}
#endregion
#region Delphi相关调用
/// <summary>
/// Delphi-Show模式打开
/// </summary>
/// <param name="module"></param>
public static void AddModuleDelphiToShow(DllModule module)
{
if (PubUtil.ModuleForms.ContainsKey(module.Id))
{
Form iform = PubUtil.ModuleForms[module.Id].ModuleForm;
iform.Text = module.Name;
iform.Activate();
iform.BringToFront();
iform.Focus();
iform.Show();
}
else
{
// StringBuilder result = PubUtil.LoadDelphiDllEx(module.DllName);
// if (result.ToString().IndexOf('@') != -1)
// {
// string[] str = result.ToString().Split('@');
// module.ModuleInPtr = new IntPtr(Convert.ToInt32(str[1]));
// module.Result = result;
// FrmWindow frm = new FrmWindow();
// frm.Text = module.Name;
// frm.ModuleIntPtr = module.ModuleInPtr;
// PubUtil.SetParent(module.ModuleInPtr, frm.Handle);
// frm.DModule = module;
// module.ModuleForm = frm;
// frm.Show();
// PubUtil.SetWindowPos(module.ModuleInPtr, 0, 0, 0, frm.Width, frm.Height - 36, 0);
// PubUtil.ModuleForms.Add(module.Id, module);
// }
}
}
/// <summary>
/// Delphi-添加到选项卡
/// </summary>
/// <param name="TabMain"></param>
/// <param name="module"></param>
/// <param name="IsShowClose"></param>
public static void AddModuleDelphiToTab(XtraTabControl TabMain, DllModule module, bool IsShowClose)
{
try
{
if (PubUtil.ModuleForms.ContainsKey(module.Id))
{
foreach (XtraTabPage item in TabMain.TabPages)
{
string id = item.Tag.ToString();
if (id == module.Id)
{
TabMain.SelectedTabPage = item;
break;
}
}
}
else
{
XtraTabPage tp1 = TabMain.TabPages[0];
XtraTabPage tp2 = new XtraTabPage();
tp2.Text = module.Name;
tp2.Tag = module.Id;
//StringBuilder result = PubUtil.LoadDelphiDllEx(module.DllName);
//if (result.ToString().IndexOf('@') != -1)
//{
// string[] str = result.ToString().Split('@');
// module.ModuleInPtr = new IntPtr(Convert.ToInt32(str[1]));
// module.Result = result;
// module.Tag = "2";
// if (!string.IsNullOrEmpty(result + ""))
// {
// TabMain.TabPages.Add(tp2);
// PubUtil.SetParent(module.ModuleInPtr, tp2.Handle);
// PubUtil.SetWindowPos(module.ModuleInPtr, 0, 0, 0, tp1.Width, tp1.Height, 0);
// if (IsShowClose)
// tp2.ShowCloseButton = DefaultBoolean.True;
// TabMain.SelectedTabPage = tp2;
// PubUtil.ModuleForms.Add(module.Id, module);
// }
//}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
/// <summary>
/// 释放Delphi资源
/// </summary>
/// <param name="m"></param>
public static void FreeDll(DllModule m)
{
try
{
if (m != null)
{
PubUtil.FreeDll(m.Result);
m.ModuleForm = null;
PubUtil.ModuleForms.Remove(m.Id);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
#endregion
}
}
@@ -0,0 +1,83 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
using CommonLib;
namespace Lskj.Main
{
/// <summary>
/// 获取系统事件
/// </summary>
public class ServerTimer
{
private static DateTime m_CurTime = DateTime.Now;
private static Timer m_runTmr;
public static void StartTimer()
{
if (m_runTmr != null)
QueryTime();
m_runTmr = new Timer();
m_runTmr.Tag = 0;
m_runTmr.Tick += new EventHandler(OnTimer);
m_runTmr.Interval = 1000;
m_runTmr.Start();
}
public static DateTime ServerTime
{
get { return m_CurTime; }
}
private static void OnTimer(object sender, EventArgs e)
{
m_CurTime = m_CurTime.AddSeconds(1);
int count = (int)m_runTmr.Tag;
count++;
//暂定30秒查询一次
if (count > 30)
{
count = 0;
QueryTime();
}
m_runTmr.Tag = count;
}
/// <summary>
/// 查询服务器时间,并查询登录表记录,没记录则强制退出
/// </summary>
private static void QueryTime()
{
try
{
string strSql = string.Format("select getdate() as cnt from p_LoginHostInfotab where HostName='{0}'", ERPInfo.Instance.WSName);
using (SqlDataReader dr = SqlHelper.ExecuteReader(CommandType.Text, strSql, null))
{
if (dr.Read())
{
m_CurTime = DateTime.Parse(dr["cnt"].ToString());
}
else
{
//掉线
//MessageBox.Show("你已经被强制下线.");
//Application.Exit();
}
}
}
catch (Exception ex)
{
PubUtil.WriteLog(ex.Message);
}
}
}
}