123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- 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 MachineChangeService
- {
- static string _conn = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
-
-
-
-
-
-
-
-
-
- public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, out int count, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
- {
- List<string> fields = new List<string>();
- fields.Add("Id");
- fields.Add("CreateDate");
- fields.Add("Status");
- fields.Add("ChangeNo");
- fields.Add("UserId");
- fields.Add("BackProductType");
- fields.Add("ChangeDeviceNum");
- fields.Add("ChangeTime");
- fields.Add("AuditBy");
- fields.Add("AuditResult");
- fields.Add("ChangeSnExpand");
- fields.Add("BackStoreId");
- fields.Add("Remark");
- fields.Add("BackStoreUserId");
- fields.Add("OutProductType");
- fields.Add("OutStoreId");
- fields.Add("OutStoreManagerMobile");
- Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MachineChange", relationData, orderBy, page, limit, condition, fields);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- count = int.Parse(obj["count"].ToString());
- return diclist;
- }
- public static List<Dictionary<string, object>> List(List<RelationData> relationData, string condition, int page = 1, int limit = 30, string orderBy = "Sort desc,Id desc")
- {
- List<string> fields = new List<string>();
- fields.Add("Id");
- fields.Add("CreateDate");
- fields.Add("Status");
- fields.Add("ChangeNo");
- fields.Add("UserId");
- fields.Add("BackProductType");
- fields.Add("ChangeDeviceNum");
- fields.Add("ChangeTime");
- fields.Add("AuditBy");
- fields.Add("AuditResult");
- fields.Add("ChangeSnExpand");
- fields.Add("BackStoreId");
- fields.Add("Remark");
- fields.Add("BackStoreUserId");
- fields.Add("OutProductType");
- fields.Add("OutStoreId");
- fields.Add("OutStoreManagerMobile");
- Dictionary<string, object> obj = new DbService(AppConfig.Base.mainTables, _conn).IndexData("MachineChange", relationData, orderBy, page, limit, condition, fields);
- List<Dictionary<string, object>> diclist = obj["data"] as List<Dictionary<string, object>>;
- return diclist;
- }
-
-
-
-
-
- public static MachineChange Query(int Id)
- {
- WebCMSEntities db = new WebCMSEntities();
- MachineChange editData = db.MachineChange.FirstOrDefault(m => m.Id == Id) ?? new MachineChange();
- db.Dispose();
- return editData;
- }
-
-
-
-
-
- public static MachineChange Query(string condition, string fields = "*")
- {
- var machineChange = new DbService(AppConfig.Base.mainTables, _conn).Query(fields, "MachineChange", condition);
- if (machineChange.Count > 0)
- {
- return Newtonsoft.Json.JsonConvert.DeserializeObject<MachineChange>(Newtonsoft.Json.JsonConvert.SerializeObject(machineChange));
- }
- return new MachineChange();
- }
- public static decimal Sum(string condition, string field)
- {
- DataTable dt = new DbService(AppConfig.Base.mainTables, _conn).QueryDetail("Sum(" + field + ")", "MachineChange", condition);
- decimal amount = 0;
- if (dt.Rows.Count > 0)
- {
- amount = decimal.Parse(dt.Rows[0][0].ToString());
- }
- return amount;
- }
-
-
-
-
-
- public static int Count(string condition = "", string field = "Id")
- {
- int result = 0;
- DataTable dt = new DbService(AppConfig.Base.mainTables, _conn).QueryDetail("count(" + field + ")", "MachineChange", condition);
- if (dt.Rows.Count > 0)
- {
- result = int.Parse(function.CheckInt(dt.Rows[0][0].ToString()));
- }
- return result;
- }
-
-
-
-
-
- public static bool Exist(int Id)
- {
- WebCMSEntities db = new WebCMSEntities();
- bool check = db.MachineChange.Any(m => m.Id == Id);
- db.Dispose();
- return check;
- }
-
-
-
-
-
- public static AppResultJson Add(Dictionary<string, object> fields, bool check = true)
- {
- if (check)
- {
- }
- int Id = new DbService(AppConfig.Base.mainTables, _conn).Add("MachineChange", fields, 0);
- return new AppResultJson() { Status = "1", Data = Id };
- }
-
-
-
-
-
- public static AppResultJson Edit(Dictionary<string, object> fields, int Id, bool check = true)
- {
- if (check)
- {
- }
- new DbService(AppConfig.Base.mainTables, _conn).Edit("MachineChange", fields, Id);
- return new AppResultJson() { Status = "1", Data = Id };
- }
-
-
-
-
- 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("MachineChange", fields, Id);
- }
-
-
-
-
- public static void Delete(int Id)
- {
- new DbService(AppConfig.Base.mainTables, _conn).Delete("MachineChange", Id);
- }
-
-
-
-
-
- public static void Sort(int Id, int Sort)
- {
- new DbService(AppConfig.Base.mainTables, _conn).Sort("MachineChange", Sort, Id);
- }
-
-
-
-
- public static void Import(string ExcelData)
- {
- WebCMSEntities db = new WebCMSEntities();
- JsonData list = JsonMapper.ToObject(ExcelData);
- for (int i = 1; i < list.Count; i++)
- {
- JsonData dr = list[i];
- db.MachineChange.Add(new MachineChange()
- {
- CreateDate = DateTime.Now,
- UpdateDate = DateTime.Now,
- });
- db.SaveChanges();
- }
- db.Dispose();
- }
-
-
-
-
-
-
-
-
-
- }
- }
|