private void btn_click_add(object sender, RoutedEventArgs e) { lbl_msg.Content = ""; try { string address = validateTxtInput(txt_address.Text, lbl_address.Content.ToString()); string city = validateTxtInput(txt_city.Text, lbl_city.Content.ToString()); string state = validateCombobox(combox_1_states.SelectedIndex, combox_1_states.SelectionBoxItem.ToString(), lbl_city.Content.ToString()); string zip = validateTxtInput(txt_zip.Text, lbl_zip.Content.ToString()); Shippment shippment = new Shippment(new_shippment_arrival_date, new_shippment_package_id, address, city, state, zip); shippmentsList.Add(shippment); btn_add.IsEnabled = false; btn_scan.IsEnabled = true; if (shippmentsList.Count >= 1) { btn_back.IsEnabled = true; btn_next.IsEnabled = true; } btn_remove.IsEnabled = true; btn_edit.IsEnabled = true; cur_pos = shippmentsList.Count - 1; lbl_msg.Content = "Shippmment has been added to list"; } catch (Exception ex) { lbl_msg.Content = ex.Message; } }
public void prevShippment() { if (shippmentsList.Count > 0) { if (cur_pos > 0) { cur_pos = cur_pos - 1; } Shippment shippment = shippmentsList[cur_pos]; txt_arrival_date.Text = (shippment.ArrivedAt).ToString("MM-dd-yyyy HH:mm:ss"); txt_package_id.Text = (shippment.PackageId).ToString(); txt_address.Text = shippment.Address; txt_city.Text = shippment.City; combox_1_states.SelectedValue = shippment.State; txt_zip.Text = shippment.Zip; } }
private void btn_click_edit(object sender, RoutedEventArgs e) { lbl_msg.Content = ""; if (cur_pos >= 0) { try { Shippment shippment = shippmentsList[cur_pos]; shippment.Address = validateTxtInput(txt_address.Text, lbl_address.Content.ToString()); shippment.City = validateTxtInput(txt_city.Text, lbl_city.Content.ToString()); shippment.State = validateCombobox(combox_1_states.SelectedIndex, combox_1_states.SelectionBoxItem.ToString(), lbl_city.Content.ToString()); shippment.Zip = validateTxtInput(txt_zip.Text, lbl_zip.Content.ToString()); lbl_msg.Content = "Shippmment has Edited"; } catch (Exception ex) { lbl_msg.Content = ex.Message; } } }