Need some WinForms and DataSet advice - winforms

Here's the story: I've been working on putting together an app in VS10 using Windows Forms in C++. This is my first experience with winforms, although I have a fair amount of experience with C++ and have worked with MFC a bit. The program needs to aquire data input from a hardware measurement system and the backend for that is mostly worked out. What I've been a bit stuck on is how to easily work with displaying this data in forms with the DataGridView and Chart objects. I'd also like to be able to save various sets of data and the programs current settings to disk that can be easily recalled and displayed in the program at a later point.
The solution I've been attempting so far has been to create a DataSet object for a certain program instance which holds some DataTables for the data and current settings. This is easily saved and read to XML files using the DataSet methods, which is nice. The tricky part for me using this method has been trying to sync up the program's display data and settings in the DataGridViews and Charts. It seems like these controls are really meant to be designed through the GUI. Maybe I'm just a noob, but I couldn't figure out how to get the DataSet I designed to link with my Charts using the "Add Project data source" dialog, so instead I set up a bindingSource and then proceeded to set Chart settings manually in the code. That's been getting hairy pretty quickly.
What would you have done to implement this, and how would you advise proceeding? I'm sure there has to be a much simpler way of doing this.

I've used Microsoft Chart Controls to display data from hardware measurement systems before with good results.
We store our data separately in arrays and when we want to display something, just call the AddXY function on the items to add a point. Configuring the graph in the first place is more easily done in designer though. Have a look at the samples for more info.

Related

Howto programmatically create a PDF from a predesigned template made in InDesign

The goal is to design beautiful templates in InDesign, which are then being used to programmatically generate printable PDFs within a special application connected to a database, so I can fill data from the database into the templates.
I have no idea how to approach this. I found a lot of HTML to PDF conversion related info, but that approach has its limitations.
Did anybody face the same question and might point me in the right direction?
Yes, the scenario you described can be fully handled by InDesign Scripting using ExtendScript. I have done this in the past several times and it works quite well. The key in my opinion is to have a designer prepare the file for you as finished as possible and make good use of the built in InDesign automations. That means they will do the layout, but also set up all the paragraph styles, character styles, object styles and possibly grep styles as well as master spreads for each different page.
Then the job of the script that you run will mostly be to fill in the contents and to assign the mentioned styles and master spread as needed. If everything is set up properly, most of the layout should fall into place automatically.
Also, contrary to the comments to your question, I don't think you need InDesign server for that. Especially if you run everything locally anyways.

CakePHP Beginner: Advice needed, Everything on a single view or multi part forms

Thanks in advance for any help offered and patience for my current web-coding experience.
Background:
I'm currently attempting to develop an web based application for my family's business. There is a current version of this system I have developed in C#, however I want to get the system web-based and in the process learn cakephp and the MVC pattern.
Current problem:
I'm currently stuck in a controller that's supposed to take care of a PurchaseTicket. This ticket will have an associated customer, line items, totals etc. I've been trying to develop a basic 'add()' function to the controller however I'm having trouble with the following:
I'm creating a view with everything on it: a button for searching customer, a button to add line items, and a save button. Since I'm used to developing desktop applications, I'm thinking that I might be trying to transfer the same logic to web-based. Is this something that would be recommended or do'able?
I'm running into basic problems like 'searching customer'. From the New Ticket page I'm redirecting to the customer controller, searching and then putting result in session variable or posting it back, but as I continue my process with the rest of the required information, I'm ending up with a bit of "spaghetti" code. Should I do a multi part form? If I do I break the visual design of the application.
Right now I ended up instantiating my PurchaseTicket model and putting it in a session variable. I did this to save intermediate data however I'm not sure if instantiating a Model is conforming to cakephp standards or MVC pattern.
I apologize for the length, this is my first post as a member.
Thanks!
Welcome to Stack Overflow!
So it sounds like there's a few questions, all with pretty open-ended answers. I don't know if this will end up an answer as such, but it's more information than I could put in a comment, so here I go:
First and foremost, if you haven't already, I'd recommend doing the CakePHP Blog Tutorial to get familiar with Cake, before diving straight into a conversion of your existing desktop app.
Second, get familiar with CakePHP's bake console. It will save you a LOT of time if you use it to get started on the web version of your app.
I can't stress how important it is to get a decent grasp of MVC and CakePHP on a small project before trying to tackle something substantial.
Third, the UI for web apps is definitely different to desktop apps. In the case of CakePHP, nothing is 'running' permanently on the server. The entire CakePHP framework gets instantiated, and dies, with every single page request to the server. That can be a tricky concept when transitioning from desktop apps, where everything is stored in memory, and instances of objects can exist for as long as you want them to. With desktop apps, it's easier to have a user go and do another task (like searching for a customer), and then send the result back to the calling object, the instance of which will still exist. As you've found out, if you try and mimic this functionality in a web app by storing too much information in sessions, you'll quickly end up with spaghetti code.
You can use AJAX (google it if you don't already know about it) to update parts of a page only, and get a more streamlined UI, which it sounds like something you'll be needing to do. To get a general idea of the possibilities, you might want to take a look at Bamboo Invoice. It's not built with CakePHP, but it's built with CodeIgniter, which is another open source PHP MVC framework. It sounds like Bamboo Invoice has quite a few similar functionalities to what you're describing (an Invoice has line items, totals, a customer, etc), so it might help you to get an idea of how you should structure your interface - and if you want to dig into the source code, how you can achieve some of the things you want to do.
Bamboo Invoice uses Ajax to give the app a feel of 'one view with everything on it', which it sounds like you want.
Fourth, regarding the specific case of your Customer Search situation, storing stuff in a session variable probably isn't the way to go. You may well want to use an autocomplete field, which sends an Ajax request to server after each time a character is entered in the field, and displays the list list of suggestions / matching customers that the server sends back. See an example here: http://jqueryui.com/autocomplete/. Implementing an autocomplete isn't totally straight forward, but there should be plenty of examples and tutorials all over the web.
Lastly, I obviously don't know what your business does, but have you looked into existing software that might work for you, before building your own? There's a lot of great, flexible web-based solutions, at very reasonable prices, for a LOT of the common tasks that businesses have. There might be something that gives you great results for much less time and money than it costs to build your own solution.
Either way, good luck, and enjoy CakePHP!

Building a SIlverlight Entity Framework application with no data initially

I have found many samples and examples of silverlight applications that use EF for their data store. Why is it that every single one uses a database full of data and shows how to edit/save? I'm having problems setting up an application where I (want to) have no data to start with and would like my user to then populate the data store. Everything works fine when data exists but I get into all sorts of null problems when I want to start with no data.
Just saying...
ANyway, my question: Does anyone know of any tutorials that demonstrate code where no data yet exists?
Thanks!
(Sorry for my bad english)
I suppose you are using RIA Services? That's the easiest way to develop an SL app with EF. It should make no diference between having data or not, the RIA Service returns a collection with 0 or more itens, you bind that with a DataGrid and are done. Here is a link with source code of a full aplication, that starts with no data: http://johnpapa.net/wcf-ria-services-hands-on-lab - What is most important to understand is the asynchronous nature of RIA Services. Keep that in mind, take a look and try the code.
If you have more questions, try to be more specific about the exact errors or problems you are facing, it would be easy to others try to help you :)

Real time database query

We have a windows program written in vbasic(i think) and we are re-writing the same program in c#. In the old program there is a grid. When we click any cell and as soon as edit the cell content the data in database is changing. In our new program we couldn't find the way of doing that. So we added some buttons for database actions like update selected cell.
What is the best way to do that?
You can do this in c# too.Use a datagridview and to bind with the database so that change in the grid effect database see here
Out of seeing dozens of legacy ODBC frontends put together in Access I would strongly advice not to commit changes in the database at real time. Instead try to create a lightweight process that helps the users to keep their data's quality high.
If you want this kind of functionality you could have the real time changes saved in a different schema, a set of different tables or with a flag that tells that these rows are unverified edits by the user X.
Rasel already gave you a pointer how to do the functionality in C#.

Creating Reports in Silverlight (either as PDF or send it off to a printer)

I have recently attempted to generate reports in Silverlight 4. In my problem domain, these reports either need to go directly to the printer and/or the client-side SL application creates a PDF and allows the user to store it somewhere.
As for the report, it's roughly composed of 50% flow text (incl. enumerations), 30% tables and 20% charts. The flow text part makes it slighty more challenging, as proper line breaking would have to take place.
So far, I have tried the following approaches - each with its own shortcomings that make them not so much feasible:
Silverlight's own PrintDocument: technically, there are two major concerns. For one, getting page breaks to work and printing UIElements on it with proper layout is a bit of a dirty hackjob and full of compromises; thankfully that's the part I've managed to get working so far. However, the PrintDocument class always renders all visuals as bitmaps before sending them off; this is not so much fun, if one uses a PDF printer and hopes to still be able to search in / select text. David Poll's approach in "Silverlight and Beyond" [1] wasn't that helpful as well as it inherently follows the same approach and thus suffers from very similar issues.
silverPDF [2]: a barely documented library that requires to do most of the layout manually (the former approach at least allowed me to re-use Silverlight's layouting engine). So far, I see no way to (for instance) measure paragraphs and the only sample with long flowtext uses hardcoded absolute values for layout rectangles. Also, the developing party seems to be inactive.
Personally, I'm now thinking of following an entirely different strategy: simply generate HTML documents. But I was hoping that the community here might have hints for the two approaches above or know other good approaches.
Thanks in advance,
~Manny
Do you need to generate the report on the client, or can you get the server to generate it? Your options are better if you can generate it on the server. Personally, I think the way Silverlight printing works at the moment is pretty poor for report usage (sending each page to the printer as raster rather than vector, resulting in potentially huge amounts of data travelling through the network, and lower printing quality output). I've found the best strategy is to generate the PDF on the server (enabling you to take advantage of a reporting engine), and display it in your application. There are also a few commercial products (such as Telerik's Silverlight Report Viewer, Report Sharp Shooter, or even First Floor Software's Document Toolkit). If a client side solution is really required, perhaps one of these might be the best option (although the printing quality will still be poor). Note that Silverlight 5 is supposed to have support for vector printing, but it's another 6 months or more away from release. Yet another option is Pete Brown and David Poll's open source reporting framework here: http://silverlightreporting.codeplex.com/.
If you want to take the option of generating the report on the server as a PDF and displaying it in your application, I've written an article on doing so here: http://www.silverlightshow.net/items/Building-a-Silverlight-Line-Of-Business-Application-Part-6.aspx. This doesn't work for OOB applications, but the source code accompanying my book (Pro Business Applications with Silverlight 4) does: apress.com/book/view/9781430272076.
Hope this helps...
Chris Anderson

Resources