2021-07-15 12:21:22 +05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Diplom_B.DB;
|
|
|
|
|
|
|
|
|
|
namespace Diplom_B
|
|
|
|
|
{
|
|
|
|
|
public class User
|
|
|
|
|
{
|
2021-07-17 22:32:53 +05:00
|
|
|
|
public readonly string[] FormsName = new string[]
|
|
|
|
|
{
|
|
|
|
|
"Договора","Документы","Извещения",
|
|
|
|
|
"Поставки","Изделия","Заказчики",
|
|
|
|
|
"Настройки"
|
|
|
|
|
};
|
2021-07-15 12:21:22 +05:00
|
|
|
|
private string user = "";
|
|
|
|
|
private string password = "";
|
2021-07-17 22:32:53 +05:00
|
|
|
|
public DB.User Usr { get; set; }
|
2021-07-15 12:21:22 +05:00
|
|
|
|
public User(string user, string password)
|
|
|
|
|
{
|
|
|
|
|
this.user = user;
|
|
|
|
|
this.password = password;
|
|
|
|
|
}
|
|
|
|
|
public bool CheckUser()
|
|
|
|
|
{
|
|
|
|
|
var res = false;
|
|
|
|
|
using (var db = new MainDB())
|
|
|
|
|
{
|
|
|
|
|
var usr = (from u in db.Users
|
|
|
|
|
where u.Name == user
|
|
|
|
|
select u).ToArray();
|
|
|
|
|
res = usr.Length == 1;
|
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
public bool Login()
|
|
|
|
|
{
|
|
|
|
|
var res = false;
|
|
|
|
|
using (var db = new MainDB())
|
|
|
|
|
{
|
|
|
|
|
var usr = (from u in db.Users
|
|
|
|
|
where u.Name == user && u.Pass == password
|
|
|
|
|
select u).ToArray();
|
|
|
|
|
res = usr.Length == 1;
|
2021-07-17 22:32:53 +05:00
|
|
|
|
if (res)
|
|
|
|
|
Usr = usr[0];
|
2021-07-15 12:21:22 +05:00
|
|
|
|
}
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|