DeliveryMatchView.xaml.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Muchinfo.MTPClient.Data.Model.Delivery;
  2. using Muchinfo.MTPClient.Delivery.ViewModels;
  3. using System;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Input;
  7. using Xceed.Wpf.Toolkit;
  8. namespace Muchinfo.MTPClient.Delivery.Views
  9. {
  10. /// <summary>
  11. /// Description for DeliveryMatchView.
  12. /// </summary>
  13. public partial class DeliveryMatchView : Window
  14. {
  15. public bool occur = false;
  16. /// <summary>
  17. /// Initializes a new instance of the DeliveryMatchView class.
  18. /// </summary>
  19. public DeliveryMatchView(DeliveryEntrustOrder model)
  20. {
  21. InitializeComponent();
  22. this.DataContext = new DeliveryMatchViewModel(model);
  23. }
  24. public void drag_MouseLeftButtonDown(object sender, MouseButtonEventArgs args)
  25. {
  26. this.DragMove();
  27. }
  28. private void SelectQty_KeyDown(object sender, KeyEventArgs e)
  29. {
  30. var txtInput = (DecimalUpDown)sender;
  31. if ((e.Key >= Key.NumPad0 && e.Key <= Key.NumPad9) || (e.Key >= Key.D0 && e.Key <= Key.D9))
  32. {
  33. e.Handled = false;
  34. }
  35. else if ((e.Key == Key.Decimal || e.Key == Key.OemPeriod))
  36. {
  37. e.Handled = false;
  38. }
  39. else
  40. {
  41. e.Handled = true;
  42. }
  43. if (txtInput.Text.Contains(".") && txtInput.Text.Length >= 8)
  44. {
  45. e.Handled = true;
  46. }
  47. else if (!txtInput.Text.Contains(".") && txtInput.Text.Length >= 6)
  48. {
  49. e.Handled = true;
  50. }
  51. }
  52. private bool IsNumberKey(Key inKey)
  53. {
  54. if (inKey < Key.D0 || inKey > Key.D9)
  55. {
  56. if (inKey < Key.NumPad0 || inKey > Key.NumPad9)
  57. {
  58. return false;
  59. }
  60. }
  61. return true;
  62. }
  63. private bool IsDelOrBackspaceOrTabKey(Key inKey)
  64. {
  65. return inKey == Key.Delete || inKey == Key.Back || inKey == Key.Tab;
  66. }
  67. private string LeaveOnlyNumbers(String inString)
  68. {
  69. occur = false;
  70. StringBuilder ans = new StringBuilder();
  71. for (int i = 0; i < inString.Length; ++i)
  72. {
  73. if (System.Text.RegularExpressions.Regex.IsMatch(inString[i].ToString(), "^[0-9\\.]*$"))
  74. {
  75. if (inString[i] == '.')
  76. {
  77. if (!occur)
  78. {
  79. occur = true;
  80. ans.Append(inString[i]);
  81. }
  82. }
  83. else ans.Append(inString[i]);
  84. }
  85. }
  86. return ans.ToString();
  87. }
  88. }
  89. }