private async System.Threading.Tasks.Task <int> AddEDCAsync() { var ws = xS.GetWS("CardMachine"); //EDCId TID EDCName AccountNumberId StartDate EndDate IsWorking MID Remark StoreId var nonEmptyDataRows = ws.RowsUsed(); int Row = 6;//Title; List <EDC> cardM = new List <EDC>(); foreach (var dR in nonEmptyDataRows) { if (dR.RowNumber() > Row) { EDC eDC = new EDC { EDCId = dR.Cell(1).GetValue <int>(), TID = dR.Cell(2).GetValue <int>(), EDCName = dR.Cell(3).Value.ToString(), AccountNumberId = dR.Cell(4).GetValue <int>(), StartDate = dR.Cell(5).GetDateTime(), IsWorking = dR.Cell(7).GetBoolean(), MID = dR.Cell(8).Value.ToString(), Remark = dR.Cell(9).Value.ToString(), StoreId = dR.Cell(10).GetValue <int>(), IsReadOnly = true, UserId = "Admin" }; try { eDC.EndDate = (DateTime?)dR.Cell(6).GetDateTime() ?? null; } catch (Exception) { } } } //Add Here await db.CardMachine.AddRangeAsync(cardM); return(await db.SaveChangesAsync()); }
private void m_EnteredButton_Click(object sender, EventArgs e) { try { if (CurrentShipping == null) { return; } switch (CurrentShipping.ShippingState.Value) { case ShippingState.Confirmed: case ShippingState.Creation: case ShippingState.Delayed: case ShippingState.WaitingForCarrierData: case ShippingState.WaitingForConfirmation: if (!CurrentShipping.TruckAwaiting.GetValueOrDefault(false)) { CurrentShipping.ArrivalTime = DateTime.Now; } CurrentShipping.StartTime = DateTime.Now; CurrentShipping.WarehouseStartTime = DateTime.Now; CurrentShipping.ShippingState = ShippingState.Underway; EDC.SubmitChanges(); break; case ShippingState.Underway: case ShippingState.None: case ShippingState.Invalid: case ShippingState.Canceled: case ShippingState.Completed: case ShippingState.Cancelation: default: break; } } catch (Exception ex) { ReportException("EnteredButton_Click", ex); } }
private void m_LeftButton_Click(object sender, EventArgs e) { try { if (CurrentShipping == null) { return; } switch (CurrentShipping.ShippingState.Value) { case ShippingState.Underway: CurrentShipping.EndTime = DateTime.Now; CurrentShipping.ShippingState = ShippingState.Completed; CurrentShipping.ShippingDuration = (CurrentShipping.EndTime.Value - CurrentShipping.StartTime.Value).TotalMinutes; EDC.SubmitChanges(); break; case ShippingState.Confirmed: case ShippingState.Creation: case ShippingState.Delayed: case ShippingState.WaitingForCarrierData: case ShippingState.WaitingForConfirmation: case ShippingState.None: case ShippingState.Invalid: case ShippingState.Canceled: case ShippingState.Completed: case ShippingState.Cancelation: default: break; } } catch (Exception ex) { ReportException("LeftButton_Click", ex); } }