ScanModelListCell.m 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. //
  2. // ScanModelListCell.m
  3. // HMLG Scan Order
  4. //
  5. // Created by Rui Zhang on 3/17/22.
  6. // Copyright © 2022 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "ScanModelListCell.h"
  9. #import "RAConvertor.h"
  10. #import "RAUtils.h"
  11. #import "RASingleton.h"
  12. #define NUMBERS @"0123456789\n"
  13. @implementation ScanModelListCell
  14. //- (IBAction)stepChange:(id)sender {
  15. // self.editQTY.text = [NSString stringWithFormat:@"%d",(int)((UIStepper*)sender).value ];
  16. //// self.pre_val =(int)((UIStepper*)sender).value;
  17. //}
  18. - (void)awakeFromNib {
  19. [super awakeFromNib];
  20. // self.editQTY.delegate = self;
  21. // _editQTY.delegate = self;
  22. // Initialization code
  23. }
  24. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  25. [super setSelected:selected animated:animated];
  26. // Configure the view for the selected state
  27. }
  28. - (void)setModelJson:(NSMutableDictionary *)modelJson
  29. {
  30. _modelJson = modelJson;
  31. _labelModel.text=_modelJson[@"model"];
  32. _labelDescription.text=_modelJson[@"description"];
  33. _labelDimension.text=_modelJson[@"dimension"];
  34. _labelCuft.text=_modelJson[@"unit_cuft"];
  35. _labelOrigin.text=_modelJson[@"origin"];
  36. _labelPort.text=_modelJson[@"port"];
  37. NSString * cell_price;
  38. if(RASingleton.sharedInstance.price_type==1)
  39. {
  40. // if(_modelJson [@"net_price"])
  41. cell_price=_modelJson[@"price3"];
  42. // jitem[@"unit_price"] =jitem[@"price3"];
  43. // jitem[@"erp_unit_price"] =jitem[@"price3"];
  44. // else if(_modelJson [@"special_price"])
  45. // {
  46. // unit_price= _modelJson[@"price2"];
  47. // }
  48. // else
  49. // {
  50. // unit_price= _modelJson[@"price1"];
  51. // }
  52. }
  53. else
  54. {
  55. cell_price=_modelJson[@"price0"];
  56. // jitem[@"unit_price"] =jitem[@"price0"];
  57. // jitem[@"erp_unit_price"] =jitem[@"price0"];
  58. }
  59. if([_modelJson[@"price0"] isEqualToString:@"N/A"])
  60. _labelPriceCTNR.text=_modelJson[@"price0"];
  61. else
  62. _labelPriceCTNR.text=[RAConvertor currencyNumber:[_modelJson[@"price0"] floatValue]];
  63. if([cell_price isEqualToString:@"N/A"])
  64. _labelPriceNCA.text=cell_price;//_modelJson[@"unit_price"];
  65. else
  66. _labelPriceNCA.text=[RAConvertor currencyNumber:[cell_price floatValue]];
  67. _labelPrice25p.text=_modelJson[@"price2"];
  68. _labelAvailable.text=_modelJson[@"available"];
  69. _editQTY.text=[_modelJson[@"count"] stringValue];
  70. int c =[_modelJson[@"count"] intValue];
  71. int s =[_modelJson[@"stockUom"] intValue];
  72. [self init_Stepper:s max:9999 min:0 value:c];
  73. }
  74. -(void) init_Stepper:(int) step max:(int) max min:(int)min value:(int)value
  75. {
  76. // [self.stepper becomeFirstResponder];
  77. if(self.steper!=nil)
  78. {
  79. // if(min<=0)
  80. // min=1;
  81. if(step<=0)
  82. step=1;
  83. self.steper.minimumValue= min;
  84. self.steper.stepValue= step;
  85. self.steper.value= value;
  86. // [self.qtystepper addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
  87. }
  88. }
  89. //
  90. //#pragma mark textField delegate
  91. //
  92. //- (BOOL)textFieldShouldReturn:(UITextField *)textField {
  93. // [textField resignFirstResponder];
  94. // return NO;
  95. //}
  96. //-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
  97. //
  98. //
  99. //// DebugLog(@"text:%@",textField.text);
  100. //
  101. //
  102. //
  103. // NSCharacterSet *cs;
  104. // cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS]invertedSet];
  105. //
  106. // NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
  107. //
  108. // BOOL canChange = [string isEqualToString:filtered];
  109. //
  110. //
  111. //
  112. //
  113. // return canChange;
  114. //}
  115. //- (void)textFieldDidEndEditing:(UITextField *)textField
  116. //{
  117. //
  118. //
  119. //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
  120. // int qty = [textField.text intValue];
  121. //
  122. // if(qty==0)
  123. // qty=self.steper.minimumValue;
  124. //
  125. //
  126. //// if ((int)qty % (int)self.stepper.stepValue != 0) {
  127. //// UIViewController* vc=[RAUtils getViewController :self];
  128. //// [((CartViewController *)vc).itemListTable reloadData];
  129. //// [RAUtils message_alert:[NSString stringWithFormat:@"Sold in quantities of %d",(int)(self.stepper.stepValue)] title:@"Change Model Count" controller:vc];
  130. //// return;
  131. //// }
  132. ////
  133. //
  134. // int c=qty;
  135. //
  136. // int m=c%(int)(self.steper.stepValue);
  137. // if(m!=0)
  138. //
  139. // {
  140. // [RAUtils message_alert:[NSString stringWithFormat:@"QTY must be a multiple of %d",(int)self.steper.stepValue] title:@"Warrning" controller:[RAUtils getViewController:self]];
  141. // textField.text = [NSString stringWithFormat:@"%d",self.pre_val];
  142. // }
  143. //
  144. // self.pre_val = qty;
  145. //
  146. //
  147. //
  148. //
  149. //
  150. //
  151. //
  152. //
  153. //}
  154. //
  155. //- (void)textFieldDidBeginEditing:(UITextField *)textField
  156. //{
  157. // NSString* text = textField.text;
  158. // if(text.length==0)
  159. // text=@"0";
  160. // self.pre_val = [textField.text intValue];
  161. //
  162. // // self.last_edit = textField.text;
  163. //}
  164. @end