NumToButtonIsEnabledConvert.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Data;
  6. namespace Muchinfo.MTPClient.Infrastructure.Converters
  7. {
  8. public class NumToButtonIsEnabledConvert : IValueConverter
  9. {
  10. public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  11. {
  12. //pValue_hValue_countNum//pValue确认票给付,hValue确认货给付,countNum交割单号数量
  13. string[] result = value.ToString().Split(',');
  14. if (result.Count() > 2)
  15. {
  16. if (result[2] != null && result[1] != null && result[0] != null)
  17. {
  18. //pValue_hValue默认不填写的情况
  19. if (int.Parse(result[0].ToString()) == 0 && int.Parse(result[1].ToString()) == 0)
  20. {
  21. if (int.Parse(result[0].ToString()) == 2)
  22. {
  23. return false;
  24. }
  25. else
  26. {
  27. return true;
  28. }
  29. }
  30. else
  31. {
  32. #region 默认填写的情况判断
  33. if ((int.Parse(result[0].ToString()) == 100 || int.Parse(result[1].ToString()) == 100) && int.Parse(result[2].ToString()) == 1)
  34. {
  35. return false;
  36. }
  37. else if ((int.Parse(result[0].ToString()) != 100 && int.Parse(result[1].ToString()) != 100) && int.Parse(result[2].ToString()) == 2)
  38. {
  39. return false;
  40. }
  41. else
  42. {
  43. return true;
  44. }
  45. #endregion
  46. }
  47. }
  48. }
  49. return false;
  50. }
  51. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  52. {
  53. throw new NotImplementedException();
  54. }
  55. }
  56. }