176 lines
5.7 KiB
C#
176 lines
5.7 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using EAS.Services;
|
||
using SOH.Entities;
|
||
using SOH.Data;
|
||
namespace SOH.BLL
|
||
{
|
||
[ServiceObject("人员管理模块")]
|
||
[ServiceBind(typeof(It_czygl))]
|
||
public class t_czyglBll : It_czygl
|
||
{
|
||
public t_czygl Login(string username, string userpass, int fd)
|
||
{
|
||
//throw new NotImplementedException();
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
int fd1 = Convert.ToInt32(fd);
|
||
var data = from t in db.t_czygls
|
||
where t.czym == username && t.zhuxiao == 0 && t.czymm == userpass
|
||
select t;
|
||
t_czygl czymodel = null;
|
||
if (data.Any())
|
||
{
|
||
czymodel = data.First();
|
||
if (czymodel.yonggong.yydm == fd1) return czymodel; else return null;
|
||
}
|
||
return czymodel;
|
||
}
|
||
}
|
||
|
||
public t_czygl Login2(string username, int fd)
|
||
{
|
||
//throw new NotImplementedException();
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
int fd1 = Convert.ToInt32(fd);
|
||
var data = from t in db.t_czygls
|
||
where t.czym == username && t.zhuxiao == 0
|
||
select t;
|
||
t_czygl czymodel = null;
|
||
if (data.Any())
|
||
{
|
||
czymodel = data.First();
|
||
if (czymodel.yonggong.yydm == fd1) return czymodel; else return null;
|
||
}
|
||
return czymodel;
|
||
}
|
||
}
|
||
|
||
public List<t_czygl> GetList()
|
||
{
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
return db.t_czygls.ToList();
|
||
}
|
||
|
||
}
|
||
public OperationResult UpdatePass(string username, string oldpass, string newpass)
|
||
{
|
||
OperationResult or = new OperationResult();
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
var data = from t in db.t_czygls
|
||
where t.czym == username && t.czymm == oldpass
|
||
select t;
|
||
if (data.Any())
|
||
{
|
||
t_czygl gl = data.ToList()[0];
|
||
gl.czymm = newpass;
|
||
db.t_czygls.OrmAccessor.Update(gl);
|
||
or.State = 2;//修改成功!
|
||
}
|
||
else
|
||
{
|
||
or.State = 1;//1:老密码输入错误!
|
||
}
|
||
}
|
||
return or;
|
||
}
|
||
|
||
|
||
public List<t_czygl> GetczyglBybm(short bm)
|
||
{
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
return db.t_czygls.Where(t => t.ygbm == bm).ToList();
|
||
}
|
||
}
|
||
|
||
|
||
public OperationResult SuperUpdatePass(short bm, string newpass, string username)
|
||
{
|
||
OperationResult or = new OperationResult();
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
var data = from t in db.t_czygls
|
||
where t.czym == username && t.ygbm == bm
|
||
select t;
|
||
if (data.Any())
|
||
{
|
||
t_czygl g = data.ToList()[0];
|
||
g.czymm = newpass;
|
||
db.t_czygls.OrmAccessor.Update(g);
|
||
or.State = 2;//修改成功!
|
||
}
|
||
}
|
||
return or;
|
||
}
|
||
|
||
public OperationResult SuperUpdatePass2(short bm, string newpass, string username, byte[] buffByte)
|
||
{
|
||
OperationResult or = new OperationResult();
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
var data = from t in db.t_czygls
|
||
where t.czym == username && t.ygbm == bm
|
||
select t;
|
||
if (data.Any())
|
||
{
|
||
t_czygl g = data.ToList()[0];
|
||
g.czymm = newpass;
|
||
g.image = buffByte;
|
||
db.t_czygls.OrmAccessor.Update(g);
|
||
or.State = 2;//修改成功!
|
||
}
|
||
}
|
||
return or;
|
||
}
|
||
|
||
public OperationResult SuperUpdateImage1(short bm, string newpass, string username, byte[] buffByte)
|
||
{
|
||
OperationResult or = new OperationResult();
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
var data = from t in db.t_czygls
|
||
where t.czym == username && t.ygbm == bm
|
||
select t;
|
||
if (data.Any())
|
||
{
|
||
t_czygl g = data.ToList()[0];
|
||
g.image1 = buffByte;
|
||
db.t_czygls.OrmAccessor.Update(g);
|
||
or.State = 2;//修改成功!
|
||
}
|
||
}
|
||
return or;
|
||
}
|
||
|
||
public OperationResult Insert(t_czygl czy)
|
||
{
|
||
OperationResult or = new OperationResult();
|
||
using (DbEntities db = new DbEntities())
|
||
{
|
||
var data = from t in db.t_czygls
|
||
where t.czym == czy.czym
|
||
select t;
|
||
if (data.Any())
|
||
{
|
||
or.State = 2;//用户名占用;
|
||
or.Message = "账号已存在";
|
||
}
|
||
else
|
||
{
|
||
db.t_czygls.OrmAccessor.Insert(czy);
|
||
or.State = 1;
|
||
or.Message = "添加成功";
|
||
}
|
||
}
|
||
return or;
|
||
}
|
||
|
||
}
|
||
}
|