private SNObject GetSN(ProcCore.Business.SNType tab) { SNObject sn = new SNObject(); using (var tx = new TransactionScope()) { var get_sn_db = getDB0; try { get_sn_db = getDB0; string tab_name = Enum.GetName(typeof(ProcCore.Business.SNType), tab); var items = get_sn_db.i_SN.Single(x => x.sn_type == tab_name); if (items.y == DateTime.Now.Year && items.m == DateTime.Now.Month && items.d == DateTime.Now.Day ) { int now_max = items.sn_max; now_max++; items.sn_max = now_max; } else { items.y = DateTime.Now.Year; items.m = DateTime.Now.Month; items.d = DateTime.Now.Day; items.sn_max = 1; } get_sn_db.SaveChanges(); tx.Complete(); sn.y = items.y; sn.m = items.m; sn.d = items.d; sn.sn_max = items.sn_max; } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { get_sn_db.Dispose(); } } return(sn); }
private SNObject GetSN(ProcCore.Business.SNType tab) { SNObject sn = new SNObject(); using (var tx = new TransactionScope()) { var get_sn_db = getDB0; try { get_sn_db = getDB0; string tab_name = Enum.GetName(typeof(ProcCore.Business.SNType), tab); var items = get_sn_db.i_SN.Single(x => x.sn_type == tab_name); if (items.y == DateTime.Now.Year && items.m == DateTime.Now.Month && items.d == DateTime.Now.Day ) { int now_max = items.sn_max; now_max++; items.sn_max = now_max; } else { items.y = DateTime.Now.Year; items.m = DateTime.Now.Month; items.d = DateTime.Now.Day; items.sn_max = 1; } get_sn_db.SaveChanges(); tx.Complete(); sn.y = items.y; sn.m = items.m; sn.d = items.d; sn.sn_max = items.sn_max; } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { get_sn_db.Dispose(); } } return sn; }