using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace PrintStock
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
}
private void Login_Load(object sender, EventArgs e)
{
this.Height = 180;
//通讯平台地址
ipBox1.Text = SetConfig.GetConfigString("", "ConnIP");
//通讯平台端口
txtPort.Text = SetConfig.GetConfigString("", "ConnPort");
}
/// <summary>
/// 打开配置 按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnSet_Click(object sender, EventArgs e)
{
if (this.Height == 180)
{
this.Height = 320;
btnSet.Text = "关闭配置";
}
else
{
this.Height = 180;
btnSet.Text = "打开配置";
}
}
/// <summary>
/// 登录按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnLogin_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(txtUserName.Text.Trim()))//判断操作员是否为空
{
if (!string.IsNullOrEmpty(txtPwd.Text.Trim()))//判断密码是否为空
{
//passWord用来接收从数据库中读取的加密过的密码
string passWord = TradeDAL.Stock.GetSQL_GetOperatorPwd(Convert.ToInt32(txtUserName.Text.Trim()));
//调用CallDll程序集中的方法进行判断此操作员系信息是否在数据库中记录
//MessageBox.Show("密码:"+passWord+"\n帐号:" + txtUserName.Text + "\n密码:" + txtPwd.Text + "\n返回结果:" + CallDll.Form1.CheckPassword1(short.Parse(txtUserName.Text.Trim()), txtPwd.Text.Trim(), passWord));
if (CallDll.Form1.CheckPassword1(short.Parse(txtUserName.Text.Trim()), txtPwd.Text.Trim(), passWord) == 100)
{
PrintStockList fo = new PrintStockList();
fo.Show();
this.Hide();
}
else
{
MessageBox.Show("密码错误!");
}
}
else
{
MessageBox.Show("请输入密码!");
}
}
else
{
MessageBox.Show("请输入操作员!");
}
}
/// <summary>
/// 取消按钮事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// 通讯平台端口 输入
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtPort_KeyPress(object sender, KeyPressEventArgs e)
{
Regex reg = new Regex(@"\d");//正则判断是数字
if (!reg.IsMatch(e.KeyChar.ToString()))//判断输入的是否匹配数字
e.Handled = true;
}
/// <summary>
/// 通讯平台地址输入完毕后
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ipBox1_Leave(object sender, EventArgs e)
{
SetConfig.SetConfigKeyValue("appSettings", "ConnIP", ipBox1.Text);
}
/// <summary>
/// 当在通讯平台端口输入完毕后
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void txtPort_Leave(object sender, EventArgs e)
{
SetConfig.SetConfigKeyValue("appSettings", "ConnPort", txtPort.Text);
}
//private byte[] GetDesSourceCode(int op_code, string password, char[] ret_code)
//{
//char[] original_data = new char[2048];
//char[] target_data = new char[2048];
//string szCmd = "";
//string source = "中华人民共和国中央人民广播电台";
//original_data = password.ToCharArray();
//long num = 0;
//for (int i = 0; i < password.Length; i++)
//{
// szCmd
//}
//}
}
}