屠宰场客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.3 KiB

using BO.Utils;
using BWP.WinFormControl;
using Forks.JsonRpc.Client;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WeightClient
{
public partial class Login : Form
{
bool rpcFacadeInited = false;
void IniteRpcFacade()
{
if (rpcFacadeInited)
return;
if (string.IsNullOrEmpty(AppContext.Context.UrlConfig.ServerUrl))
throw new Exception("请先设置服务器地址");
RpcFacade.Init(AppContext.Context.UrlConfig.ServerUrl, "B3ButcherManageClient");
rpcFacadeInited = true;
}
public Login()
{
InitializeComponent();
userNameTxt.Text = AppContext.Context.UserConfig.UserName;
}
private void settingBtn_Click(object sender, EventArgs e)
{
var f = new SettingForm();
f.ShowDialog();
}
private async void loginBtn_Click(object sender, EventArgs e)
{
var username = userNameTxt.Text.Trim();
var pwd = pwdTxt.Text;
if (string.IsNullOrEmpty(username))
throw new Exception("请输入用户名");
IniteRpcFacade();
await Task.Factory.StartNew(() => RpcFacade.Login(username, pwd));
AppContext.Context.UserConfig.ID = 1;
AppContext.Context.UserConfig.UserName = username;
AppContext.Context.Save();
// var form = new ButcherOrderForm();
//form.Show();
Hide();
}
private void closeBtn_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void userNameTxt_Click(object sender, EventArgs e)
{
IniteRpcFacade();
var keyBoard = new NumberPad();
if (keyBoard.ShowDialog() == true)
{
string errorInfo;
userNameTxt.Text = LoginRpcUtil.GetUserNameByCode(keyBoard.Result, out errorInfo);
//if (string.IsNullOrEmpty(userNameTxt.Text))
// throw new Exception("工号输入错误");
if (!string.IsNullOrEmpty(errorInfo))
MessageBox.Show(errorInfo);
}
}
private void pwdTxt_Click(object sender, EventArgs e)
{
var keyBoard = new VirtualKeyPad();
if (keyBoard.ShowDialog() == true)
pwdTxt.Text = keyBoard.Result;
}
}
}