|
|
@@ -7,7 +7,8 @@
|
|
|
//
|
|
|
|
|
|
#import "PortfolioEditQTYViewController.h"
|
|
|
-
|
|
|
+#import "iSalesNetwork.h"
|
|
|
+#define NUMBERS @"0123456789\n"
|
|
|
@interface PortfolioEditQTYViewController ()
|
|
|
|
|
|
@end
|
|
|
@@ -16,14 +17,91 @@
|
|
|
|
|
|
- (void)viewDidLoad {
|
|
|
[super viewDidLoad];
|
|
|
+ self.editQTY.text = [NSString stringWithFormat:@"%d",self.qty];
|
|
|
+ [self requestqty];
|
|
|
// Do any additional setup after loading the view.
|
|
|
}
|
|
|
+- (IBAction)onRefreshClick:(id)sender {
|
|
|
+ [self requestqty];
|
|
|
+}
|
|
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
|
[super didReceiveMemoryWarning];
|
|
|
// Dispose of any resources that can be recreated.
|
|
|
}
|
|
|
+-(void) requestqty
|
|
|
+{
|
|
|
+ self.buttonRefresh.enabled=false;
|
|
|
+ self.labelQueryQTY.text = @"Query current QTY...";
|
|
|
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
|
+
|
|
|
+ NSDictionary* detail_json = [iSalesNetwork request_model_qty:self.fashionid];
|
|
|
+
|
|
|
+ dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
+ self.buttonRefresh.enabled=true;
|
|
|
+// NSDictionary* imgsection = [detail_json objectForKey:@"img_section"];
|
|
|
+ // AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate];
|
|
|
+
|
|
|
+ if([[detail_json valueForKey:@"result"] intValue]==2)
|
|
|
+ {
|
|
|
+
|
|
|
+ NSString* qty = [detail_json valueForKey:@"quantity_available"];
|
|
|
+ self.labelQueryQTY.text = [NSString stringWithFormat:@"Current Available QTY: %@",qty];
|
|
|
+ // self.detailTable.hidden = false;
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
|
|
|
+ {
|
|
|
+ self.labelQueryQTY.text=@"Tap Refresh to query current QTY";
|
|
|
+ [RAUtils message_alert:[detail_json valueForKey:@"err_msg"] title:@"Request Available QTY"/*@"Loading Model Detail Failed."*/ controller:self] ;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|
|
|
+- (IBAction)onSaveClick:(id)sender {
|
|
|
+
|
|
|
+
|
|
|
+// if([self.editDiscount.text floatValue]>100.0)
|
|
|
+// {
|
|
|
+// // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Discount error" message:@"Discount must less than 100" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
|
|
|
+// //
|
|
|
+// //
|
|
|
+// // [alert show];
|
|
|
+//
|
|
|
+// [RAUtils alert_view:@"Fields with * mark cannot be empty." title:@"Some Requried Fields Are Missing."];
|
|
|
+//
|
|
|
+// self.editDiscount.text=@"0";
|
|
|
+//
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// [self update_newprice];
|
|
|
+
|
|
|
+
|
|
|
+ if(self.editQTY.text.length==0)
|
|
|
+ self.qty=0;
|
|
|
+ else
|
|
|
+ self.qty=[self.editQTY.text intValue];
|
|
|
+ [self dismissViewControllerAnimated:NO
|
|
|
+ completion:^{
|
|
|
+ if(self.onSetValue)
|
|
|
+ self.onSetValue( self.qty);
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
+- (IBAction)onCloseClicked:(id)sender {
|
|
|
+ [self dismissViewControllerAnimated:NO
|
|
|
+ completion:^{
|
|
|
+
|
|
|
+
|
|
|
+ }];
|
|
|
+}
|
|
|
/*
|
|
|
#pragma mark - Navigation
|
|
|
|
|
|
@@ -33,5 +111,94 @@
|
|
|
// Pass the selected object to the new view controller.
|
|
|
}
|
|
|
*/
|
|
|
+#pragma mark textField delegate
|
|
|
+- (BOOL)textFieldShouldReturn:(UITextField *)textField {
|
|
|
+ [textField resignFirstResponder];
|
|
|
+ return NO;
|
|
|
+}
|
|
|
+-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ if(textField.text.length==0 && [string isEqualToString:@"."])
|
|
|
+ return false;
|
|
|
+
|
|
|
+ NSCharacterSet *cs;
|
|
|
+ cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS]invertedSet];
|
|
|
+ //
|
|
|
+ NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
|
|
|
+
|
|
|
+ BOOL canChange = [string isEqualToString:filtered];
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ //
|
|
|
+ return canChange;
|
|
|
+ // return true;
|
|
|
+}
|
|
|
+
|
|
|
+//- (void)textFieldDidEndEditing:(UITextField *)textField
|
|
|
+//{
|
|
|
+//
|
|
|
+//// if(textField.tag==2)
|
|
|
+//// {
|
|
|
+//// if(textField.text.length==0)
|
|
|
+//// textField.text=@"0";
|
|
|
+////
|
|
|
+//// if([textField.text floatValue]>100.0)
|
|
|
+//// {
|
|
|
+//// // UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @"Discount error" message:@"Discount must less than 100" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
|
|
|
+//// // // UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error!" message:@"User&Password can not be empty!" delegate:nil cancelButtonTitle:NSLocalizedString(@"ok", nil) , nil];
|
|
|
+//// // [alert show];
|
|
|
+////
|
|
|
+////
|
|
|
+////
|
|
|
+//// [RAUtils alert_view:@"Discount must less than 100." title:@"Input Error."];
|
|
|
+//// textField.text=@"0";
|
|
|
+//// }
|
|
|
+//// }
|
|
|
+//// else
|
|
|
+//// {
|
|
|
+//// float f = [textField.text floatValue];
|
|
|
+//// textField.text=[NSString stringWithFormat:@"%.2f",f];
|
|
|
+//// }
|
|
|
+////
|
|
|
+//// [self update_newprice];
|
|
|
+//
|
|
|
+// // UITableViewCell *cell = (UITableViewCell *) textField.superview.superview;
|
|
|
+// // NSIndexPath * indexPath = [self.editorTable indexPathForCell:cell];
|
|
|
+// //
|
|
|
+// //
|
|
|
+// // NSMutableDictionary* section_json=nil;
|
|
|
+// //
|
|
|
+// //
|
|
|
+// // // NSLog(@"endedit %d_%d",indexPath.section,indexPath.row);
|
|
|
+// // NSMutableDictionary* item_json =[((NSMutableArray*)self.content_data_control[indexPath.section])[indexPath.row] mutableCopy];
|
|
|
+// //
|
|
|
+// //
|
|
|
+// // [item_json setValue:@"true" forKey:@"dirty"];
|
|
|
+// // [item_json setValue:textField.text forKey:@"value"];
|
|
|
+// // section_json = [[self.content_data_download objectForKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]] mutableCopy];
|
|
|
+// // int count=0;
|
|
|
+// //
|
|
|
+// // count=[[section_json valueForKey:@"count"] intValue];
|
|
|
+// //
|
|
|
+// // for(int i=0;i<count;i++)
|
|
|
+// // {
|
|
|
+// // NSDictionary * olditem=[section_json objectForKey:[NSString stringWithFormat:@"item_%d",i ]];
|
|
|
+// // if([[olditem valueForKey:@"name"] isEqualToString:[item_json valueForKey:@"name" ]])
|
|
|
+// // [section_json setObject:item_json forKey:[NSString stringWithFormat:@"item_%d",i ]];
|
|
|
+// //
|
|
|
+// //
|
|
|
+// // }
|
|
|
+// //
|
|
|
+// // [self.content_data_download setObject:section_json forKey:[NSString stringWithFormat:@"section_%ld",(long)indexPath.section ]];
|
|
|
+//}
|
|
|
+//
|
|
|
+//- (void)textFieldDidBeginEditing:(UITextField *)textField
|
|
|
+//{
|
|
|
+// //
|
|
|
+// // self.lastedit = textField;
|
|
|
+//}
|
|
|
|
|
|
@end
|