XML-Based Applications: |
|
To make our application intuitive, we will create a few objects as follows:
When designing this type of application, you should keep in mind to make it as user friendly as possible, which is what we did. Still, you are free to change our design to what suits you. |
Practical Learning: Designing the Application |
|
|
#pragma once using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Xml; #include "NewMake.h" namespace CPAP3 { /// <summary> /// Summary for NewModel /// /// WARNING: If you change the name of this class, you will need to change the /// 'Resource File Name' property for the managed resource compiler tool /// associated with all .resx files this class depends on. Otherwise, /// the designers will not be able to interact properly with localized /// resources associated with this form. /// </summary> public __gc class NewModel : public System::Windows::Forms::Form { public: NewModel(void) { InitializeComponent(); } . . . No Change /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { . . . No Change } private: System::Void btnNewMake_Click(System::Object * sender, System::EventArgs * e) { NewMake *frmNewMake = new NewMake; frmNewMake->ShowDialog(); } }; } |
|
|
System::Void NewPart_Load(System::Object * sender, System::EventArgs * e) { // Fill the Year combo box with years from 1960 to the coming year for(int i = DateTime::Now.Year+1; i >= 1960; i--) this->cboYears->Items->Add(i.ToString()); // We will generate a random number for the item // To start, we will use the miliseconds as a seed DateTime tmeNow = DateTime::Now; int ms = tmeNow.Millisecond; // Now we can generate a random number between 100000 and 999999 Random *rndNumber = new Random(ms); // Generate three randomg characters Char firstCharacter = static_cast<Char>(rndNumber->Next(65, 90)); Char secondCharacter = static_cast<Char>(rndNumber->Next(65, 90)); Char thirdCharacter = static_cast<Char>(rndNumber->Next(65, 90)); // Generate a random number made of 4 digits int numberPart = rndNumber->Next(1000, 9999); // Exclude the digits 1 and 0 because they create confusion if( firstCharacter == 'I' || firstCharacter == 'O' ) firstCharacter = 'A'; if( secondCharacter == 'I' || secondCharacter == 'O' ) secondCharacter = 'A'; if( thirdCharacter == 'I' || thirdCharacter == 'O' ) thirdCharacter = 'A'; // Generate a random number between 1 and 3 int rndCombination = rndNumber->Next(1, 4); String *strPartNumber = 0; // Create a part number using some algorithm if( rndCombination == 1 ) strPartNumber = String::Concat(firstCharacter.ToString(), secondCharacter.ToString(), numberPart.ToString(), thirdCharacter.ToString()); else if( rndCombination == 2 ) strPartNumber = String::Concat(firstCharacter.ToString(), numberPart.ToString(), secondCharacter.ToString(), thirdCharacter.ToString()); else if( rndCombination == 3 ) strPartNumber = String::Concat(numberPart.ToString(), firstCharacter.ToString(), secondCharacter.ToString(), thirdCharacter.ToString()); else strPartNumber = rndNumber->Next(100000, 999999).ToString(); // Display the new number in the Part # text box this->txtPartNumber->Text = strPartNumber; // Disable the OK button to indicate that the part is not ready this->btnAddPart->Enabled = false; } |
#pragma once #include "NewMake.h" #include "NewModel.h" #include "NewPartCategory.h" using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::Xml; namespace CPAP3 { . . . No Change /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> void InitializeComponent(void) { . . . No Change } private: System::Void btnNewMake_Click(System::Object * sender, System::EventArgs * e) { NewMake *frmNewMake = new NewMake; frmNewMake->ShowDialog(); } private: System::Void btnNewModel_Click(System::Object * sender, System::EventArgs * e) { NewModel *frmNewModel = new NewModel; frmNewModel->ShowDialog(); } private: System::Void btnNewCategory_Click(System::Object * sender, System::EventArgs * e) { NewPartCategory *frmCat = new NewPartCategory; frmCat->ShowDialog(); } private: System::Void btnClose_Click(System::Object * sender, System::EventArgs * e) { Close(); } }; } |
|
System::Void OrderProcessing_Load(System::Object * sender, System::EventArgs * e) { // Fill the Year combo box with years from 1960 to the coming year for(int i = DateTime::Now.Year+1; i >= 1960; i--) this->cboYears->Items->Add(i.ToString()); } |
#pragma once #include "NewPart.h" using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; using namespace System::IO; using namespace System::Xml; |
System::Void btnNewPart_Click(System::Object * sender, System::EventArgs * e) { NewPart *frmPart = new NewPart(); frmPart->ShowDialog(); } |
System::Void btnClose_Click(System::Object * sender, System::EventArgs * e) { Close(); } |
|
#pragma once #include "OrderProcessing.h" #include "NewPart.h" namespace CPAP3b { using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System::Data; using namespace System::Drawing; . . . No Change private: System::Void btnOrderProcessing_Click(System::Object * sender, System::EventArgs * e) { OrderProcessing *frmOrder = new OrderProcessing(); frmOrder->ShowDialog(); } private: System::Void btnNewPart_Click(System::Object * sender, System::EventArgs * e) { NewPart *frmPart = new NewPart(); frmPart->ShowDialog(); } private: System::Void btnClose_Click(System::Object * sender, System::EventArgs * e) { Close(); } }; } |
|
||
Previous | Copyright © 2004-2016, FunctionX, Inc. | Next |
|