public static List<Supplier> Getlist(string str, int intFalg, out int total) { using (BaseContext _db = new BaseContext()) { var query = new List<Supplier>(); switch (intFalg) { case 1: query = _db.a_Supplier.AsNoTracking(). Where(l => l.Name.Contains(str) || string.IsNullOrEmpty(str)).ToList(); break; case 2: query = _db.a_Supplier.AsNoTracking(). Where(l => l.Director.Contains(str) || string.IsNullOrEmpty(str)).ToList(); break; default: query = _db.a_Supplier.AsNoTracking().ToList(); break; } total = query.Count(); var list = query.ToList(); return list; } //供应商名称1//联系人2 }
public static List<Dic> Getlist(string str, int intFalg, out int total) { using (BaseContext _db = new BaseContext()) { var query = new List<Dic>(); switch (intFalg) { case 1: query = _db.a_Dic.AsNoTracking(). Where(l => l.KeyType == "商品单位").OrderBy(x => x.SortId).ToList(); break; case 2: query = _db.a_Dic.AsNoTracking().OrderBy(x => x.SortId).ToList(); break; case 3: query = _db.a_Dic.AsNoTracking().Where(l => l.KeyType == "商品品牌").OrderBy(x => x.SortId).ToList(); break; case 4: query = _db.a_Dic.AsNoTracking().Where(l => l.KeyType == "商品类别").OrderBy(x => x.SortId).ToList(); break; default: query = _db.a_Dic.AsNoTracking().Where(l=>l.KeyType == "商品单位").OrderBy(x=>x.SortId).ToList(); break; } total = query.Count(); var list = query.ToList(); return list; } //供应商名称1//联系人2 }
public static bool checkloginName(string name,int id=0) { using (BaseContext _db = new BaseContext()) { if (id == 0) { var query = _db.a_Supplier.AsNoTracking(). Where(l => l.Name.Contains(name)).FirstOrDefault(); if (query != null) { return true; } } else { var query = _db.a_Supplier.AsNoTracking(). Where(l => l.Name.Contains(name) && l.SupplierId != id).FirstOrDefault(); if (query != null) { return true; } } return false; } }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int add(Employee model) { var sql = string.Format(@"INSERT INTO [a_Emp]([EmpName],[Sex],[BirthDay],[DepId] ,[Phone],[Email],[Address],[Remark],[Pwd],[Role],[CreateTime],[UpdateTime],[RealName]) VALUES('{0}','{1}','{2}',{3},'{4}','{5}','{6}','{7}','{8}',{9},'{10}','{11}','{12}')", model.EmpName, model.Sex, model.BirthDay, model.DepId, model.Phone, model.Email, model.Address, model.Remark, model.Pwd, model.Role, model.CreateTime, model.UpdateTime, model.RealName); using (BaseContext db = new BaseContext()) { var result = db.Database.ExecuteSqlCommand(sql); return result; } }
public static List<Dept> getlist() { using (BaseContext _db = new BaseContext()) { var query = from s in _db.a_Dept.AsNoTracking() select s; var list = query.ToList(); return list; } }
public static List<Sales> Getlist() { using (BaseContext _db = new BaseContext()) { //获取销售记录 var query = _db.a_Sales.AsNoTracking(). Where(l =>l.Num > 0).ToList(); return query; } }
public static List<Ware> Getlist() { using (BaseContext _db = new BaseContext()) { var query = _db.a_Ware.AsNoTracking().ToList(); var list = query.ToList(); return list; } //供应商名称1//联系人2 }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool add(Sales model) { var sql = string.Format("insert into dbo.a_Sales values({0},'{1}',{2},{3},{4})", model.GoodsId, model.AddTime.ToString(), model.EmpId,model.Price, model.Num); using (BaseContext db = new BaseContext()) { var querylist = db.Database.ExecuteSqlCommand(sql); if (querylist > 0) { return true; } else { return false; } } }
public static bool checkloginName(string name) { using (BaseContext _db = new BaseContext()) { Employee query = _db.a_Emp.AsNoTracking(). Where(l => l.EmpName == name).FirstOrDefault(); if (query == null) { return false; } else { return true; } } }
public static bool checkloginName(string name,int goodid) { using (BaseContext _db = new BaseContext()) { Goods query = _db.a_Goods.AsNoTracking(). Where(l => l.GoodsName == name && (goodid==0 ||l.GoodsId != goodid)).FirstOrDefault(); if (query == null) { return false; } else { return true; } } }
/// <summary> /// 统计某商品销售数量 /// </summary> /// <param name="goodsId"></param> /// <returns></returns> public static int getSalesNums(int goodsId) { using (BaseContext _db = new BaseContext()) { try { //获取销售记录 var query = _db.a_Sales.AsNoTracking(). Where(l => l.GoodsId == goodsId).Sum(x => x.Num); return query; } catch (Exception) { return 0; } } }
public static List<Employee> Getlist(string str, int intFalg,out int total) { using (BaseContext _db = new BaseContext()) { var query= new List<Employee>(); switch (intFalg) { case 1: query = _db.a_Emp.AsNoTracking(). Where(l => l.RealName.Contains(str)||string.IsNullOrEmpty(str)).ToList(); break; case 2: query = _db.a_Emp.AsNoTracking(). Where(l => l.Sex.Contains(str) || string.IsNullOrEmpty(str)).ToList(); break; case 3: query = _db.a_Emp.AsNoTracking(). Where(l =>(l.DepId == 3)).ToList();//销售部 break; case 4: query = _db.a_Emp.AsNoTracking().Where(l =>(l.DepId == 2)).ToList();//采购部 break; case 5: query = _db.a_Emp.AsNoTracking().Where(l => (l.DepId == 1)).ToList();//管理部 break; default: query = _db.a_Emp.Include("Dept").AsNoTracking().ToList(); break; } total = query.Count(); var list = query.ToList(); return list; } //员工姓名1//员工性别2//员工所属部门3//员工职位4 }
public static List<Goods> Getlist(string str, int intFalg, out int total) { using (BaseContext _db = new BaseContext()) { var query = new List<Goods>(); try { switch (intFalg) { case 1: query = _db.a_Goods.AsNoTracking(). Where(l => l.GoodsName.Contains(str) || string.IsNullOrEmpty(str)).ToList(); break; case 2: query = _db.a_Goods.AsNoTracking(). Where(l => l.GoodsId.ToString().Contains(str) || string.IsNullOrEmpty(str)).ToList(); break; default: query = _db.a_Goods.AsNoTracking().ToList(); break; } } catch (Exception ex) { throw ex ; } total = query.Count(); var list = query.ToList(); return list; } //供应商名称1//联系人2 }
private static List<StcokQueryty> GetDatabySql(string sql) { using (BaseContext db = new BaseContext()) { var querylist = db.Database.SqlQuery<StcokQueryty>(sql).ToList(); return querylist; } }
public static List<Stockty> queryForList(string sql) { List<Stockty> list = null; using (BaseContext _db = new BaseContext()) { var result = _db.Database.SqlQuery<Stockty>(sql).ToList(); if (result != null) { list = result; } else { list = new List<Stockty>(); } } return list; }
public static List<WarnLog> getlist() { using (BaseContext _db = new BaseContext()) { //获取销售记录 var query = _db.a_WareLog.AsNoTracking().ToList(); return query; } }
private static int getStockgoosNum(int goodsId) { using (BaseContext _db = new BaseContext()) { var query = _db.a_Stock.AsNoTracking(). Where(l => l.GoodsId == goodsId).Sum(x => x.Num); return query; } //供应商名称1//联系人2 }
/// <summary> /// 登录 /// </summary> /// <returns></returns> public static ReturnRet<Employee> Login(string username, string password) { ReturnRet<Employee> ret = new ReturnRet<Employee>(); ret.success = false; using (BaseContext _db = new BaseContext()) { var query = from s in _db.a_Emp where s.EmpName == username select s; Employee user = query.FirstOrDefault(); if (user == null) { ret.message = "找不到账号"; return ret; } if (user.Pwd != EncryptHelper.MD5Encrypt(password)) { ret.message = "密码错误"; return ret; } ret.success = true; ret.message = "登录成功"; ret.data = user; } return ret; }