private async Task ExecuteConfirm() { int orderid, suborderid; string skuid; try { EditEnabled = false; EnabledCC = false; try { switch (_selectedCommand) { case CommandType.AddOrder: Detailed.Order.SubOrderERPID = Detailed.Order.SubOrderID; _dbservicewms.AddOrder(Detailed.Order); orderid = Detailed.OrderID; await ExecuteRefresh(); SelectedOrder = DataListOrder.FirstOrDefault(p => p.OrderID == orderid); _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Add order: {Detailed.Order.ToString()}"); break; case CommandType.EditOrder: _dbservicewms.UpdateOrders(SelectedOrder.ERPID, SelectedOrder.OrderID, Detailed.Order); var loe = from d in DataListOrder where d.OrderID == SelectedOrder.OrderID select d; foreach (var l in loe) { l.OrderID = Detailed.OrderID; l.Destination = Detailed.Destination; l.ReleaseTime = Detailed.ReleaseTime; } _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Edit order: {Detailed.Order.ToString()}"); break; case CommandType.DeleteOrder: _dbservicewms.DeleteOrders(SelectedOrder.ERPID, SelectedOrder.OrderID); _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Delete order: {Detailed.Order.ToString()}"); await ExecuteRefresh(); break; case CommandType.AddSubOrder: Detailed.Order.SubOrderERPID = Detailed.Order.SubOrderID; _dbservicewms.AddOrder(Detailed.Order); orderid = Detailed.OrderID; suborderid = Detailed.SubOrderID; await ExecuteRefresh(); SelectedSubOrder = DataListSubOrder.FirstOrDefault(p => p.OrderID == orderid && p.SubOrderID == suborderid); _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Add suborder: {Detailed.Order.ToString()}"); break; case CommandType.EditSubOrder: Detailed.Order.SubOrderERPID = Detailed.Order.SubOrderID; _dbservicewms.UpdateSubOrders(Detailed.ERPID, SelectedSubOrder.OrderID, SelectedSubOrder.SubOrderID, Detailed.Order); var lse = from d in DataListSubOrder where d.OrderID == SelectedSubOrder.OrderID && d.SubOrderID == SelectedSubOrder.SubOrderID select d; foreach (var l in lse) { l.SubOrderID = Detailed.SubOrderID; l.SubOrderName = Detailed.SubOrderName; } SelectedSubOrder.SubOrderID = Detailed.SubOrderID; SelectedSubOrder.SubOrderName = Detailed.SubOrderName; _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Edit suborder: {Detailed.Order.ToString()}"); break; case CommandType.DeleteSubOrder: _dbservicewms.DeleteSubOrders(Detailed.ERPID, Detailed.OrderID, Detailed.SubOrderID); _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Delete suborder: {Detailed.Order.ToString()}"); await ExecuteRefresh(); break; case CommandType.AddSKU: if (Detailed.Order.SubOrderName == null) { Detailed.Order.SubOrderName = Detailed.Order.SubOrderID.ToString(); } Detailed.Order.SubOrderERPID = Detailed.Order.SubOrderID; _dbservicewms.AddSKU(Detailed.Order); orderid = Detailed.OrderID; suborderid = Detailed.SubOrderID; skuid = Detailed.SKUID; _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Add SKU: {Detailed.Order.ToString()}"); await ExecuteRefresh(); SelectedSubOrder = DataListSubOrder.FirstOrDefault(p => p.OrderID == orderid && p.SubOrderID == suborderid); SelectedSKU = DataListSKU.FirstOrDefault(p => p.OrderID == orderid && p.SubOrderID == suborderid && p.SKUID == skuid); break; case CommandType.EditSKU: Detailed.Order.SubOrderERPID = Detailed.Order.SubOrderID; _dbservicewms.UpdateSKU(Detailed.Order); SelectedSKU.SKUID = Detailed.SKUID; SelectedSKU.SKUBatch = Detailed.SKUBatch; SelectedSKU.SKUQty = Detailed.SKUQty; _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Edit SKU: {Detailed.Order.ToString()}"); break; case CommandType.DeleteSKU: _dbservicewms.DeleteSKU(Detailed.Order); _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Delete SKU: {Detailed.Order.ToString()}"); await ExecuteRefresh(); break; default: break; } if (Detailed != null) { Detailed.EnableOrderEdit = false; Detailed.EnableSubOrderEdit = false; Detailed.EnableSKUEdit = false; Detailed.ValidationEnabled = false; } } catch (Exception e) { _warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, e.Message); } } catch (Exception e) { _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception, string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message)); } }