public void Example() { //将字符串进行base64编码、解码 var character = "123456ABCDE"; var baseString1 = ZConvert.ToBase64Encode(character); var baseString2 = ZConvert.ToBase64Decode(baseString1); //将时间转为时间戳/将时间戳转为时间 var timestamp = ZConvert.ToTimeStampFromDateTime(DateTime.Now); var datetime = ZConvert.ToDateTimeFromTimeStamp(timestamp); //得到枚举的int32值 var enumber = ZConvert.ToIntFromEnum(TimeStampUnit.Millisecond); //IP转为数字/数字转为IP var inumber = ZConvert.ToLongFromIp("127.0.0.1"); var ip = ZConvert.ToIpFromLong(inumber); //在转换过程中,你并不想在转换失败的时候抛出异常,那么建议你试试TryTo方法 //将字符串/object转为数字 var number = "123456"; var number1 = ZConvert.TryToInt32(number); //也可使用:TryToInt16()、TryToInt64() var number2 = ZConvert.TryToUInt32(number); //也可使用:TryToUInt16()、TryToUInt64() //将时间转为时间戳/将时间戳转为时间 var timestamp2 = ZConvert.TryToTimeStampFromDateTime(DateTime.Now); var datetime2 = ZConvert.TryToDateTimeFromTimeStamp(timestamp); //... }
private void To() { //base64 var character = "ABCDEFG"; var base64 = "WkhJ5qGG5p6257uE5Lu2"; Console.WriteLine("base64"); Console.WriteLine(" ToBase64Encode:{0}", ZConvert.ToBase64Encode(character)); Console.WriteLine(" ToBase64Decode:{0}", ZConvert.ToBase64Decode(base64)); //timestamp var timestamp = "1609430400"; Console.WriteLine("timestamp"); Console.WriteLine(" ToDateTimeFromTimeStamp:{0}", ZConvert.ToDateTimeFromTimeStamp(timestamp)); Console.WriteLine(" ToTimeStampFromDateTime:{0}", ZConvert.ToTimeStampFromDateTime(DateTime.Now)); //enum Console.WriteLine("enum"); Console.WriteLine(" ToIntFromEnum:{0}", ZConvert.ToIntFromEnum(TimeStampUnit.Millisecond)); //ip Console.WriteLine("ip"); Console.WriteLine(" ToIpFromLong:{0}", ZConvert.ToIpFromLong(2130706433)); Console.WriteLine(" ToLongFromIp:{0}", ZConvert.ToLongFromIp("127.0.0.1")); //unicode character = "中文"; var unicode = "\\u8fd9\\u662f\\u0055\\u006e\\u0069\\u0063\\u006f\\u0064\\u0065\\u7f16\\u7801"; Console.WriteLine("unicode"); Console.WriteLine(" ToUnicodeEncode:{0}", ZConvert.ToUnicodeEncode(character)); Console.WriteLine(" ToUnicodeDecode:{0}", ZConvert.ToUnicodeDecode(unicode)); Console.WriteLine(); Console.WriteLine(); }
private static string GetDateRangeSql(WhereData cp, char[] separator, bool ignoreEmpty = true) { var sSql = string.Empty; string fromDateStr; string toDateStr; if (APP.DbProvider == DbProviderEnum.Oracle) { fromDateStr = "{0} >= TO_DATE('{1}','yyyy-mm-dd')"; toDateStr = "{0} <= TO_DATE('{1} 23:59:59','yyyy-mm-dd hh24:mi:ss')"; } else { fromDateStr = "datediff(day,'{1}',{0}) >=0"; toDateStr = "datediff(day,'{1}',{0})<=0"; } var values = ZConvert.ToString(cp.Value).Split(separator); var startDate = values[0].Trim(); var endDate = values.Length == 2 ? values[1].Trim() : startDate; if (!string.IsNullOrWhiteSpace(startDate) || !ignoreEmpty) { sSql = string.Format(fromDateStr, cp.Column, startDate); } if (!string.IsNullOrWhiteSpace(endDate) || !ignoreEmpty) { sSql += (sSql.Length > 0 ? " AND " : string.Empty) + string.Format(toDateStr, cp.Column, endDate); } return(sSql); }
//[IgnoreAuthorize] public async Task <IActionResult> resertPassword(string Id) { var r = await UserApp. //ChangePasswordAsync(CurrentUser.Id, model.Password, model.NewPassword, 0, CurrentUser); ResetPasswordAsync(ZConvert.StrToLong(Id), "123456", 0, CurrentUser); return(Operation(r.IsSuc, r.IsSuc ? "重置密码成功" : r.Msg)); }
private static string GetDateRangeSql(WhereData cp, char _separator, bool _ignoreEmpty = true) { var sSql = string.Empty; var _from = "datediff(day,'{1}',{0}) >=0"; var _to = "datediff(day,'{1}',{0})<=0"; var values = ZConvert.ToString(cp.Value).Split(_separator); if (values.Length == 1) { values = new string[] { values[0], values[0] } } ; if (!string.IsNullOrWhiteSpace(values[0]) || !_ignoreEmpty) { sSql = string.Format(_from, cp.Column, values[0]); } if (!string.IsNullOrWhiteSpace(values[1]) || !_ignoreEmpty) { sSql += (sSql.Length > 0 ? " and " : string.Empty) + string.Format(_to, cp.Column, values[1]); } return(sSql); } }
public decimal GetByBillNo(string sql) { List <SqlParameter> paramList = new List <SqlParameter>(); DataTable dt = SqlQueryForDataTatable(sql, paramList); return(ZConvert.StrToDecimal(dt.Rows[0][0].ToString())); }
private static void SetCacheKey(string table, string field, string key) { var tableKeys = GetTableKeys(table); var fieldKeys = GetFieldKeys(tableKeys, field); tableKeys[field] = ZConvert.ToString(MaxOfAllKey(fieldKeys, key)); ZCache.SetCache(String.Format("currentkey_{0}", table), tableKeys); }
/// <summary> /// 分页获取数据 /// </summary> /// <param name="data">分页数据</param> /// <param name="count">总条数</param> /// <param name="sqlp">参数</param> /// <returns>实体列表数据</returns> public virtual List <T> GetQueryManyForPage(SelectBuilderData data, out int count, List <SqlParameter> sqlp) { List <SqlParameter> temp = new List <SqlParameter>(); string sqlStr = SqlServerProvider.GetSqlForSelectBuilder(data); string sqlStr2 = SqlServerProvider.GetSqlForTotalBuilder(data); object totalCount = SqlQueryForScalar(sqlStr2, sqlp); count = ZConvert.StrToInt(totalCount, 0); return(SqlQuery(sqlStr, sqlp).ToList <T>()); }
//日期时间加上N位数字加一 public static string Dateplus(IDbContext db, string table, string field, string datestringFormat, int numberLength) { var dbkey = db.Sql(String.Format("select isnull(max({0}),0) from {1}", field, table)).QuerySingle <string>(); var mykey = DateTime.Now.ToString(datestringFormat) + String.Empty.PadLeft(numberLength, '0'); var cachedKeys = GetCacheKey(table, field); var currentKey = MaxOfAllKey(cachedKeys, ZConvert.ToString(dbkey), mykey); var key = ZConvert.ToString(currentKey + 1); SetCacheKey(table, field, key); return(key); }
private static long MaxOfAllKey(string cachedKeys, params string[] otherKey) { var keys = new List <string> { cachedKeys }; keys.AddRange(otherKey); var max = keys.Max <object>(x => ZConvert.To <long>(x)); return(max); }
public dynamic GetSystemLog(RequestWrapper request) { var page = ZConvert.To <int>(request["page"], 1); var rows = ZConvert.To <int>(request["rows"], 0); var logDate = ZConvert.ToString(request["logdate"]); var list = new List <dynamic>(); var basepath = HttpContext.Current.Server.MapPath("/logs/"); var di = new DirectoryInfo(basepath); if (!di.Exists) { di.Create(); } string[] s = logDate.Split('到'); string s1 = "1990-01-01"; string s2 = DateTime.Now.Date.ToString(); switch (s.Length) { case 1: if (logDate.Length > 0) { s1 = s[0]; s2 = s1; } break; case 2: s1 = s[0]; s2 = s[1]; break; } int t1 = Convert.ToInt32(Convert.ToDateTime(s1).ToString("yyyyMMdd")); int t2 = Convert.ToInt32(Convert.ToDateTime(s2).ToString("yyyyMMdd")); foreach (var fi in di.GetFiles().Where(x => (Convert.ToInt32(x.FullName.Replace(basepath, "").Substring(3, 8)) >= t1 && Convert.ToInt32(x.FullName.Replace(basepath, "").Substring(3, 8)) <= t2))) { dynamic item = new ExpandoObject(); item.filename = fi.FullName.Replace(basepath, ""); item.size = (fi.Length / 1024).ToString() + " KB"; item.time = fi.CreationTime.ToString(); item.id = item.filename.Replace(".txt", ""); list.Add(item); } var result = list.OrderByDescending(x => x.filename).Skip((page - 1) * rows).Take(rows); return(new { rows = result, total = list.Count() }); }
//最大值加一 public static string Maxplus(IDbContext db, string table, string field) { var sqlWhere = " where 1 = 1 "; var dbkey = APP.DbProvider == DbProviderEnum.SqlServer ? db.Sql(String.Format("select isnull(max({0}),0) from {1} {2}", field, table, sqlWhere)).QuerySingle <string>() : db.Sql(String.Format("select NVL(max({0}),0) from {1} {2}", field, table, sqlWhere)).QuerySingle <string>(); var cachedKeys = GetCacheKey(table, field); var currentKey = MaxOfAllKey(cachedKeys, ZConvert.ToString(dbkey)); var key = ZConvert.ToString(currentKey + 1); SetCacheKey(table, field, key); return(key); }
private void TryTo() { //base64 var character = "ABCDEFG"; var base64 = "WkhJ5qGG5p6257uE5Lu2"; Console.WriteLine("base64"); Console.WriteLine(" TryToBase64Encode:{0}", ZConvert.TryToBase64Encode(character)); Console.WriteLine(" TryToBase64Decode:{0}", ZConvert.TryToBase64Decode(base64)); //timestamp var timestamp = "1609430400"; Console.WriteLine("timestamp"); Console.WriteLine(" TryToDateTimeFromTimeStamp:{0}", ZConvert.TryToDateTimeFromTimeStamp(timestamp)); Console.WriteLine(" TryToTimeStampFromDateTime:{0}", ZConvert.TryToTimeStampFromDateTime(DateTime.Now)); //ip Console.WriteLine("ip"); Console.WriteLine(" TryToIpFromLong:{0}", ZConvert.TryToIpFromLong(2130706433)); Console.WriteLine(" TryToLongFromIp:{0}", ZConvert.TryToLongFromIp("127.0.0.1")); //bool Console.WriteLine("bool"); Console.WriteLine(" TryToBoolean:{0}", ZConvert.TryToBoolean("true")); //datetime Console.WriteLine("datetime"); Console.WriteLine(" TryToDateTime:{0}", ZConvert.TryToDateTime("2021-01-01")); //number Console.WriteLine("number"); Console.WriteLine(" TryToDecimal:{0}", ZConvert.TryToDecimal("100")); Console.WriteLine(" TryToDouble:{0}", ZConvert.TryToDouble("100")); Console.WriteLine(" TryToInt16:{0}", ZConvert.TryToInt16("100")); Console.WriteLine(" TryToInt32:{0}", ZConvert.TryToInt32("100")); Console.WriteLine(" TryToInt64:{0}", ZConvert.TryToInt64("100")); Console.WriteLine(" TryToSingle:{0}", ZConvert.TryToSingle("100")); Console.WriteLine(" TryToUInt16:{0}", ZConvert.TryToUInt16("100")); Console.WriteLine(" TryToUInt32:{0}", ZConvert.TryToUInt32("100")); Console.WriteLine(" TryToUInt64:{0}", ZConvert.TryToUInt64("100")); //unicode character = "中文"; var unicode = "\\u8fd9\\u662f\\u0055\\u006e\\u0069\\u0063\\u006f\\u0064\\u0065\\u7f16\\u7801"; Console.WriteLine("unicode"); Console.WriteLine(" TryToUnicodeEncode:{0}", ZConvert.TryToUnicodeEncode(character)); Console.WriteLine(" TryToUnicodeDecode:{0}", ZConvert.TryToUnicodeDecode(unicode)); Console.WriteLine(); Console.WriteLine(); }
public static string inventory(IDbContext db, string table, string field, ParamQuery pQuery) { //var where = pQuery.GetData().WhereSql; var sqlWhere = " where 1 = 1 "; if (pQuery != null) { sqlWhere += " and " + pQuery.GetData().WhereSql; } var dbkey = db.Sql(String.Format("select isnull(max({0}),0) from {1} {2}", field, table, sqlWhere)).QuerySingle <string>(); var cachedKeys = getCacheKey(table, field); var currentKey = maxOfAllKey(cachedKeys, ZConvert.ToString(dbkey)); var key = ZConvert.ToString(currentKey + 1); SetCacheKey(table, field, key); return(key); }
public string GetNewMaterialCode(string ParentCode) { int index = 0; var MaxCode = db.Sql(@"select max(MaterialCode) from mms_material where MaterialType=@0", ParentCode).QuerySingle <string>() ?? string.Empty; if (MaxCode.Length < ParentCode.Length) { index = ZConvert.To <int>(MaxCode, 0); } else { index = ZConvert.To <int>(MaxCode.Substring(ParentCode.Length), 0); } return(ParentCode + (index + 1).ToString().PadLeft(2, '0')); }
// GET: /<controller>/ public async Task <IActionResult> Index(ErrorLogOption filter) { ViewBag.filter = filter; var model = new List <ErrorLogDto>(); var contentRoot = Directory.GetCurrentDirectory(); var webRoot = Path.Combine(contentRoot, "logs\\Error"); var filelist = new List <string>(); new ServiceCollection() .AddSingleton <IFileProvider>(new PhysicalFileProvider(webRoot)) .AddSingleton <IFileManager, FileManager>() .BuildServiceProvider() .GetService <IFileManager>() .ShowStructure((layer, name) => filelist.Add(name)); var result = new List <ErrorLogDto>(); if (filelist.Count > 0) { int i = 1; foreach (var item in filelist.OrderByDescending(o => o)) { var m = new ErrorLogDto { Id = i, filename = item, CreatorTime = ZConvert.StrToDateTime(item.Replace(".log", ""), DateTime.Now) }; result.Add(m); i++; } } if (filter.kCreatorTime != null) { result = result.Where(o => o.CreatorTime >= filter.kCreatorTime.Value).ToList(); } if (filter.eCreatorTime != null) { result = result.Where(o => o.CreatorTime <= filter.eCreatorTime.Value).ToList(); } model = result.OrderByDescending(o => o.CreatorTime).ToList(); return(View(model)); }
public virtual void FillData(int x, int y, string field, object value) { var row = sheet.GetRow(y) ?? sheet.CreateRow(y); var cell = row.GetCell(x) ?? row.CreateCell(x); //if (!field.StartsWith("title_")) cell.CellStyle = GetDataStyle(); switch ((value ?? string.Empty).GetType().Name.ToLower()) { case "int32": case "int64": case "decimal": cell.CellStyle.Alignment = HorizontalAlignment.Right; cell.SetCellValue(ZConvert.To <double>(value, 0)); break; default: cell.SetCellValue(ZConvert.ToString(value)); break; } }
public RoleController(IOptions <SiteConfig> option, IConfiguration configuration) : base(configuration) { Config = option.Value; DefaultPageSize = ZConvert.StrToInt(Config.Configlist.FirstOrDefault(o => o.Key == "pagesize")?.Values); }
/// <summary> /// Base64解码字符串(Base64 decode string) /// </summary> /// <param name="value">解码字符串</param> /// <returns></returns> public static string Base64Decode(string value) { return(ZConvert.ToBase64Decode(value)); }
public static Stream ListToExcel(object list, Dictionary <string, string> titles, bool IsExportAllCol) { const int startIndex = 0; var fields = titles.Keys.ToList(); var workbook = new HSSFWorkbook(); var sheet = workbook.CreateSheet("sheet1"); sheet.DefaultRowHeight = 200 * 20; var row = sheet.CreateRow(startIndex); var headStyle = GetHeadStyle(workbook); EachHelper.EachListHeader(list, (i, name, type) => { if (!fields.Contains(name)) { if (IsExportAllCol) { fields.Add(name); } else { return; } } var cellIndex = fields.IndexOf(name) + startIndex; var cell = row.CreateCell(cellIndex); cell.SetCellValue(titles.ContainsKey(name)?titles[name]:name); cell.CellStyle = headStyle; sheet.AutoSizeColumn(cellIndex); }); EachHelper.EachListRow(list, (rowIndex, dataRow) => { row = sheet.CreateRow(rowIndex + 1); EachHelper.EachObjectProperty(dataRow, (i, name, value) => { if (!fields.Contains(name)) { if (IsExportAllCol) { fields.Add(name); } else { return; } } var cellIndex = fields.IndexOf(name) + startIndex; var dataStyle = GetDataStyle(workbook); var cell = row.CreateCell(cellIndex); cell.CellStyle = dataStyle; switch ((value ?? string.Empty).GetType().Name.ToLower()) { case "int32": case "int64": case "decimal": dataStyle.Alignment = HorizontalAlignment.RIGHT; cell.SetCellValue(ZConvert.To <double>(value, 0)); break; default: cell.CellStyle.Alignment = HorizontalAlignment.LEFT; cell.SetCellValue(ZConvert.ToString(value)); break; } }); }); var ms = new MemoryStream(); workbook.Write(ms); ms.Flush(); ms.Position = 0; workbook = null; sheet = null; row = null; return(ms); }
/// <summary> /// Unicode解码字符串(Unicode decode string) /// </summary> /// <param name="value">字符串</param> /// <returns></returns> public static string UnicodeDecode(string value) { return(ZConvert.ToUnicodeDecode(value)); }
public LoginLogController(IOptions <SiteConfig> option) { Config = option.Value; DefaultPageSize = ZConvert.StrToInt(Config.Configlist.FirstOrDefault(o => o.Key == "pagesize").Values); }
//[IgnoreAuthorize] public async Task <IActionResult> ResertPassword(string id) { var r = await UserApp.ResetPasswordAsync(ZConvert.StrToLong(id), "123456", 0, await CurrentUser()); return(Json(r)); }
/// <summary> /// 添加溢出值 /// </summary> public void AddInventoryOver() { int Stockdate = ZConvert.StrToInt(ZConfig.GetConfigString("Stockdate")); DateTime Time = DateTime.Now; for (int z = 0; z < Stockdate; z++) { int t = z == 0 ? 0 : 1; Time = Time.AddDays(t); var InventoryHistory = InventoryOverHistoryBLL.GetInstance().TableNoTracking().Where(o => o.CreTime == Time.Date).FirstOrDefault(); if (InventoryHistory == null) { // 添加记录 InventoryOverHistory obj = new InventoryOverHistory(); obj.CreTime = Time.Date; InventoryOverHistoryBLL.GetInstance().Add(obj); var store = StoreBll.GetInstance().TableNoTracking().Where(o => o.State == (int)StoreState.线中).ToList(); var ProductCategory = ProductCategoryBll.GetInstance().TableNoTracking().ToList(); var ProductCategoryidlist = ProductCategory.Select(o => o.Id).ToList(); ProductCategoryidlist.Add(0); var Productlist = ProductBll.GetInstance().TableNoTracking().Where(o => ProductCategoryidlist.Contains(o.ProductCategoryId) && o.State == ProductStateEnum.架).ToList(); var Productidlist = Productlist.Select(o => o.Id).ToList(); Productidlist.Add(0); var StockSettinglist = StockSettingBLL.GetInstance().TableNoTracking().Where(o => Productidlist.Contains(o.ProductId)).ToList(); if (store != null && store.Count > 0) { foreach (var itemstore in store) { if (ProductCategory != null && ProductCategory.Count > 0) { foreach (var itemProductCategory in ProductCategory) { #region MyRegion //// //店铺 分类下 当天的总库存 List <StockOutInView> StockOutInViewlist = InventoryBLL.GetInstance().GetStockTotal(itemstore.Id, itemProductCategory.Id, Time); List <Product> ProductList = Productlist.Where(o => o.ProductCategoryId == itemProductCategory.Id).ToList(); if (ProductList != null) { foreach (var item in ProductList) { string sql = " INSERT INTO [InventoryOver] ([StoreId] ,[ProductId] ,[CreTime] "; sql += " ,[Time1] ,[Time2] ,[Time3] ,[Time4] ,[Time5] ,[Time6] ,[Time7] ,[Time8] ,[Time9] ,[Time10] ,[Time11] ,[Time12] ,[Time13] ,[Time14] ,[Time15] "; sql += " ,[Time16] ,[Time17] ,[Time18] ,[Time19] ,[Time20] ,[Time21] ,[Time22] ,[Time23] "; sql += " ,[Time24] ,[Time25] ,[Time26] ,[Time27] ,[Time28] ,[Time29] ,[Time30] ,[Time31] ,[Time32] ,[Time33] "; sql += " ,[Time34] ,[Time35] ,[Time36] ,[Time37] ,[Time38] ,[Time39] ,[Time40] ,[Time41] ,[Time42] ,[Time43] ,[Time44] ,[Time45] ,[Time46] ,[Time47] ,[Time48] "; sql += " ) "; sql += " VALUES "; sql += " (" + itemstore.Id + "," + item.Id + ",'" + Time.Date + "' "; int i = 1; #region 循环 while (i < 49) { //分类下 var EmployeeProductViewModellistitem = new List <StockOutInView>(); #region MyRegion if (i == 1) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time1 != null).ToList(); } else if (i == 2) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time2 != null).ToList(); } else if (i == 3) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time3 != null).ToList(); } else if (i == 4) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time4 != null).ToList(); } else if (i == 5) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time5 != null).ToList(); } else if (i == 6) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time6 != null).ToList(); } else if (i == 7) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time7 != null).ToList(); } else if (i == 8) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time8 != null).ToList(); } else if (i == 9) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time9 != null).ToList(); } else if (i == 10) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time10 != null).ToList(); } else if (i == 11) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time11 != null).ToList(); } else if (i == 12) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time12 != null).ToList(); } else if (i == 13) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time13 != null).ToList(); } else if (i == 14) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time14 != null).ToList(); } else if (i == 15) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time15 != null).ToList(); } else if (i == 16) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time16 != null).ToList(); } else if (i == 17) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time17 != null).ToList(); } else if (i == 18) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time18 != null).ToList(); } else if (i == 19) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time19 != null).ToList(); } else if (i == 20) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time20 != null).ToList(); } else if (i == 21) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time21 != null).ToList(); } else if (i == 22) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time22 != null).ToList(); } else if (i == 23) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time23 != null).ToList(); } else if (i == 24) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time24 != null).ToList(); } else if (i == 25) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time25 != null).ToList(); } else if (i == 26) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time26 != null).ToList(); } else if (i == 27) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time27 != null).ToList(); } else if (i == 28) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time28 != null).ToList(); } else if (i == 29) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time29 != null).ToList(); } else if (i == 30) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time30 != null).ToList(); } else if (i == 31) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time31 != null).ToList(); } else if (i == 32) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time32 != null).ToList(); } else if (i == 33) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time33 != null).ToList(); } else if (i == 34) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time34 != null).ToList(); } else if (i == 35) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time35 != null).ToList(); } else if (i == 36) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time36 != null).ToList(); } else if (i == 37) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time37 != null).ToList(); } else if (i == 38) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time38 != null).ToList(); } else if (i == 39) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time39 != null).ToList(); } else if (i == 40) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time40 != null).ToList(); } else if (i == 41) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time41 != null).ToList(); } else if (i == 42) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time42 != null).ToList(); } else if (i == 43) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time43 != null).ToList(); } else if (i == 44) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time44 != null).ToList(); } else if (i == 45) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time45 != null).ToList(); } else if (i == 46) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time46 != null).ToList(); } else if (i == 47) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time47 != null).ToList(); } else if (i == 48) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time48 != null).ToList(); } #endregion //产品下的总库存 int TotalInventory = EmployeeProductViewModellistitem.Select(o => o.EmployeeId).Distinct().Count(); //百分比计算 var StockSetting = StockSettinglist.Where(o => o.ProductId == item.Id).FirstOrDefault(); if (StockSetting != null) { TotalInventory = ZConvert.StrToInt(TotalInventory * ((StockSetting.OverflowValue - 100) / 100)); } else { TotalInventory = 0; } sql += " ," + TotalInventory + " "; i++; } #endregion sql += " )"; ExecuteSqlCommand(sql, null); } } #endregion } } } } } } }
/// <summary> /// 添加溢出值 后台修改 比例 /// </summary> /// <param name="ProductId"></param> public void UpdateInventoryOver(object oid) { int ProductId = (int)oid; DateTime dt = DateTime.Now.Date; var InventoryHistory = InventoryOverHistoryBLL.GetInstance().TableNoTracking().Where(o => o.CreTime >= dt).ToList(); var store = StoreBll.GetInstance().TableNoTracking().Where(o => o.State == (int)StoreState.线中).ToList(); var ProductCategory = ProductCategoryBll.GetInstance().TableNoTracking().ToList(); var ProductCategoryidlist = ProductCategory.Select(o => o.Id).ToList(); ProductCategoryidlist.Add(0); var Productlist = ProductBll.GetInstance().TableNoTracking().Where(o => o.Id == ProductId && o.State == ProductStateEnum.架).ToList(); var Productidlist = Productlist.Select(o => o.Id).ToList(); Productidlist.Add(0); var StockSettinglist = StockSettingBLL.GetInstance().TableNoTracking().Where(o => Productidlist.Contains(o.ProductId)).ToList(); if (store != null && store.Count > 0) { foreach (var itemstore in store) { if (ProductCategory != null && ProductCategory.Count > 0) { foreach (var itemProductCategory in ProductCategory) { if (InventoryHistory != null && InventoryHistory.Count > 0) { foreach (var objInventoryHistory in InventoryHistory) { //// //店铺 分类下 当天的总库存 List <StockOutInView> StockOutInViewlist = InventoryBLL.GetInstance().GetStockTotal(itemstore.Id, itemProductCategory.Id, objInventoryHistory.CreTime); List <Product> ProductList = Productlist.Where(o => o.ProductCategoryId == itemProductCategory.Id).ToList(); #region MyRegion if (ProductList != null) { foreach (var item in ProductList) { string sql = " update [InventoryOver] set "; int i = 1; #region 循环 string tstr = ""; while (i < 49) { //分类下 var EmployeeProductViewModellistitem = new List <StockOutInView>(); #region MyRegion if (i == 1) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time1 != null).ToList(); } else if (i == 2) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time2 != null).ToList(); } else if (i == 3) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time3 != null).ToList(); } else if (i == 4) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time4 != null).ToList(); } else if (i == 5) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time5 != null).ToList(); } else if (i == 6) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time6 != null).ToList(); } else if (i == 7) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time7 != null).ToList(); } else if (i == 8) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time8 != null).ToList(); } else if (i == 9) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time9 != null).ToList(); } else if (i == 10) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time10 != null).ToList(); } else if (i == 11) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time11 != null).ToList(); } else if (i == 12) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time12 != null).ToList(); } else if (i == 13) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time13 != null).ToList(); } else if (i == 14) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time14 != null).ToList(); } else if (i == 15) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time15 != null).ToList(); } else if (i == 16) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time16 != null).ToList(); } else if (i == 17) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time17 != null).ToList(); } else if (i == 18) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time18 != null).ToList(); } else if (i == 19) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time19 != null).ToList(); } else if (i == 20) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time20 != null).ToList(); } else if (i == 21) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time21 != null).ToList(); } else if (i == 22) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time22 != null).ToList(); } else if (i == 23) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time23 != null).ToList(); } else if (i == 24) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time24 != null).ToList(); } else if (i == 25) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time25 != null).ToList(); } else if (i == 26) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time26 != null).ToList(); } else if (i == 27) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time27 != null).ToList(); } else if (i == 28) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time28 != null).ToList(); } else if (i == 29) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time29 != null).ToList(); } else if (i == 30) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time30 != null).ToList(); } else if (i == 31) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time31 != null).ToList(); } else if (i == 32) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time32 != null).ToList(); } else if (i == 33) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time33 != null).ToList(); } else if (i == 34) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time34 != null).ToList(); } else if (i == 35) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time35 != null).ToList(); } else if (i == 36) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time36 != null).ToList(); } else if (i == 37) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time37 != null).ToList(); } else if (i == 38) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time38 != null).ToList(); } else if (i == 39) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time39 != null).ToList(); } else if (i == 40) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time40 != null).ToList(); } else if (i == 41) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time41 != null).ToList(); } else if (i == 42) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time42 != null).ToList(); } else if (i == 43) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time43 != null).ToList(); } else if (i == 44) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time44 != null).ToList(); } else if (i == 45) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time45 != null).ToList(); } else if (i == 46) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time46 != null).ToList(); } else if (i == 47) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time47 != null).ToList(); } else if (i == 48) { EmployeeProductViewModellistitem = StockOutInViewlist.Where(o => o.PrdouctId == item.Id && o.Time48 != null).ToList(); } #endregion //产品下的总库存 int TotalInventory = EmployeeProductViewModellistitem.Select(o => o.EmployeeId).Distinct().Count(); //百分比计算 var StockSetting = StockSettinglist.Where(o => o.ProductId == item.Id).FirstOrDefault(); if (StockSetting != null) { TotalInventory = ZConvert.StrToInt(TotalInventory * ((StockSetting.OverflowValue - 100) / 100)); } else { TotalInventory = 0; } tstr += " [Time" + i + "]=" + TotalInventory + ","; i++; } #endregion if (!string.IsNullOrEmpty(tstr)) { tstr = tstr.Substring(0, tstr.Length - 1); } sql += tstr; sql += " where [StoreId]=" + itemstore.Id + " and [ProductId]=" + item.Id + " and [CreTime]='" + objInventoryHistory.CreTime.Date + "'"; ExecuteSqlCommand(sql, null); } } #endregion } } } } } } }