private void SelectContract(object sender, SelectionChangedEventArgs e) { // Populates text boxes with current information except for the Carrier, which will be selected from a dropdown list of valid carriers List <Carrier> validCarriers = new List <Carrier>(); DataGrid gd = (DataGrid)sender; dynamic rowView = gd.SelectedItem; if (rowView != null) { txtContractID.Text = rowView.ContractID.ToString(); txtClientName.Text = rowView.Customer.Name; txtJobType.Text = rowView.JobType.ToString(); txtQuantity.Text = rowView.Quantity.ToString(); txtOrigin.Text = rowView.Origin.ToString(); txtDestination.Text = rowView.Destination.ToString(); } TMS.Data.City originCity = (TMS.Data.City)Enum.Parse(typeof(TMS.Data.City), txtOrigin.Text.ToString()); validCarriers = tms.GetCarriersByCity(originCity); listOfCarriers.ItemsSource = validCarriers; listOfCarriers.IsEnabled = true; }
/// <summary> /// This function initiate order and send to the planner for further process /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CreateOrder_Click(object sender, RoutedEventArgs e) { if (!string.IsNullOrEmpty(ClientName.Text) || !string.IsNullOrEmpty(txtDestinationCity.Text) || !string.IsNullOrEmpty(txtOriginCity.Text) || !string.IsNullOrEmpty(JobType.Text) || !string.IsNullOrEmpty(vanType.Text)) { TMS.Data.City city = (TMS.Data.City)Enum.Parse(typeof(TMS.Data.City), txtDestinationCity.Text); contract.Destination = city; contract.Customer = new Customer(); contract.Customer.Name = ClientName.Text; tms.CreateCustomer(contract.Customer); city = (TMS.Data.City)Enum.Parse(typeof(TMS.Data.City), txtOriginCity.Text); contract.Origin = city; JobType job = (JobType)Enum.Parse(typeof(JobType), JobType.Text); contract.JobType = job; VanType van = (VanType)Enum.Parse(typeof(VanType), vanType.Text); contract.VanType = van; contract.Quantity = Convert.ToInt32(Quantity.Text); TMS.Data.Status status = (TMS.Data.Status)Enum.Parse(typeof(TMS.Data.Status), Status.PENDING.ToString()); contract.Status = status; tms.CreateContract(contract); MessageBox.Show("Order Started", "Done", MessageBoxButton.OK, MessageBoxImage.Information); MakeFileEmpty(); Invoice.GenerateInvoice(contract); } else { MessageBox.Show("Please Select an order first !!", "Empty Selection", MessageBoxButton.OK, MessageBoxImage.Error); } }
/*================================================================================================ * Function : UpdateCarrier * Description : This function will updates the Carrier according to the information given by admin * Parameters : object sender: * RoutedEventArgs e: * Returns : Nothing as return type is void * ` ================================================================================================*/ /// <summary> /// This function will updates the Carrier according to the information given by admin /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UpdateCarrier(object sender, RoutedEventArgs e) { if (CheckFields()) { carrier.Name = txtCarrier_Name.Text; TMS.Data.City city = (TMS.Data.City)Enum.Parse(typeof(TMS.Data.City), txtDepot_City.Text); carrier.DepotCity = city; carrier.FtlAvailability = Convert.ToInt32(txtFTL_Avail.Text); carrier.LtlAvailability = Convert.ToInt32(txtLTL_Avail.Text); carrier.FTLRate = Convert.ToInt32(txtFTL_Rate.Text); carrier.LTLRate = Convert.ToInt32(txtLTL_Rate.Text); carrier.ReeferCharge = Convert.ToInt32(txtReefer_Rate.Text); list = tms.SearchCarriers(carrier.Name, txtDepot_City.Text); if (list.Count != 0) { tms.UpdateCarrier(Convert.ToUInt32(cID), carrier); MessageBox.Show("Carrier Updated Successfully ", "Done", MessageBoxButton.OK, MessageBoxImage.Information); GetCarrierList(); MakeFieldEmpty(); } else if (MessageBox.Show("Carrier does not exist !\n Do you want to add ?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Error) == MessageBoxResult.Yes) { tms.CreateCarrier(carrier); MessageBox.Show("Carrier Added Successfully ", "Done", MessageBoxButton.OK, MessageBoxImage.Information); MakeFieldEmpty(); GetCarrierList(); } } }