using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace PunchingMistake { public class Function3 { /// /// 获取班次,规定早8至晚8为A班 /// /// public static string GetWorkClass() { bool classA = IsBetweenTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), DateTime.Now.ToString("yyyy-MM-dd") + " 08:00:00", DateTime.Now.ToString("yyyy-MM-dd") + " 20:00:00"); if (classA) { return "A班"; } else { return "B班"; } } /// /// 判断传入时间是否在工作时间段内 /// /// /// /// /// public static bool IsBetweenTime(string timeStr, string startTime, string endTime) { //判断传入时间是否在工作时间段内 try { TimeSpan startSpan = DateTime.Parse(startTime).TimeOfDay; TimeSpan endSpan = DateTime.Parse(endTime).TimeOfDay; DateTime t1 = Convert.ToDateTime(timeStr); TimeSpan dspNow = t1.TimeOfDay; if (dspNow > startSpan && dspNow < endSpan) { return true; } return false; } catch (Exception ex) { LogHelper.WriteLog(ex.ToString()); return false; } } /// /// 判断条码有效性 /// /// /// public static bool BarCodeValid(string barcode) { bool res = false; if (!string.IsNullOrWhiteSpace(barcode)) { if (barcode.Contains(".")) { res = true; } else { if (barcode.Length == 20) { res = true; } } } return res; } } public static class ScanAll { public static bool ScanResult; public static string barCode1; public static string barCode2; public static string barCode3; public static string barCode4; public static string barCode5; public static string barCode6; public static string partNo1; public static string partNo2; public static string partNo3; public static string partNo4; public static string partNo5; public static string partNo6; } public class OtherPart { public string productID3 { get; set; } public string qty3 { get; set; } public string productID4 { get; set; } public string qty4 { get; set; } public string productID5 { get; set; } public string qty5 { get; set; } public string productID6 { get; set; } public string qty6 { get; set; } public string productID7 { get; set; } public string qty7 { get; set; } public string productID8 { get; set; } public string qty8 { get; set; } } }