using SteamWare; using System.Globalization; namespace AppData { public class DataLayer { #region oggetti public public DS_AppTableAdapters.BatchListTableAdapter taBL; public DS_AppTableAdapters.ItemListTableAdapter taIL; public DS_AppTableAdapters.MaterialsTableAdapter taMat; public DS_AppTableAdapters.OrderListTableAdapter taOL; public DS_AppTableAdapters.StackListTableAdapter taSTL; public DS_AppTableAdapters.SheetListTableAdapter taSHL; public DataLayer() { // inizializzaizone classe initTA(); setupConnString(); } private void setupConnString() { string connString = memLayer.ML.CRS("NKC_WFConnectionString"); taBL.Connection.ConnectionString = connString; taIL.Connection.ConnectionString = connString; taMat.Connection.ConnectionString = connString; taOL.Connection.ConnectionString = connString; taSTL.Connection.ConnectionString = connString; taSHL.Connection.ConnectionString = connString; } private void initTA() { taBL = new DS_AppTableAdapters.BatchListTableAdapter(); taIL = new DS_AppTableAdapters.ItemListTableAdapter(); taMat = new DS_AppTableAdapters.MaterialsTableAdapter(); taOL = new DS_AppTableAdapters.OrderListTableAdapter(); taSTL = new DS_AppTableAdapters.StackListTableAdapter(); taSHL = new DS_AppTableAdapters.SheetListTableAdapter(); } #endregion /// /// oggetto static/singleton per fare chiamate sul datalayer /// public static DataLayer man = new DataLayer(); public string CodSoggCurrUser { get { return "O000123456"; } } public string CognNomeCurrUser { get { return "Mario Rossi"; } } public decodedData decodeBcode(string bcValue) { decodedData answ = new decodedData(); if (bcValue.StartsWith("MT")) { answ.codeType = codeType.Material; answ.code = bcValue.Replace("MT", ""); int codeInt = 0; int.TryParse(answ.code, out codeInt); answ.codeInt = codeInt; answ.description = $"Material: {answ.code}"; } else if (bcValue.StartsWith("ST")) { answ.codeType = codeType.Stack; answ.code = bcValue.Replace("ST", ""); int codeInt = 0; int.TryParse(answ.code, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out codeInt); answ.codeInt = codeInt; answ.description = $"Stack: {answ.code}"; } //else if (bcValue.StartsWith("SH")) //{ //} return answ; } } /// /// Valori decodificati /// public class decodedData { /// /// Tipo codice decodificato /// public codeType codeType { get; set; } = codeType.UNK; /// /// Codice decodificato /// public string code { get; set; } = ""; /// /// Codice decodificato in formato INT /// public int codeInt { get; set; } = 0; /// /// Descrizione associata /// public string description { get; set; } = ""; } /// /// Tipi di barcode gestiti /// public enum codeType { UNK = 0, Item, Material, Sheet, Stack, Batch } }