crecode.com

Displaying the Products for Sale and Updating the Stock in Software Receive bar code 39 in Software Displaying the Products for Sale and Updating the Stock




How to generate, print barcode using .NET, Java sdk library control with example project source code free download:
Displaying the Products for Sale and Updating the Stock use software code 39 generation toencode ansi/aim code 39 on software RFID The performfetch is executed Software Code39 to retrieve the managed object context from the persistent store. We remove the keyboard (when desired products are displayed through table view) by informing the Search Bar to resign the first responder status, which will cause the keyboard to go away. Recall that NSPredicate is used for applying the condition on the kind of entities to be retrieved.

. // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIn dexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdent ifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyl eDefault reuseIdentifier:CellIdentifier] autorelease]; cell.

accessoryType=UITableViewCellAccessoryDisclosureIndicator; } // Configure the cell. NSManagedObject *managedObject = [fetchedResultsController objectAtIndexPath:indexPath]; cell.textLabel.

text = [[managedObject valueForKey:@"itemname"] description]; UIImage *pimage=[managedObject valueForKey:@"image"]; CGSize size=pimage.size; CGFloat ratio = 0; if (size.width > size.

height) { ratio = 44.0 / size.width; } else { ratio = 44.

0 / size.height; } CGRect rect = CGRectMake(0.0, 0.

0, ratio * size.width, ratio * size. height); UIGraphicsBeginImageContext(rect.

size); [pimage drawInRect:rect]; cell.imageView.image=UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return cell; }.

[ 286 ]. 11 . In the cellForRowAtIndexPath USS Code 39 for None method, we retrieve the managed object from the Fetched Results Controller by just calling objectAtIndexPath: on the fetched results controller and pass in the indexPath parameter. The fetchedResultsController will return the desired objects for each table cell. To display text (item name) in the table cell, we use valueForKey (key value method used for retrieving attribute values) to retrieve the contents in the itemname attribute of the managed object.

As we want to display the master product image (also) to the left of the master product name in the table view cell, we retrieve the image from the image attribute of the managed object and temporarily assign it to an UIImage instance: pimage. The image assigned to a pimage instance has to be scaled down to accommodate in the table cell. For displaying the image in the "pimage" instance within the defined size of the frame (of a window), we configure the drawing environment, that is, we create a bitmap-based graphics context using the UIGraphicsBeginImageContext() function.

In the UIGraphicsBeginImageContext() function, we specify the size of the frame within which we want the image to appear. Once the context is created, we retrieve the image based on the contents of the current context (using the UIGraphicsGetImageFromCurrentimageContext()) and assign it to the imageView of the table cell for display. When our job is over, we clean up the bitmap drawing environment (that we created with UIGraphicsBeginImageContext()) and remove the graphics context (from the top of the context stack) using the UIGraphicsEndImageContext() function.

. - (void)tableView:(UITableVi ew *)tableView didSelectRowAtIndexPath:(NS IndexPath *)indexPath { AddProductController *addprodController =[[AddProductController alloc] initWithNibName:@"AddProductController" bundle:nil]; MasterProduct *selectedprod=(MasterProduct *) [fetchedResultsController objectAtIndexPath:indexPath]; addprodController.mastprod=selectedprod; addprodController.cust=cust; [self.

navigationController pushViewController:addprodController animated:YES]; [addprodController release]; }. [ 287 ]. Displaying the Products for Sale and Updating the Stock In the didSelectRowAtIndexPa Software Code-39 th method that is invoked when any product is selected from the tableView, we write code to navigate to the View of the AddProductController class that displays the information (itemname, price, and image) of the selected product (automatically retrieved from the MasterProduct"s table) and prompts the user to enter the quantity of the selected product that is sold to the customer. We create and initialize an instance of the AddProductController class with the name: addprodController. We make use of alloc to create the view controller object and initialize it.

The init method specifies the name of the NIB file that has to be loaded by the controller (AddProductController) followed by the bundle where the NIB file is expected to be found. The bundle parameter is set to nil as we want the method to look for the NIB file in the main bundle. The initWithNibName method allows initializing a UIViewController"s view from a NIB file rather than from the code.

This method is preferred when the view of the view controller exists in the NIB and we want to initialize that view controller, that is, we are interested in loading a view from a NIB file. In this method, we also retrieve a managed object context from the fetchedResultsController. The managed object context is retrieved from the fetchedResultsController (it is the object that is returned by calling objectAtIndexPath on the fetched results controller and passing in the indexPath parameter to it) and is assigned to an instance: selectedprod of the MasterProduct class.

That is, the information of the product whose item name is selected from the table view is assigned to the selectedprod instance. The contents of the selectedprod instance are assigned to the mastprod object of addprodController (instance of the AddProductController class) as we want the information (itemname, price, and image) of the selected product to be displayed via the Text Field and ImageView control placed in the View of the AddProductController class. The view controller instance: addprodController is then pushed on the navigation stack causing the view of the AddProductController to be displayed; this also updates the navigation controls to reflect the changes.

The animated attribute is set to Yes to display the view (associated with the AddProductController) with animation effect.. - (NSFetchedResultsControlle r *)fetchedResultsController { if (fetchedResultsController != nil) { return fetchedResultsController; } probAppDelegate *appDelegate = (probAppDelegate *)[[UIApplication sharedApplication] delegate]; NSManagedObjectContext *context = [appDelegate managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity:[NSEntityDescription entityForName:@"MasterProduct" inManagedObjectContext:context]];. [ 288 ]. 11 NSSortDescriptor *sortDe scriptor = [[NSSortDescriptor alloc] initWithKey:@"itemname" ascending:YES]; NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil]; [fetchRequest setSortDescriptors:sortDescriptors]; NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fet chRequest managedObjectContext:context sectionNameKeyPath:nil cacheName:@"Root"]; aFetchedResultsController.delegate = self; self.fetchedResultsController = aFetchedResultsController; [aFetchedResultsController release]; return fetchedResultsController; } ( ) @end.

In the fetchedResultsControl USS Code 39 for None ler method, we retrieve the managed object context from the application delegate. Now, on selecting the Add button from the toolbar of the product menu, we should be navigated to the view of the SearchProductController class that will display the information (itemname, price, and image) of all the products available for sale from the MasterProduct entity along with the search facility. So, let"s go ahead and see how the SearchProductController can be invoked from the product menu.

. As we want to navigate to th e view of the SearchProductController class on selecting the Add button from the product menu, we need to modify the code of the addproduct method of the implementation file of the ProductInfoController class, that is, ProductInfoController.m. Recall that the product menu is displayed through the ProductInfoController class.

The implementation file, ProductInfoController.m may be modified to appear as shown next. Only the modified code is shown next.

For the complete code, refer to the code bundle of this chapter..
Copyright © crecode.com . All rights reserved.