/* * 仓库编号关联仓库Id */ using System; using System.Collections.Generic; using System.Linq; using System.Data; using MySystem.Models.Main; using Library; using LitJson; namespace MySystem.Service.Main { public class StoreForCodeService { static string _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString(); /// /// 通过仓库编号查询一条记录 /// /// 仓库编号 /// public static StoreForCode QueryByStoreNo(string StoreNo) { WebCMSEntities db = new WebCMSEntities(); StoreForCode editData = db.StoreForCode.FirstOrDefault(m => m.Code == StoreNo) ?? new StoreForCode(); db.Dispose(); return editData; } /// /// 查询记录数 /// /// 主键Id /// public static int Count(string condition = "") { int result = 0; DataTable dt = CustomerSqlConn.dtable("select count(Id) from StoreForCode where 1=1" + condition, _conn); if (dt.Rows.Count > 0) { result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString())); } return result; } /// /// 查询是否存在 /// /// 主键Id /// // public static bool Exist(int Id) // { // WebCMSEntities db = new WebCMSEntities(); // bool check = db.StoreForCode.Any(m => m.Id == Id); // db.Dispose(); // return check; // } /// /// 添加数据 /// /// 要设置的字段 /// public static AppResultJson Add(Dictionary fields, bool check = true) { int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("StoreForCode", fields, 0); return new AppResultJson() { Status = "1", Data = Id }; } /// /// 逻辑删除 /// /// 主键Id public static void Remove(int Id) { Dictionary fields = new Dictionary(); fields.Add("Status", -1); new DbService(AppConfig.Base.mainTables, _conn).Edit("StoreForCode", fields, Id); } /// /// 删除数据 /// /// 主键Id public static void Delete(int Id) { new DbService(AppConfig.Base.mainTables, _conn).Delete("StoreForCode", Id); } /// /// 导出excel表格 /// /// 查询条件(单个字段) /// 查询条件(sql语句) /// // public void ExportExcel(List relationData, string condition) // { // } } }