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.
107 lines
3.5 KiB
107 lines
3.5 KiB
using AMES_AP.Models;
|
|
using MaterialSkin.Controls;
|
|
using Newtonsoft.Json;
|
|
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 AMES_AP
|
|
{
|
|
|
|
public partial class Login : MaterialForm
|
|
{
|
|
public static int _userID;
|
|
public static string _User_Name;
|
|
public Login()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btnLogin_Click(object sender, EventArgs e)
|
|
{
|
|
if (txtUserName.Text == "" && txtPassword.Text == "")
|
|
{
|
|
MessageBox.Show("請輸入帳號或密碼");
|
|
}
|
|
else
|
|
{
|
|
|
|
var query = ApiHelper.GetMethod($"api/UserInfoes/ByUserNo/{txtUserName.Text}");
|
|
if (query == "error" || query == "無法連線WebAPI")
|
|
{
|
|
MessageBox.Show(query);
|
|
|
|
}
|
|
else
|
|
{
|
|
var barcodeInfos = JsonConvert.DeserializeObject<dynamic>(query);
|
|
if (barcodeInfos.loginPassword == txtPassword.Text)
|
|
{
|
|
if (cbxRemember.Checked)
|
|
{
|
|
_userID = barcodeInfos.userID;
|
|
_User_Name = barcodeInfos.userName;
|
|
Properties.Settings.Default.UserName = txtUserName.Text;
|
|
Properties.Settings.Default.Password = txtPassword.Text;
|
|
Properties.Settings.Default.CheckBox = cbxRemember.Checked;
|
|
Properties.Settings.Default.Save();
|
|
}
|
|
//StockControlForm stfrm = new StockControlForm();
|
|
//stfrm.Show();
|
|
Form1 form1 = new Form1();
|
|
form1.Show();
|
|
this.Hide();
|
|
|
|
}
|
|
else
|
|
{
|
|
lblErrorMessage.ForeColor = Color.Red;
|
|
|
|
lblErrorMessage.Text = "帳號或密碼錯誤!";
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//if (txtUserName.Text == "1" && txtPassword.Text == "1")
|
|
//{
|
|
// if (cbxRemember.Checked)
|
|
// {
|
|
// Properties.Settings.Default.UserName = txtUserName.Text;
|
|
// Properties.Settings.Default.Password = txtPassword.Text;
|
|
// Properties.Settings.Default.CheckBox = cbxRemember.Checked;
|
|
// Properties.Settings.Default.Save();
|
|
// }
|
|
// //StockControlForm stfrm = new StockControlForm();
|
|
// //stfrm.Show();
|
|
// Form1 form1 = new Form1();
|
|
// form1.Show();
|
|
// this.Hide();
|
|
//}
|
|
//else
|
|
//{
|
|
// //
|
|
// lblErrorMessage.ForeColor = Color.Red;
|
|
|
|
// lblErrorMessage.Text = "帳號或密碼錯誤!";
|
|
//}
|
|
}
|
|
}
|
|
|
|
private void Login_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
cbxRemember.Checked = Properties.Settings.Default.CheckBox;
|
|
txtUserName.Text = Properties.Settings.Default.UserName;
|
|
txtPassword.Text = Properties.Settings.Default.Password;
|
|
|
|
}
|
|
}
|
|
}
|
|
|