| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191 |
- //
- // ScanModelListCell.m
- // HMLG Scan Order
- //
- // Created by Rui Zhang on 3/17/22.
- // Copyright © 2022 United Software Applications, Inc. All rights reserved.
- //
- #import "ScanModelListCell.h"
- #import "RAConvertor.h"
- #import "RAUtils.h"
- #import "RASingleton.h"
- #define NUMBERS @"0123456789\n"
- @implementation ScanModelListCell
- //- (IBAction)stepChange:(id)sender {
- // self.editQTY.text = [NSString stringWithFormat:@"%d",(int)((UIStepper*)sender).value ];
- //// self.pre_val =(int)((UIStepper*)sender).value;
- //}
- - (void)awakeFromNib {
- [super awakeFromNib];
- // self.editQTY.delegate = self;
- // _editQTY.delegate = self;
- // Initialization code
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (void)setModelJson:(NSMutableDictionary *)modelJson
- {
- _modelJson = modelJson;
-
-
- _labelModel.text=_modelJson[@"model"];
- _labelDescription.text=_modelJson[@"description"];
- _labelDimension.text=_modelJson[@"dimension"];
- _labelCuft.text=_modelJson[@"unit_cuft"];
- _labelOrigin.text=_modelJson[@"origin"];
- _labelPort.text=_modelJson[@"port"];
-
- NSString * cell_price;
- if(RASingleton.sharedInstance.price_type==1)
- {
- // if(_modelJson [@"net_price"])
- cell_price=_modelJson[@"price3"];
- // jitem[@"unit_price"] =jitem[@"price3"];
- // jitem[@"erp_unit_price"] =jitem[@"price3"];
- // else if(_modelJson [@"special_price"])
- // {
- // unit_price= _modelJson[@"price2"];
- // }
- // else
- // {
- // unit_price= _modelJson[@"price1"];
- // }
- }
- else
- {
- cell_price=_modelJson[@"price0"];
- // jitem[@"unit_price"] =jitem[@"price0"];
- // jitem[@"erp_unit_price"] =jitem[@"price0"];
- }
-
-
- if([_modelJson[@"price0"] isEqualToString:@"N/A"])
- _labelPriceCTNR.text=_modelJson[@"price0"];
- else
- _labelPriceCTNR.text=[RAConvertor currencyNumber:[_modelJson[@"price0"] floatValue]];
-
- if([cell_price isEqualToString:@"N/A"])
- _labelPriceNCA.text=cell_price;//_modelJson[@"unit_price"];
- else
- _labelPriceNCA.text=[RAConvertor currencyNumber:[cell_price floatValue]];
- _labelPrice25p.text=_modelJson[@"price2"];
- _labelAvailable.text=_modelJson[@"available"];
- _editQTY.text=[_modelJson[@"count"] stringValue];
-
- int c =[_modelJson[@"count"] intValue];
- int s =[_modelJson[@"stockUom"] intValue];
- [self init_Stepper:s max:9999 min:0 value:c];
- }
- -(void) init_Stepper:(int) step max:(int) max min:(int)min value:(int)value
- {
-
- // [self.stepper becomeFirstResponder];
- if(self.steper!=nil)
- {
- // if(min<=0)
- // min=1;
- if(step<=0)
- step=1;
- self.steper.minimumValue= min;
-
-
-
- self.steper.stepValue= step;
-
- self.steper.value= value;
-
-
-
- // [self.qtystepper addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];
-
-
- }
- }
- //
- //#pragma mark textField delegate
- //
- //- (BOOL)textFieldShouldReturn:(UITextField *)textField {
- // [textField resignFirstResponder];
- // return NO;
- //}
- //-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
- //
- //
- //// DebugLog(@"text:%@",textField.text);
- //
- //
- //
- // NSCharacterSet *cs;
- // cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS]invertedSet];
- //
- // NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
- //
- // BOOL canChange = [string isEqualToString:filtered];
- //
- //
- //
- //
- // return canChange;
- //}
- //- (void)textFieldDidEndEditing:(UITextField *)textField
- //{
- //
- //
- //// AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
- // int qty = [textField.text intValue];
- //
- // if(qty==0)
- // qty=self.steper.minimumValue;
- //
- //
- //// if ((int)qty % (int)self.stepper.stepValue != 0) {
- //// UIViewController* vc=[RAUtils getViewController :self];
- //// [((CartViewController *)vc).itemListTable reloadData];
- //// [RAUtils message_alert:[NSString stringWithFormat:@"Sold in quantities of %d",(int)(self.stepper.stepValue)] title:@"Change Model Count" controller:vc];
- //// return;
- //// }
- ////
- //
- // int c=qty;
- //
- // int m=c%(int)(self.steper.stepValue);
- // if(m!=0)
- //
- // {
- // [RAUtils message_alert:[NSString stringWithFormat:@"QTY must be a multiple of %d",(int)self.steper.stepValue] title:@"Warrning" controller:[RAUtils getViewController:self]];
- // textField.text = [NSString stringWithFormat:@"%d",self.pre_val];
- // }
- //
- // self.pre_val = qty;
- //
- //
- //
- //
- //
- //
- //
- //
- //}
- //
- //- (void)textFieldDidBeginEditing:(UITextField *)textField
- //{
- // NSString* text = textField.text;
- // if(text.length==0)
- // text=@"0";
- // self.pre_val = [textField.text intValue];
- //
- // // self.last_edit = textField.text;
- //}
- @end
|