54 lines
1.1 KiB
C#
54 lines
1.1 KiB
C#
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
|
|
{
|
|
public readonly string[] FormsName = new string[]
|
|
{
|
|
"Договора","Документы","Извещения",
|
|
"Поставки","Изделия","Заказчики",
|
|
"Настройки"
|
|
};
|
|
private string user = "";
|
|
private string password = "";
|
|
public DB.User Usr { get; set; }
|
|
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;
|
|
if (res)
|
|
Usr = usr[0];
|
|
}
|
|
return res;
|
|
}
|
|
}
|
|
}
|