123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- /*
- * 仓库名称关联仓库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 StoreForNameService
- {
- static string _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
- // public StoreForNameService()
- // {
- // _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
- // }
- /// <summary>
- /// 通过仓库名称查询一条记录
- /// </summary>
- /// <param name="StoreName">仓库名称</param>
- /// <returns></returns>
- public static StoreForName QueryByStoreName(string StoreName)
- {
- WebCMSEntities db = new WebCMSEntities();
- StoreForName editData = db.StoreForName.FirstOrDefault(m => m.Name == StoreName) ?? new StoreForName();
- db.Dispose();
- return editData;
- }
- /// <summary>
- /// 查询记录数
- /// </summary>
- /// <param name="Id">主键Id</param>
- /// <returns></returns>
- public static int Count(string condition = "")
- {
- int result = 0;
- DataTable dt = CustomerSqlConn.dtable("select count(Id) from StoreForName where 1=1" + condition, _conn);
- if (dt.Rows.Count > 0)
- {
- result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
- }
- return result;
- }
- /// <summary>
- /// 查询是否存在
- /// </summary>
- /// <param name="Id">主键Id</param>
- /// <returns></returns>
- // public static bool Exist(int Id)
- // {
- // WebCMSEntities db = new WebCMSEntities();
- // bool check = db.StoreForName.Any(m => m.Id == Id);
- // db.Dispose();
- // return check;
- // }
- /// <summary>
- /// 添加数据
- /// </summary>
- /// <param name="Fields">要设置的字段</param>
- /// <returns></returns>
- public static AppResultJson Add(Dictionary<string, object> fields, bool check = true)
- {
- int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("StoreForName", fields, 0);
- return new AppResultJson() { Status = "1", Data = Id };
- }
- /// <summary>
- /// 逻辑删除
- /// </summary>
- /// <param name="Id">主键Id</param>
- public static void Remove(int Id)
- {
- Dictionary<string, object> fields = new Dictionary<string, object>();
- fields.Add("Status", -1);
- new DbService(AppConfig.Base.mainTables, _conn).Edit("StoreForName", fields, Id);
- }
- /// <summary>
- /// 删除数据
- /// </summary>
- /// <param name="Id">主键Id</param>
- public static void Delete(int Id)
- {
- new DbService(AppConfig.Base.mainTables, _conn).Delete("StoreForName", Id);
- }
- /// <summary>
- /// 导出excel表格
- /// </summary>
- /// <param name="fields">查询条件(单个字段)</param>
- /// <param name="condition">查询条件(sql语句)</param>
- /// <returns></returns>
- // public void ExportExcel(List<RelationData> relationData, string condition)
- // {
- // }
- }
- }
|