Merge branch 'master' of http://192.168.0.12:13000/sc/formula_manage
This commit is contained in:
commit
a25f599430
5 files changed
+125
-73
No files matched your search
+35
-28
@@ -14,6 +14,7 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
namespace formula_manage
|
namespace formula_manage
|
||||||
{
|
{
|
||||||
@@ -22,35 +23,12 @@ namespace formula_manage
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Login : Window
|
public partial class Login : Window
|
||||||
{
|
{
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
|
||||||
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
|
|
||||||
public static void PressKey(Keys key, bool up)
|
|
||||||
{
|
|
||||||
const int KEYEVENTF_EXTENDEDKEY = 0x1;
|
|
||||||
const int KEYEVENTF_KEYUP = 0x2;
|
|
||||||
if (up)
|
|
||||||
{
|
|
||||||
keybd_event((byte)key, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
keybd_event((byte)key, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Login()
|
public Login()
|
||||||
{
|
{
|
||||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
|
|
||||||
{
|
|
||||||
Regex re = new Regex("^[1-9]+[0-9]*$");
|
|
||||||
|
|
||||||
e.Handled = !re.IsMatch(e.Text);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e) //退出按钮事件
|
private void Button_Click(object sender, RoutedEventArgs e) //退出按钮事件
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
@@ -71,20 +49,49 @@ namespace formula_manage
|
|||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchBox_OnKeyDownd(object sender, System.Windows.Input.KeyEventArgs e)
|
private void SearchBox_OnKeyDownd(object sender, System.Windows.Input.KeyEventArgs e) //回车跳转功能
|
||||||
{
|
{
|
||||||
if (e.Key == Key.Enter)
|
if (e.Key == Key.Enter)
|
||||||
{
|
{
|
||||||
//SendKeys.SendWait("{Tab}");
|
//SendKeys.SendWait("{Tab}");
|
||||||
PressKey(Keys.Tab, false);
|
UserClass.PressKey.PressKeys(Keys.Tab, false);
|
||||||
PressKey(Keys.Tab, true);
|
UserClass.PressKey.PressKeys(Keys.Tab, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini";
|
||||||
|
|
||||||
|
|
||||||
|
string TEXT_SQLIP;
|
||||||
|
string TEXT_SQLNAME;
|
||||||
|
string TEXT_SQMOD;
|
||||||
|
string TEXT_SQLUSER;
|
||||||
|
string TEXT_SQLPASWOR;
|
||||||
|
string Connstr_SC;
|
||||||
|
int i;
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
PressKey(Keys.Tab, false);
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
|
||||||
PressKey(Keys.Tab, true);
|
TEXT_SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
||||||
|
TEXT_SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2");
|
||||||
|
TEXT_SQMOD = Configini.IniReadvalue("SQL_SERVER", "SQL3");
|
||||||
|
TEXT_SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4");
|
||||||
|
TEXT_SQLPASWOR = Configini.IniReadvalue("SQL_SERVER", "SQL5");
|
||||||
|
int.TryParse(Configini.IniReadvalue("SQL_SERVER", "SQL3"), out i); //读数据库状态配置文件
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";Trusted_Connection=SSPI";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";User ID=" + TEXT_SQLUSER + ";Password=" + TEXT_SQLPASWOR;
|
||||||
|
}
|
||||||
|
SqlConnection conn_DBC = new SqlConnection(Connstr_SC);
|
||||||
|
conn_DBC.Open();
|
||||||
|
conn_DBC.Close();
|
||||||
|
|
||||||
|
UserClass.PressKey.PressKeys(Keys.Tab, false);
|
||||||
|
UserClass.PressKey.PressKeys(Keys.Tab, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace formula_manage.UserClass
|
||||||
|
{
|
||||||
|
internal class IniFile
|
||||||
|
{
|
||||||
|
public class IniFiles
|
||||||
|
{
|
||||||
|
public string path;
|
||||||
|
[DllImport("kernel32")] //返回0表示失败,非0为成功
|
||||||
|
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
|
||||||
|
[DllImport("kernel32")] //返回取得字符串缓冲区的长度
|
||||||
|
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
|
||||||
|
/// <summary>
|
||||||
|
/// 保存ini文件的路径
|
||||||
|
/// 调用示例:var ini = IniFiles("C:\file.ini");
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="INIPath"></param>
|
||||||
|
public IniFiles(string iniPath)
|
||||||
|
{
|
||||||
|
this.path = iniPath;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 写Ini文件
|
||||||
|
/// 调用示例:ini.IniWritevalue("Server","name","localhost");
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section">[缓冲区]</param>
|
||||||
|
/// <param name="Key">键</param>
|
||||||
|
/// <param name="value">值</param>
|
||||||
|
public void IniWritevalue(string Section, string Key, string value)
|
||||||
|
{
|
||||||
|
WritePrivateProfileString(Section, Key, value, this.path);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 读Ini文件
|
||||||
|
/// 调用示例:ini.IniWritevalue("Server","name");
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Section">[缓冲区]</param>
|
||||||
|
/// <param name="Key">键</param>
|
||||||
|
/// <returns>值</returns>
|
||||||
|
public string IniReadvalue(string Section, string Key)
|
||||||
|
{
|
||||||
|
StringBuilder temp = new StringBuilder(255);
|
||||||
|
|
||||||
|
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
|
||||||
|
return temp.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace formula_manage.UserClass
|
||||||
|
{
|
||||||
|
internal class PressKey
|
||||||
|
{
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);
|
||||||
|
public static void PressKeys(Keys key, bool up)
|
||||||
|
{
|
||||||
|
const int KEYEVENTF_EXTENDEDKEY = 0x1;
|
||||||
|
const int KEYEVENTF_KEYUP = 0x2;
|
||||||
|
if (up)
|
||||||
|
{
|
||||||
|
keybd_event((byte)key, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
keybd_event((byte)key, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-45
@@ -17,6 +17,7 @@ using System.Runtime.InteropServices;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data.SqlTypes;
|
using System.Data.SqlTypes;
|
||||||
|
|
||||||
|
|
||||||
namespace formula_manage.Windows
|
namespace formula_manage.Windows
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -24,49 +25,6 @@ namespace formula_manage.Windows
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Sql : Window
|
public partial class Sql : Window
|
||||||
{
|
{
|
||||||
public class IniFiles
|
|
||||||
{
|
|
||||||
public string path;
|
|
||||||
[DllImport("kernel32")] //返回0表示失败,非0为成功
|
|
||||||
private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
|
|
||||||
[DllImport("kernel32")] //返回取得字符串缓冲区的长度
|
|
||||||
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
|
|
||||||
/// <summary>
|
|
||||||
/// 保存ini文件的路径
|
|
||||||
/// 调用示例:var ini = IniFiles("C:\file.ini");
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="INIPath"></param>
|
|
||||||
public IniFiles(string iniPath)
|
|
||||||
{
|
|
||||||
this.path = iniPath;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 写Ini文件
|
|
||||||
/// 调用示例:ini.IniWritevalue("Server","name","localhost");
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Section">[缓冲区]</param>
|
|
||||||
/// <param name="Key">键</param>
|
|
||||||
/// <param name="value">值</param>
|
|
||||||
public void IniWritevalue(string Section, string Key, string value)
|
|
||||||
{
|
|
||||||
WritePrivateProfileString(Section, Key, value, this.path);
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 读Ini文件
|
|
||||||
/// 调用示例:ini.IniWritevalue("Server","name");
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="Section">[缓冲区]</param>
|
|
||||||
/// <param name="Key">键</param>
|
|
||||||
/// <returns>值</returns>
|
|
||||||
public string IniReadvalue(string Section, string Key)
|
|
||||||
{
|
|
||||||
StringBuilder temp = new StringBuilder(255);
|
|
||||||
|
|
||||||
int i = GetPrivateProfileString(Section, Key, "", temp, 255, this.path);
|
|
||||||
return temp.ToString();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public Sql()
|
public Sql()
|
||||||
{
|
{
|
||||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
@@ -83,7 +41,7 @@ namespace formula_manage.Windows
|
|||||||
private void Window_SQL(object sender, RoutedEventArgs e)
|
private void Window_SQL(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
IniFiles Configini = new IniFiles(INIPath);
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
|
||||||
|
|
||||||
TEXT_SQLIP.Text = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
TEXT_SQLIP.Text = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
||||||
TEXT_SQLNAME.Text = Configini.IniReadvalue("SQL_SERVER", "SQL2");
|
TEXT_SQLNAME.Text = Configini.IniReadvalue("SQL_SERVER", "SQL2");
|
||||||
@@ -122,7 +80,7 @@ namespace formula_manage.Windows
|
|||||||
|
|
||||||
SQL2 = TEXT_SQLINK.IsChecked.GetValueOrDefault(); //数据库对象2是否生效
|
SQL2 = TEXT_SQLINK.IsChecked.GetValueOrDefault(); //数据库对象2是否生效
|
||||||
|
|
||||||
IniFiles Configini = new IniFiles(INIPath); //配置文件
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath); //配置文件
|
||||||
Configini.IniWritevalue("SQL_SERVER", "SQL1", TEXT_SQLIP.Text); //保存的配置
|
Configini.IniWritevalue("SQL_SERVER", "SQL1", TEXT_SQLIP.Text); //保存的配置
|
||||||
Configini.IniWritevalue("SQL_SERVER", "SQL2", TEXT_SQLNAME.Text);
|
Configini.IniWritevalue("SQL_SERVER", "SQL2", TEXT_SQLNAME.Text);
|
||||||
Configini.IniWritevalue("SQL_SERVER", "SQL3", SQL_MOD.ToString());
|
Configini.IniWritevalue("SQL_SERVER", "SQL3", SQL_MOD.ToString());
|
||||||
|
|||||||
@@ -80,6 +80,8 @@
|
|||||||
<Compile Include="Login.xaml.cs">
|
<Compile Include="Login.xaml.cs">
|
||||||
<DependentUpon>Login.xaml</DependentUpon>
|
<DependentUpon>Login.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="UserClass\IniFile.cs" />
|
||||||
|
<Compile Include="UserClass\PressKey.cs" />
|
||||||
<Compile Include="Windows\Sql.xaml.cs">
|
<Compile Include="Windows\Sql.xaml.cs">
|
||||||
<DependentUpon>Sql.xaml</DependentUpon>
|
<DependentUpon>Sql.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
Reference in new issue
Block a user