2 Replies - 663 Views - Last Post: 29 August 2014 - 02:01 AM Rate Topic: -----

#1 martynball  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 128
  • Joined: 21-July 14

Design Question, displaying multiple images and adding sales to them.

Posted 28 August 2014 - 09:26 AM

My application requires the user to add sales to images, this is done by displaying the image for the GUI, and then the user would add sales using that images ID which is brought in from the database.

In part this is 2 questions, first question is what is the best way to generate a List for use when adding the sales to the database. The List would need multiple strings for each sale. So for example:

Image 1 (Sale)
- JPG ID
- Product ID
- Product Quantity



So i'm going to assume i'm best creating a new instance of a custom class for each sale, and then add each instance to a List<Sale>?

public class Sale
{
    public int SaleID { get; set; }
    public int JpgID { get; set; }
    public int SaleQty { get; set; }
}



Then I need a decent way to update this List with the GUI controls. So maybe get the JPG ID and set name of the Sale Class Instance to the ID, in this way its unique and I can update that instance when it comes to increasing the sale of a product or decreasing it.

-----

Second part comes to the design of the GUI of adding sales, when I made this using HTML/PHP that was easier. It looked something like this:
Posted Image

If I wrote some code to generate that kind of design again in C# it going to require many Controls, wouldn't that be a bit intensive on the system? Any ideas would be great, I just want something which looks great but also functions good.

At some point I'm going to switch to WPF, but I just need to get a working prototype working now which my client can use, and then update it when I have more time as I have got other Web Related projects that need doing, so at the moment WPF is out of the question.

This post has been edited by martynball: 28 August 2014 - 09:29 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Design Question, displaying multiple images and adding sales to them.

#2 optix212  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 30
  • View blog
  • Posts: 540
  • Joined: 10-October 09

Re: Design Question, displaying multiple images and adding sales to them.

Posted 28 August 2014 - 01:28 PM

You aren't going to make anything that looks that good in WinForms unless you're up for a crapload of work. You should switch to WPF now, while you have the chance. It looks like you're trying to make a full-production project on a framework that was at its peak 15 years ago. You should update first, if you want people to take your software seriously.

Now, with that said, your first assumption is correct. You always want to have a List or some other type of collection that holds all of your database data. You should never have to access data directly from a control. That is bad practice.

For keeping track of how to update your list, I would say you have 2 choices:

You could do it your way, iterate over every Sale in your list and see if the ID matches your JPG ID.

Or, when you actually add the Sale to the list, you could get its index within the list and assign the ID of the jpg to that index, then access it from its original index. Either way works fine enough. The second option might be just a tid bit more efficient since you wouldn't require iteration.

This post has been edited by optix212: 28 August 2014 - 01:29 PM

Was This Post Helpful? 0
  • +
  • -

#3 martynball  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 128
  • Joined: 21-July 14

Re: Design Question, displaying multiple images and adding sales to them.

Posted 29 August 2014 - 02:01 AM

Reading up on WPF now, will make the change!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1