/// <summary> /// Deprecated Method for adding a new object to the RailCarCurrentStatus EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRailCarCurrentStatus(RailCarCurrentStatu railCarCurrentStatu) { base.AddObject("RailCarCurrentStatus", railCarCurrentStatu); }
private void save_Click(object sender, RoutedEventArgs e) { var selectedCar = autoCompleteBox1.SelectedItem as TrainTracker.Web.Models.RailCar; if (selectedCar == null) { MessageBox.Show("Car is not in System.\nPlease Enter a 'New Car'"); return; } var context = new RailServeDS(); InvokeOperation<int> InvokeOp = context.GetRailCarsByNumber(selectedCar.Number); InvokeOp.Completed += (ss, ee) => { int carInSystem = InvokeOp.Value; if(carInSystem < 1) { MessageBox.Show("Car is not in System. Please enter a 'New Car from next tab'"); return; } else { Random key = new Random(); var currentStatus = new RailCarCurrentStatu(); currentStatus.CurrentStatusID = key.Next(0, 99999999); var selectedStatus = loadComboBox.SelectedItem as TrainTracker.Web.Models.CarLoadStatu; var selectedComm = commComboBox.SelectedItem as TrainTracker.Web.Models.Commodity; var selectedDepartment = departmentComboBox.SelectedItem as TrainTracker.Web.Models.Department; var selectedTrack = trackComboBox.SelectedItem as TrainTracker.Web.Models.Track; currentStatus.LocationID = myLocation; currentStatus.YardID = (int)selectedTrack.YardId; currentStatus.StatusId = selectedStatus.StatusID; currentStatus.CommodityId = selectedComm.CommodityID; currentStatus.CarID = selectedCar.CarID; currentStatus.TrackId = selectedTrack.TrackID; currentStatus.PrimaryUser = WebContext.Current.User.Name; currentStatus.Demurrage = checkBox1.IsChecked; currentStatus.Company = company.Text; currentStatus.DepartmentId = selectedDepartment.DepartmentID; currentStatus.ReceiptDate = date.DisplayDate; currentStatus.ReceiptTime = (DateTime)time.Value; currentStatus.MovementDate = DateTime.Today; if(weight.Text != null || weight.Text !="") { int we; if (Int32.TryParse(weight.Text, out we)) currentStatus.Weight = we; else { MessageBox.Show("Weight is not a valid Numeric field"); return; } } currentStatus.Supplier = supplier.Text; currentStatus.Comments = comments.Text; currentStatus.HistoryTypeId = 1; //HistoryType is stored in db to distinguish movement types if (railCarCurrentStatuDomainDataSource.DataView.CanAdd == false) railCarCurrentStatuDomainDataSource.Load(); railCarCurrentStatuDomainDataSource.DataView.Add(currentStatus); if (railCarCurrentStatuDomainDataSource.HasChanges) { railCarCurrentStatuDomainDataSource.SubmitChanges(); MessageBox.Show("Car: " +selectedCar.Number + " is now is your yard!"); save.IsEnabled = false; } } }; }
/// <summary> /// Create a new RailCarCurrentStatu object. /// </summary> /// <param name="currentStatusID">Initial value of the CurrentStatusID property.</param> /// <param name="carID">Initial value of the CarID property.</param> /// <param name="yardID">Initial value of the YardID property.</param> /// <param name="departmentId">Initial value of the DepartmentId property.</param> /// <param name="historyTypeId">Initial value of the HistoryTypeId property.</param> public static RailCarCurrentStatu CreateRailCarCurrentStatu(global::System.Int32 currentStatusID, global::System.Int32 carID, global::System.Int32 yardID, global::System.Int32 departmentId, global::System.Int32 historyTypeId) { RailCarCurrentStatu railCarCurrentStatu = new RailCarCurrentStatu(); railCarCurrentStatu.CurrentStatusID = currentStatusID; railCarCurrentStatu.CarID = carID; railCarCurrentStatu.YardID = yardID; railCarCurrentStatu.DepartmentId = departmentId; railCarCurrentStatu.HistoryTypeId = historyTypeId; return railCarCurrentStatu; }