SubmitOrderCell.m 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. //
  2. // SubmitOrderCell.m
  3. // IBOSSIPAD
  4. //
  5. // Created by iHope on 14-7-18.
  6. // Copyright (c) 2014年 elongtian. All rights reserved.
  7. //
  8. #import "SubmitOrderCell.h"
  9. @interface SubmitOrderCell()<UITextFieldDelegate>
  10. @property(strong) UIButton * btnSelect;
  11. //@property(copy,nonatomic) NSString *hiddenID;
  12. @end
  13. @implementation SubmitOrderCell
  14. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  15. {
  16. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  17. if (self) {
  18. }
  19. return self;
  20. }
  21. -(void)setReadOnly
  22. {
  23. _txtMarkedPrice.enabled=NO;
  24. _txtRemarks.enabled=NO;
  25. _txtSalesPrice.enabled=NO;
  26. _txtSalesQuantity.enabled=NO;
  27. }
  28. -(void)hideSelect
  29. {
  30. _btnSelect.hidden=YES;
  31. }
  32. -(void)awakeFromNib
  33. {
  34. [super awakeFromNib];
  35. _hiddenID=@"";
  36. _btnSelect=[UIButton buttonWithType:UIButtonTypeCustom];
  37. _btnSelect.frame=CGRectMake(10, 151, 63, 63);
  38. [_btnSelect addTarget:self action:@selector(btnGoCheck) forControlEvents:UIControlEventTouchUpInside];
  39. [self.contentView addSubview:_btnSelect];
  40. UIImageView *lineView = [[UIImageView alloc] initWithFrame:CGRectMake(Screen_Width-30, 151, 10, 23)];
  41. lineView.image = [UIImage imageNamed:@"jiantou.png"];
  42. [self.contentView addSubview:lineView];
  43. _lblCartID=[UILabel new];
  44. _lblInventoryID=[UILabel new];
  45. _lblCodeID=[UILabel new];
  46. _lblGradeID=[UILabel new];
  47. _lblWarehouseID=[UILabel new];
  48. _lblBrandID=[UILabel new];
  49. _lblKindID=[UILabel new];
  50. _lblVarietyID=[UILabel new];
  51. _lblSeriesID=[UILabel new];
  52. _lblUnitID=[UILabel new];
  53. _lblGradeName=[UILabel new];
  54. [_txtRemarks removeFromSuperview];
  55. [_txtSalesPrice removeFromSuperview];
  56. [_txtSalesQuantity removeFromSuperview];
  57. [_txtMarkedPrice removeFromSuperview];
  58. [self addSubview:_txtRemarks];
  59. [self addSubview:_txtSalesPrice];
  60. [self addSubview:_txtSalesQuantity];
  61. [self addSubview:_txtMarkedPrice];
  62. // [_txtRemarks addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  63. // [_txtSalesPrice addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  64. // [_txtSalesQuantity addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  65. // [_txtMarkedPrice addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
  66. _txtSalesPrice.keyboardType=UIKeyboardTypeNumberPad;
  67. _txtSalesQuantity.keyboardType=UIKeyboardTypeNumberPad;
  68. _txtMarkedPrice.keyboardType=UIKeyboardTypeNumberPad;
  69. _txtSalesPrice.delegate=self;
  70. _txtSalesQuantity.delegate=self;
  71. _txtMarkedPrice.delegate=self;
  72. _txtRemarks.delegate=self;
  73. _txtSalesPrice.tag=1001;
  74. _txtSalesQuantity.tag=1002;
  75. _txtRemarks.tag=1003;
  76. _txtMarkedPrice.tag=1004;
  77. }
  78. - (void)textFieldDidBeginEditing:(UITextField *)textField
  79. {
  80. }
  81. - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  82. {
  83. NSCharacterSet *cs;
  84. if(textField == _txtSalesQuantity)
  85. {
  86. cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERSANDDOT] invertedSet];
  87. NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
  88. BOOL basicTest = [string isEqualToString:filtered];
  89. if(!basicTest)
  90. {
  91. return NO;
  92. }
  93. }
  94. if(textField == _txtSalesPrice)
  95. {
  96. cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERSANDDOT] invertedSet];
  97. NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
  98. BOOL basicTest = [string isEqualToString:filtered];
  99. if(!basicTest)
  100. {
  101. return NO;
  102. }
  103. }
  104. if(textField == _txtMarkedPrice)
  105. {
  106. cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERSANDDOT] invertedSet];
  107. NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
  108. BOOL basicTest = [string isEqualToString:filtered];
  109. if(!basicTest)
  110. {
  111. return NO;
  112. }
  113. }
  114. //其他的类型不需要检测,直接写入
  115. return YES;
  116. }
  117. //编辑回調
  118. //- (void) textFieldDidChange:(id) sender {
  119. // UITextField *field = (UITextField *)sender;
  120. // if(field.text.length==0)return;
  121. //
  122. // else if(field.tag==1001 ||field.tag==1002||field.tag==1003||field.tag==1004){
  123. // if([self.delegate respondsToSelector:@selector(textValueChange: txtField:)])
  124. // {
  125. // [self.delegate textValueChange:self txtField:field];
  126. //
  127. // }
  128. // }
  129. //
  130. //}
  131. - (void) textFieldDidEndEditing:(UITextField *) field
  132. {
  133. if(field.tag==1001 ||field.tag==1002||field.tag==1003||field.tag==1004){
  134. // if([self.delegate respondsToSelector:@selector(textValueChange: txtField:)])
  135. // {
  136. // [self.delegate textValueChange:self txtField:field];
  137. //
  138. // }
  139. }
  140. }
  141. -(void)ParseInfoModel:(ShopCartItemModel *)model
  142. {
  143. _hiddenID=model.CartID;
  144. _lblCartID.text=[NSString stringWithFormat:@"%@", model.CartID ];
  145. _lblInventoryID.text=[NSString stringWithFormat:@"%@", model.InventoryID ];
  146. _txtSalesQuantity.text=[NSString stringWithFormat:@"%@", model.SalesQuantity ];
  147. _txtSalesPrice.text=[NSString stringWithFormat:@"%@", model.SalesPrice ];
  148. _txtMarkedPrice.text=[NSString stringWithFormat:@"%@", model.MarkedPrice ];
  149. _txtRemarks.text=[NSString stringWithFormat:@"%@", model.Remarks ];
  150. _lblSpecification.text=[NSString stringWithFormat:@"%@", model.Specification ];
  151. _lblAcreage.text=[NSString stringWithFormat:@"%@", model.Acreage ];
  152. _lblVolume.text=[NSString stringWithFormat:@"%@", model.Volume ];
  153. _lblCodeID.text=[NSString stringWithFormat:@"%@", model.CodeID ];
  154. _lblCode.text=[NSString stringWithFormat:@"%@", model.Code ];
  155. _lblOnlyCode.text=[NSString stringWithFormat:@"%@", model.OnlyCode ];
  156. _lblGradeID.text=[NSString stringWithFormat:@"%@", model.GradeID];
  157. _lblColorNumber.text=[NSString stringWithFormat:@"%@", model.ColorNumber ];
  158. _lblWarehouseID.text=[NSString stringWithFormat:@"%@", model.WarehouseID];
  159. _lblPositionNumber.text=[NSString stringWithFormat:@"%@",model.PositionNumber ];
  160. _lblWarehouseName.text=[NSString stringWithFormat:@"%@",model.WarehouseName ];
  161. _lblBalanceQuantity.text=[NSString stringWithFormat:@"%@",model.BalanceQuantity ];
  162. _lblBrandID.text=[NSString stringWithFormat:@"%@", model.BrandID];
  163. _lblBrandName.text=[NSString stringWithFormat:@"%@",model.BrandName ];
  164. _lblKindID.text=[NSString stringWithFormat:@"%@",model.KindID];
  165. _lblKindName.text=[NSString stringWithFormat:@"%@", model.KindName ];
  166. _lblVarietyID.text=[NSString stringWithFormat:@"%@",model.VarietyID];
  167. _lblVarietyName.text=[NSString stringWithFormat:@"%@", model.VarietyName ];
  168. _lblSeriesID.text=[NSString stringWithFormat:@"%@",model.SeriesID];
  169. _lblSeriesName.text=[NSString stringWithFormat:@"%@", model.SeriesName ];
  170. _lblUnitID.text=[NSString stringWithFormat:@"%@",model.UnitID];
  171. _lblUnitName.text=[NSString stringWithFormat:@"%@", model.UnitName ];
  172. _lblGradeName.text=[NSString stringWithFormat:@"%@",model.GradeName ];
  173. }
  174. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  175. {
  176. [super setSelected:selected animated:animated];
  177. }
  178. -(void)btnGoCheck
  179. {
  180. // if([self.delegate respondsToSelector:@selector(btnCheckPressed:)])
  181. // {
  182. // [self.delegate btnCheckPressed:self];
  183. //
  184. // }
  185. }
  186. - (void) setCheckBackground: (BOOL) checked
  187. {
  188. if(!checked)
  189. {
  190. _isSelect=NO;
  191. [_btnSelect setImage:[UIImage imageNamed:@"shenpiweixuanzhong.png"] forState:UIControlStateNormal];
  192. _btnSelect.imageEdgeInsets=UIEdgeInsetsMake(18,18,20,20.5);
  193. }
  194. else
  195. {
  196. _isSelect=YES;
  197. [_btnSelect setImage:[UIImage imageNamed:@"shenpixuanzhong.png"] forState:UIControlStateNormal];
  198. _btnSelect.imageEdgeInsets=UIEdgeInsetsMake(18,18,20,20.5);
  199. }
  200. }
  201. -(void) gotoDetail:(id)sender
  202. {
  203. // if([self.delegate respondsToSelector:@selector(showCartInfoDetail:)])
  204. // {
  205. // [self.delegate showCartInfoDetail:_cellIndex];
  206. //
  207. // }
  208. }
  209. @end