ab56a9bcf7
SVN-Revision: r240
190 lines
6.5 KiB
C#
190 lines
6.5 KiB
C#
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 System.Runtime.InteropServices;
|
|
using testUI;
|
|
using Microsoft.Win32;
|
|
using Lskj.Model;
|
|
using Lskj.Util;
|
|
using Lskj.Core;
|
|
|
|
namespace CallDelphi
|
|
{
|
|
|
|
|
|
public partial class frmCall : Form
|
|
{
|
|
public string operatorid { get; set; }
|
|
public string operatorname {get;set;}
|
|
public string servername { get; set; }
|
|
public string dbname { get; set; }
|
|
public frmCall()
|
|
{
|
|
InitializeComponent();
|
|
|
|
}
|
|
|
|
private StringBuilder libKey = new StringBuilder("");
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
const int WM_COPYDATA = 0x004a;
|
|
|
|
|
|
if (m.Msg == WM_COPYDATA)
|
|
{
|
|
COPYDATASTRUCT mystr = new COPYDATASTRUCT();
|
|
Type mytype = mystr.GetType();
|
|
mystr = (COPYDATASTRUCT)m.GetLParam(mytype);
|
|
String rltstr = (mystr.lpData + "").TrimEnd('^');
|
|
richTextBox1.Text = rltstr;
|
|
|
|
List<String> lst = rltstr.Split('^').ToList();
|
|
String dllFile = lst[0];
|
|
IntPtr mainHandle = new IntPtr(Convert.ToInt32(lst[1]));
|
|
lst.RemoveAt(0);
|
|
lst.RemoveAt(0);
|
|
String[] args = lst.ToArray();
|
|
SqlHelper._connection = new System.Data.SqlClient.SqlConnection(GetConStr());
|
|
SqlHelper._connection.Open();
|
|
|
|
int loperid = Int32.Parse(args[1]);
|
|
StringBuilder loper = new StringBuilder(args[2]);
|
|
StringBuilder lwsname = new StringBuilder("");
|
|
StringBuilder skin = new StringBuilder("");
|
|
DelphiHelper.Delphi_SetParams(loperid, 1, loper, lwsname, skin);
|
|
//MessageBox.Show(lst.Count + "");
|
|
//MessageBox.Show(rltstr);
|
|
ERPInfo.Instance.GroupId = lst[lst.Count - 1];
|
|
|
|
IForm ifrm = FormHelper.LoadDllForm(dllFile, args);
|
|
ifrm.SubForm.WindowState = FormWindowState.Maximized;
|
|
//ifrm.SubForm.Show();
|
|
ifrm.SubForm.ShowDialog();
|
|
ifrm.SubForm.Dispose();
|
|
}
|
|
else
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
}
|
|
|
|
private void frmCall_Shown(object sender, EventArgs e)
|
|
{
|
|
this.Hide();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
int ret = DelphiHelper.LoadDelphiDll("p_Basedate.lsp");
|
|
MessageBox.Show(libKey.ToString());
|
|
String[] lbk = libKey.ToString().Split('@');
|
|
if (lbk.Count() <= 0) {
|
|
return;
|
|
}
|
|
IntPtr hChild = new IntPtr(Convert.ToInt32( lbk[1] ));
|
|
FormModule fm = new FormModule();
|
|
DelphiHelper.SetParent(hChild, fm.Handle);
|
|
DelphiHelper.SetWindowPos(hChild, 0, 0, 0, fm.Width, fm.Height, 0);
|
|
fm.Show();
|
|
}
|
|
|
|
public string GetDelphiConStr()
|
|
{
|
|
string host = GetRegistData("ServerName");
|
|
string db = GetRegistData("datastr");
|
|
string connectionStr = string.Format("Provider=SQLOLEDB.1;Server={0};Database={1};Persist Security Info=True;User ID=wlms;Password=mymsserver", host, db);
|
|
return connectionStr;
|
|
}
|
|
|
|
|
|
public string GetConStr()
|
|
{
|
|
//string host = servername;
|
|
//string db = dbname;
|
|
//if (string.IsNullOrEmpty(servername)||string.IsNullOrEmpty(dbname))
|
|
//{
|
|
string host = GetRegistData("ServerName");
|
|
string db = GetRegistData("datastr");
|
|
//};
|
|
string connectionStr = string.Format("Server={0};Database={1};Persist Security Info=True;User ID=lserpAdmin;Password=lserp110", host, db);
|
|
//string strSql = string.Format("Provider=SQLOLEDB.1;Password=lserp110;Persist Security Info=True;User ID=lserpAdmin;Initial Catalog=lsErp;Data Source=JINJIN;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=JINJIN;Use Encryption for Data=False;Tag with column collation when possible=False");
|
|
return connectionStr;
|
|
}
|
|
private void frmCall_Load(object sender, EventArgs e)
|
|
{
|
|
StringBuilder sb = new StringBuilder(GetDelphiConStr());
|
|
DelphiHelper.Delphi_Init(sb);
|
|
StringBuilder loper = new StringBuilder(operatorname);
|
|
StringBuilder lwsname = new StringBuilder("");
|
|
StringBuilder skin = new StringBuilder("");
|
|
DelphiHelper.Delphi_SetParams(Int32.Parse(operatorid), 1, loper, lwsname, skin);
|
|
|
|
|
|
}
|
|
|
|
private void frmCall_FormClosed(object sender, FormClosedEventArgs e)
|
|
{
|
|
//PubUtil.Delphi_UnInit();
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
DelphiHelper.FreeDll(libKey);
|
|
}
|
|
|
|
private static string GetRegistData(string name)
|
|
{
|
|
string registData;
|
|
RegistryKey hkml = Registry.CurrentUser;
|
|
RegistryKey software = hkml.OpenSubKey("AA_LS_Erp V2.0", true);
|
|
if (software == null)
|
|
{
|
|
return "";
|
|
}
|
|
RegistryKey aimdir = software.OpenSubKey("File", true);
|
|
if (aimdir == null)
|
|
{
|
|
return "";
|
|
}
|
|
registData = aimdir.GetValue(name).ToString();
|
|
if (registData == null)
|
|
{
|
|
return "";
|
|
}
|
|
return registData;
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
string rltstr = richTextBox1.Text;
|
|
if (rltstr.Trim() == "")
|
|
return;
|
|
List<String> lst = rltstr.Split('^').ToList();
|
|
String dllFile = lst[0];
|
|
IntPtr mainHandle = new IntPtr(Convert.ToInt32(lst[1]));
|
|
lst.RemoveAt(0);
|
|
lst.RemoveAt(0);
|
|
String[] args = lst.ToArray();
|
|
MessageBox.Show(Convert.ToString( args.Length));
|
|
IForm ifrm = FormHelper.LoadDllForm(dllFile, args);
|
|
MessageBox.Show("OK");
|
|
ifrm.SubForm.Show();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public struct COPYDATASTRUCT
|
|
{
|
|
public IntPtr dwData;
|
|
public int cbData;
|
|
[MarshalAs(UnmanagedType.LPStr)]
|
|
public String lpData;
|
|
}
|
|
}
|