Archives from S:\ Drive

Good to keep around methinks
This commit is contained in:
Amrit Panesar committed 2015-04-01 21:23:15 -07:00
1 parent eadaf70b9e
commit 6dd63cc439
606 files changed
+50212

No files matched your search

@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ATM Machine", "ATM Machine\ATM Machine.csproj", "{CF1759B7-2217-46A8-8AD9-3169DE41C7F2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CF1759B7-2217-46A8-8AD9-3169DE41C7F2}.Debug|x86.ActiveCfg = Debug|x86
{CF1759B7-2217-46A8-8AD9-3169DE41C7F2}.Debug|x86.Build.0 = Debug|x86
{CF1759B7-2217-46A8-8AD9-3169DE41C7F2}.Release|x86.ActiveCfg = Release|x86
{CF1759B7-2217-46A8-8AD9-3169DE41C7F2}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CF1759B7-2217-46A8-8AD9-3169DE41C7F2}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ATM_Machine</RootNamespace>
<AssemblyName>ATM Machine</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>ATM.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Customer.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SQLHandler.cs">
<SubType>Form</SubType>
</Compile>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="ATM.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

@@ -0,0 +1,50 @@
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace ATM_Machine
{
class Customer
{
public Customer()
{
transactions = new ArrayList();
}
public string Name { get; set; }
public uint CustomerID { get; set; }
public uint AccountNumber { get; set; }
public uint ATMNumber { get; set; }
public uint PIN { get; set; }
public ArrayList transactions;
public decimal balance { get; set; }
}
public class Transaction
{
public Transaction()
{
}
public Transaction(uint id, uint account_number, decimal amount, char type, DateTime date)
{
this.id = id;
this.account_number = account_number;
this.amount = amount;
this.type = type;
this.date = date;
}
public Transaction(object[] values)
{
id = Convert.ToUInt32(values[0]);
account_number = Convert.ToUInt32(values[1]);
amount = Convert.ToDecimal(values[2]);
type = Convert.ToChar(values[3]);
date = (DateTime)values[4];
}
public uint id { get; set; }
public uint account_number { get; set; }
public decimal amount { get; set; }
public char type { get; set; }
public DateTime date { get; set; }
}
}
@@ -0,0 +1,887 @@
namespace ATM_Machine
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.statusStrip1 = new System.Windows.Forms.StatusStrip();
this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
this.label1 = new System.Windows.Forms.Label();
this.panel2 = new System.Windows.Forms.Panel();
this.button5 = new System.Windows.Forms.Button();
this.button4 = new System.Windows.Forms.Button();
this.button3 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.panel1 = new System.Windows.Forms.Panel();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.panel3 = new System.Windows.Forms.Panel();
this.button6 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.label8 = new System.Windows.Forms.Label();
this.label7 = new System.Windows.Forms.Label();
this.panel4 = new System.Windows.Forms.Panel();
this.label11 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.button16 = new System.Windows.Forms.Button();
this.button15 = new System.Windows.Forms.Button();
this.button14 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.button12 = new System.Windows.Forms.Button();
this.button11 = new System.Windows.Forms.Button();
this.button10 = new System.Windows.Forms.Button();
this.button9 = new System.Windows.Forms.Button();
this.button8 = new System.Windows.Forms.Button();
this.button7 = new System.Windows.Forms.Button();
this.label9 = new System.Windows.Forms.Label();
this.panel5 = new System.Windows.Forms.Panel();
this.button17 = new System.Windows.Forms.Button();
this.label13 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.panel6 = new System.Windows.Forms.Panel();
this.button20 = new System.Windows.Forms.Button();
this.button18 = new System.Windows.Forms.Button();
this.maskedTextBox1 = new System.Windows.Forms.MaskedTextBox();
this.label17 = new System.Windows.Forms.Label();
this.label14 = new System.Windows.Forms.Label();
this.label15 = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.panel7 = new System.Windows.Forms.Panel();
this.button23 = new System.Windows.Forms.Button();
this.button19 = new System.Windows.Forms.Button();
this.maskedTextBox2 = new System.Windows.Forms.MaskedTextBox();
this.label18 = new System.Windows.Forms.Label();
this.label19 = new System.Windows.Forms.Label();
this.label20 = new System.Windows.Forms.Label();
this.label21 = new System.Windows.Forms.Label();
this.panel8 = new System.Windows.Forms.Panel();
this.button22 = new System.Windows.Forms.Button();
this.button21 = new System.Windows.Forms.Button();
this.listBox2 = new System.Windows.Forms.ListBox();
this.label23 = new System.Windows.Forms.Label();
this.label22 = new System.Windows.Forms.Label();
this.statusStrip1.SuspendLayout();
this.panel2.SuspendLayout();
this.panel1.SuspendLayout();
this.panel3.SuspendLayout();
this.panel4.SuspendLayout();
this.panel5.SuspendLayout();
this.panel6.SuspendLayout();
this.panel7.SuspendLayout();
this.panel8.SuspendLayout();
this.SuspendLayout();
//
// statusStrip1
//
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabel1});
this.statusStrip1.Location = new System.Drawing.Point(0, 407);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(560, 22);
this.statusStrip1.TabIndex = 0;
this.statusStrip1.Text = "statusStrip1";
//
// toolStripStatusLabel1
//
this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
this.toolStripStatusLabel1.Size = new System.Drawing.Size(38, 17);
this.toolStripStatusLabel1.Text = "Status";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 36F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(49, 14);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(454, 55);
this.label1.TabIndex = 1;
this.label1.Text = "Bank of Biscuit ATM";
//
// panel2
//
this.panel2.Controls.Add(this.button5);
this.panel2.Controls.Add(this.button4);
this.panel2.Controls.Add(this.button3);
this.panel2.Controls.Add(this.button2);
this.panel2.Controls.Add(this.label6);
this.panel2.Controls.Add(this.label5);
this.panel2.Location = new System.Drawing.Point(12, 80);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(536, 320);
this.panel2.TabIndex = 6;
this.panel2.Visible = false;
this.panel2.Enter += new System.EventHandler(this.panel2_Enter);
//
// button5
//
this.button5.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button5.Location = new System.Drawing.Point(297, 189);
this.button5.Name = "button5";
this.button5.Size = new System.Drawing.Size(157, 43);
this.button5.TabIndex = 5;
this.button5.Text = "&Logoff";
this.button5.UseVisualStyleBackColor = true;
this.button5.Click += new System.EventHandler(this.button5_Click);
//
// button4
//
this.button4.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button4.Location = new System.Drawing.Point(89, 189);
this.button4.Name = "button4";
this.button4.Size = new System.Drawing.Size(157, 43);
this.button4.TabIndex = 4;
this.button4.Text = "&Statement";
this.button4.UseVisualStyleBackColor = true;
this.button4.Click += new System.EventHandler(this.button4_Click);
//
// button3
//
this.button3.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button3.Location = new System.Drawing.Point(297, 112);
this.button3.Name = "button3";
this.button3.Size = new System.Drawing.Size(157, 43);
this.button3.TabIndex = 3;
this.button3.Text = "&Deposit";
this.button3.UseVisualStyleBackColor = true;
this.button3.Click += new System.EventHandler(this.button3_Click);
//
// button2
//
this.button2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button2.Location = new System.Drawing.Point(89, 112);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(157, 43);
this.button2.TabIndex = 2;
this.button2.Text = "&Withdraw";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(149, 53);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(240, 20);
this.label6.TabIndex = 1;
this.label6.Text = "What would you like to do today?";
//
// label5
//
this.label5.AutoEllipsis = true;
this.label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label5.Location = new System.Drawing.Point(3, 9);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(530, 29);
this.label5.TabIndex = 0;
this.label5.Text = "Welcome User";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panel1
//
this.panel1.Controls.Add(this.textBox1);
this.panel1.Controls.Add(this.textBox2);
this.panel1.Controls.Add(this.label3);
this.panel1.Controls.Add(this.label4);
this.panel1.Controls.Add(this.button1);
this.panel1.Controls.Add(this.label2);
this.panel1.Location = new System.Drawing.Point(14, 81);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(533, 320);
this.panel1.TabIndex = 7;
this.panel1.Enter += new System.EventHandler(this.panel1_Enter);
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox1.Location = new System.Drawing.Point(168, 105);
this.textBox1.MaxLength = 5;
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(183, 29);
this.textBox1.TabIndex = 14;
//
// textBox2
//
this.textBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.textBox2.Location = new System.Drawing.Point(168, 184);
this.textBox2.MaxLength = 4;
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(183, 29);
this.textBox2.TabIndex = 15;
this.textBox2.UseSystemPasswordChar = true;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label3.Location = new System.Drawing.Point(147, 78);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(231, 24);
this.label3.TabIndex = 11;
this.label3.Text = "Card or Account Number: ";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(129, 157);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(276, 24);
this.label4.TabIndex = 12;
this.label4.Text = "Personal Identification Number: ";
//
// button1
//
this.button1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button1.Location = new System.Drawing.Point(192, 244);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(128, 33);
this.button1.TabIndex = 13;
this.button1.Text = "&Process";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label2.Location = new System.Drawing.Point(214, 23);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(81, 29);
this.label2.TabIndex = 0;
this.label2.Text = "Logon";
//
// panel3
//
this.panel3.Controls.Add(this.button6);
this.panel3.Controls.Add(this.listBox1);
this.panel3.Controls.Add(this.label8);
this.panel3.Controls.Add(this.label7);
this.panel3.Location = new System.Drawing.Point(12, 80);
this.panel3.Name = "panel3";
this.panel3.Size = new System.Drawing.Size(536, 321);
this.panel3.TabIndex = 8;
//
// button6
//
this.button6.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button6.Location = new System.Drawing.Point(376, 256);
this.button6.Name = "button6";
this.button6.Size = new System.Drawing.Size(146, 51);
this.button6.TabIndex = 3;
this.button6.Text = "&Main Menu";
this.button6.UseVisualStyleBackColor = true;
this.button6.Click += new System.EventHandler(this.button6_Click);
//
// listBox1
//
this.listBox1.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 14;
this.listBox1.Location = new System.Drawing.Point(8, 67);
this.listBox1.Name = "listBox1";
this.listBox1.ScrollAlwaysVisible = true;
this.listBox1.Size = new System.Drawing.Size(514, 172);
this.listBox1.TabIndex = 2;
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.Location = new System.Drawing.Point(166, 25);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(124, 24);
this.label8.TabIndex = 1;
this.label8.Text = "$0.00 || -$0.00";
//
// label7
//
this.label7.AutoSize = true;
this.label7.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label7.Location = new System.Drawing.Point(16, 25);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(155, 24);
this.label7.TabIndex = 0;
this.label7.Text = "Current Balance: ";
//
// panel4
//
this.panel4.Controls.Add(this.label11);
this.panel4.Controls.Add(this.label10);
this.panel4.Controls.Add(this.button16);
this.panel4.Controls.Add(this.button15);
this.panel4.Controls.Add(this.button14);
this.panel4.Controls.Add(this.button13);
this.panel4.Controls.Add(this.button12);
this.panel4.Controls.Add(this.button11);
this.panel4.Controls.Add(this.button10);
this.panel4.Controls.Add(this.button9);
this.panel4.Controls.Add(this.button8);
this.panel4.Controls.Add(this.button7);
this.panel4.Controls.Add(this.label9);
this.panel4.Location = new System.Drawing.Point(13, 81);
this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(535, 321);
this.panel4.TabIndex = 9;
//
// label11
//
this.label11.Location = new System.Drawing.Point(277, 40);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(245, 13);
this.label11.TabIndex = 15;
this.label11.Text = "$00.00 || -$00.00";
this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(176, 40);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(95, 13);
this.label10.TabIndex = 14;
this.label10.Text = "Account Balance: ";
this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button16
//
this.button16.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button16.Location = new System.Drawing.Point(47, 272);
this.button16.Name = "button16";
this.button16.Size = new System.Drawing.Size(177, 45);
this.button16.TabIndex = 5;
this.button16.Text = "&Main Menu";
this.button16.UseVisualStyleBackColor = true;
this.button16.Click += new System.EventHandler(this.button16_Click);
//
// button15
//
this.button15.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button15.Location = new System.Drawing.Point(314, 170);
this.button15.Name = "button15";
this.button15.Size = new System.Drawing.Size(177, 45);
this.button15.TabIndex = 8;
this.button15.Text = "$180.00";
this.button15.UseVisualStyleBackColor = true;
this.button15.Click += new System.EventHandler(this.button15_Click);
//
// button14
//
this.button14.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button14.Location = new System.Drawing.Point(314, 272);
this.button14.Name = "button14";
this.button14.Size = new System.Drawing.Size(177, 45);
this.button14.TabIndex = 10;
this.button14.Text = "&Custom ...";
this.button14.UseVisualStyleBackColor = true;
this.button14.Click += new System.EventHandler(this.button14_Click);
//
// button13
//
this.button13.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button13.Location = new System.Drawing.Point(314, 221);
this.button13.Name = "button13";
this.button13.Size = new System.Drawing.Size(177, 45);
this.button13.TabIndex = 9;
this.button13.Text = "$200.00";
this.button13.UseVisualStyleBackColor = true;
this.button13.Click += new System.EventHandler(this.button13_Click);
//
// button12
//
this.button12.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button12.Location = new System.Drawing.Point(314, 119);
this.button12.Name = "button12";
this.button12.Size = new System.Drawing.Size(177, 45);
this.button12.TabIndex = 7;
this.button12.Text = "$140.00";
this.button12.UseVisualStyleBackColor = true;
this.button12.Click += new System.EventHandler(this.button12_Click);
//
// button11
//
this.button11.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button11.Location = new System.Drawing.Point(314, 68);
this.button11.Name = "button11";
this.button11.Size = new System.Drawing.Size(177, 45);
this.button11.TabIndex = 6;
this.button11.Text = "$120.00";
this.button11.UseVisualStyleBackColor = true;
this.button11.Click += new System.EventHandler(this.button11_Click);
//
// button10
//
this.button10.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button10.Location = new System.Drawing.Point(47, 222);
this.button10.Name = "button10";
this.button10.Size = new System.Drawing.Size(177, 45);
this.button10.TabIndex = 4;
this.button10.Text = "$100.00";
this.button10.UseVisualStyleBackColor = true;
this.button10.Click += new System.EventHandler(this.button10_Click);
//
// button9
//
this.button9.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button9.Location = new System.Drawing.Point(47, 170);
this.button9.Name = "button9";
this.button9.Size = new System.Drawing.Size(177, 45);
this.button9.TabIndex = 3;
this.button9.Text = "$80.00";
this.button9.UseVisualStyleBackColor = true;
this.button9.Click += new System.EventHandler(this.button9_Click);
//
// button8
//
this.button8.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button8.Location = new System.Drawing.Point(47, 119);
this.button8.Name = "button8";
this.button8.Size = new System.Drawing.Size(177, 45);
this.button8.TabIndex = 2;
this.button8.Text = "$40.00";
this.button8.UseVisualStyleBackColor = true;
this.button8.Click += new System.EventHandler(this.button8_Click);
//
// button7
//
this.button7.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button7.Location = new System.Drawing.Point(47, 69);
this.button7.Name = "button7";
this.button7.Size = new System.Drawing.Size(177, 45);
this.button7.TabIndex = 1;
this.button7.Text = "$20.00";
this.button7.UseVisualStyleBackColor = true;
this.button7.Click += new System.EventHandler(this.button7_Click);
//
// label9
//
this.label9.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label9.Location = new System.Drawing.Point(8, 9);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(514, 23);
this.label9.TabIndex = 0;
this.label9.Text = "Withdrawals - Fast Cash";
this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panel5
//
this.panel5.Controls.Add(this.button17);
this.panel5.Controls.Add(this.label13);
this.panel5.Controls.Add(this.label12);
this.panel5.Location = new System.Drawing.Point(12, 80);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(536, 322);
this.panel5.TabIndex = 10;
this.panel5.Enter += new System.EventHandler(this.panel5_Enter);
//
// button17
//
this.button17.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button17.Location = new System.Drawing.Point(197, 189);
this.button17.Name = "button17";
this.button17.Size = new System.Drawing.Size(125, 43);
this.button17.TabIndex = 2;
this.button17.Text = "&Main Menu";
this.button17.UseVisualStyleBackColor = true;
this.button17.Click += new System.EventHandler(this.button17_Click);
//
// label13
//
this.label13.AutoSize = true;
this.label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label13.Location = new System.Drawing.Point(176, 124);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(180, 20);
this.label13.TabIndex = 1;
this.label13.Text = "Please Try Again Later...";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label12.ForeColor = System.Drawing.Color.Red;
this.label12.Location = new System.Drawing.Point(106, 93);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(310, 24);
this.label12.TabIndex = 0;
this.label12.Text = "Insufficient Funds for this transaction";
//
// panel6
//
this.panel6.Controls.Add(this.button20);
this.panel6.Controls.Add(this.button18);
this.panel6.Controls.Add(this.maskedTextBox1);
this.panel6.Controls.Add(this.label17);
this.panel6.Controls.Add(this.label14);
this.panel6.Controls.Add(this.label15);
this.panel6.Controls.Add(this.label16);
this.panel6.Location = new System.Drawing.Point(13, 80);
this.panel6.Name = "panel6";
this.panel6.Size = new System.Drawing.Size(536, 324);
this.panel6.TabIndex = 11;
this.panel6.Enter += new System.EventHandler(this.panel6_Enter);
//
// button20
//
this.button20.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button20.Location = new System.Drawing.Point(117, 227);
this.button20.Name = "button20";
this.button20.Size = new System.Drawing.Size(128, 34);
this.button20.TabIndex = 22;
this.button20.Text = "&Main Menu";
this.button20.UseVisualStyleBackColor = true;
this.button20.Click += new System.EventHandler(this.button20_Click);
//
// button18
//
this.button18.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button18.Location = new System.Drawing.Point(305, 227);
this.button18.Name = "button18";
this.button18.Size = new System.Drawing.Size(128, 34);
this.button18.TabIndex = 21;
this.button18.Text = "&Next";
this.button18.UseVisualStyleBackColor = true;
this.button18.Click += new System.EventHandler(this.button18_Click);
//
// maskedTextBox1
//
this.maskedTextBox1.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.maskedTextBox1.HidePromptOnLeave = true;
this.maskedTextBox1.Location = new System.Drawing.Point(295, 123);
this.maskedTextBox1.Mask = "$0000";
this.maskedTextBox1.Name = "maskedTextBox1";
this.maskedTextBox1.Size = new System.Drawing.Size(100, 29);
this.maskedTextBox1.TabIndex = 20;
this.maskedTextBox1.MaskInputRejected += new System.Windows.Forms.MaskInputRejectedEventHandler(this.maskedTextBox1_MaskInputRejected);
//
// label17
//
this.label17.AutoSize = true;
this.label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label17.Location = new System.Drawing.Point(89, 121);
this.label17.Name = "label17";
this.label17.Size = new System.Drawing.Size(199, 24);
this.label17.TabIndex = 19;
this.label17.Text = "Withdrawal Ammount: ";
//
// label14
//
this.label14.Location = new System.Drawing.Point(276, 41);
this.label14.Name = "label14";
this.label14.Size = new System.Drawing.Size(245, 13);
this.label14.TabIndex = 18;
this.label14.Text = "$00.00 || -$00.00";
this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(175, 41);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(95, 13);
this.label15.TabIndex = 17;
this.label15.Text = "Account Balance: ";
this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label16
//
this.label16.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label16.Location = new System.Drawing.Point(7, 10);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(514, 23);
this.label16.TabIndex = 16;
this.label16.Text = "Withdrawals - Custom Ammount";
this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panel7
//
this.panel7.Controls.Add(this.button23);
this.panel7.Controls.Add(this.button19);
this.panel7.Controls.Add(this.maskedTextBox2);
this.panel7.Controls.Add(this.label18);
this.panel7.Controls.Add(this.label19);
this.panel7.Controls.Add(this.label20);
this.panel7.Controls.Add(this.label21);
this.panel7.Location = new System.Drawing.Point(13, 81);
this.panel7.Name = "panel7";
this.panel7.Size = new System.Drawing.Size(536, 324);
this.panel7.TabIndex = 12;
this.panel7.Enter += new System.EventHandler(this.panel7_Enter);
//
// button23
//
this.button23.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button23.Location = new System.Drawing.Point(93, 221);
this.button23.Name = "button23";
this.button23.Size = new System.Drawing.Size(128, 34);
this.button23.TabIndex = 22;
this.button23.Text = "&Main Menu";
this.button23.UseVisualStyleBackColor = true;
this.button23.Click += new System.EventHandler(this.button23_Click);
//
// button19
//
this.button19.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button19.Location = new System.Drawing.Point(287, 221);
this.button19.Name = "button19";
this.button19.Size = new System.Drawing.Size(128, 34);
this.button19.TabIndex = 21;
this.button19.Text = "&Process";
this.button19.UseVisualStyleBackColor = true;
this.button19.Click += new System.EventHandler(this.button19_Click);
//
// maskedTextBox2
//
this.maskedTextBox2.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.maskedTextBox2.HidePromptOnLeave = true;
this.maskedTextBox2.Location = new System.Drawing.Point(295, 123);
this.maskedTextBox2.Mask = "$0000";
this.maskedTextBox2.Name = "maskedTextBox2";
this.maskedTextBox2.Size = new System.Drawing.Size(100, 29);
this.maskedTextBox2.TabIndex = 20;
this.maskedTextBox2.MaskInputRejected += new System.Windows.Forms.MaskInputRejectedEventHandler(this.maskedTextBox2_MaskInputRejected);
//
// label18
//
this.label18.AutoSize = true;
this.label18.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label18.Location = new System.Drawing.Point(89, 121);
this.label18.Name = "label18";
this.label18.Size = new System.Drawing.Size(170, 24);
this.label18.TabIndex = 19;
this.label18.Text = "Deposit Ammount: ";
//
// label19
//
this.label19.Location = new System.Drawing.Point(276, 41);
this.label19.Name = "label19";
this.label19.Size = new System.Drawing.Size(245, 13);
this.label19.TabIndex = 18;
this.label19.Text = "$00.00 || -$00.00";
this.label19.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// label20
//
this.label20.AutoSize = true;
this.label20.Location = new System.Drawing.Point(175, 41);
this.label20.Name = "label20";
this.label20.Size = new System.Drawing.Size(95, 13);
this.label20.TabIndex = 17;
this.label20.Text = "Account Balance: ";
this.label20.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label21
//
this.label21.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label21.Location = new System.Drawing.Point(7, 10);
this.label21.Name = "label21";
this.label21.Size = new System.Drawing.Size(514, 23);
this.label21.TabIndex = 16;
this.label21.Text = "Deposits - Custom Ammount";
this.label21.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panel8
//
this.panel8.Controls.Add(this.button22);
this.panel8.Controls.Add(this.button21);
this.panel8.Controls.Add(this.listBox2);
this.panel8.Controls.Add(this.label23);
this.panel8.Controls.Add(this.label22);
this.panel8.Location = new System.Drawing.Point(12, 80);
this.panel8.Name = "panel8";
this.panel8.Size = new System.Drawing.Size(537, 324);
this.panel8.TabIndex = 13;
this.panel8.Enter += new System.EventHandler(this.panel8_Enter);
//
// button22
//
this.button22.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button22.Location = new System.Drawing.Point(376, 256);
this.button22.Name = "button22";
this.button22.Size = new System.Drawing.Size(116, 40);
this.button22.TabIndex = 4;
this.button22.Text = "&Process";
this.button22.UseVisualStyleBackColor = true;
this.button22.Click += new System.EventHandler(this.button22_Click);
//
// button21
//
this.button21.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.button21.Location = new System.Drawing.Point(55, 256);
this.button21.Name = "button21";
this.button21.Size = new System.Drawing.Size(116, 40);
this.button21.TabIndex = 3;
this.button21.Text = "&Main Menu";
this.button21.UseVisualStyleBackColor = true;
this.button21.Click += new System.EventHandler(this.button21_Click);
//
// listBox2
//
this.listBox2.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listBox2.FormattingEnabled = true;
this.listBox2.ItemHeight = 14;
this.listBox2.Location = new System.Drawing.Point(8, 116);
this.listBox2.Name = "listBox2";
this.listBox2.Size = new System.Drawing.Size(515, 32);
this.listBox2.TabIndex = 2;
//
// label23
//
this.label23.AutoSize = true;
this.label23.Location = new System.Drawing.Point(115, 66);
this.label23.Name = "label23";
this.label23.Size = new System.Drawing.Size(285, 13);
this.label23.TabIndex = 1;
this.label23.Text = "Are you sure you want to process the folowing transaction?";
//
// label22
//
this.label22.AutoSize = true;
this.label22.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label22.Location = new System.Drawing.Point(149, 24);
this.label22.Name = "label22";
this.label22.Size = new System.Drawing.Size(223, 24);
this.label22.TabIndex = 0;
this.label22.Text = "Confirm Your Transaction";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(560, 429);
this.Controls.Add(this.label1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.panel1);
this.Controls.Add(this.panel3);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel7);
this.Controls.Add(this.panel8);
this.Controls.Add(this.panel6);
this.Controls.Add(this.panel5);
this.Controls.Add(this.panel4);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.KeyPreview = true;
this.Name = "Form1";
this.Text = "ATM Machine";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
this.statusStrip1.ResumeLayout(false);
this.statusStrip1.PerformLayout();
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.panel3.ResumeLayout(false);
this.panel3.PerformLayout();
this.panel4.ResumeLayout(false);
this.panel4.PerformLayout();
this.panel5.ResumeLayout(false);
this.panel5.PerformLayout();
this.panel6.ResumeLayout(false);
this.panel6.PerformLayout();
this.panel7.ResumeLayout(false);
this.panel7.PerformLayout();
this.panel8.ResumeLayout(false);
this.panel8.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.StatusStrip statusStrip1;
private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button button4;
private System.Windows.Forms.Button button3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button5;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Button button6;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Button button16;
private System.Windows.Forms.Button button15;
private System.Windows.Forms.Button button14;
private System.Windows.Forms.Button button13;
private System.Windows.Forms.Button button12;
private System.Windows.Forms.Button button11;
private System.Windows.Forms.Button button10;
private System.Windows.Forms.Button button9;
private System.Windows.Forms.Button button8;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.Button button17;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Panel panel6;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.Label label15;
private System.Windows.Forms.Label label16;
private System.Windows.Forms.MaskedTextBox maskedTextBox1;
private System.Windows.Forms.Label label17;
private System.Windows.Forms.Button button18;
private System.Windows.Forms.Panel panel7;
private System.Windows.Forms.Button button19;
private System.Windows.Forms.MaskedTextBox maskedTextBox2;
private System.Windows.Forms.Label label18;
private System.Windows.Forms.Label label19;
private System.Windows.Forms.Label label20;
private System.Windows.Forms.Label label21;
private System.Windows.Forms.Button button20;
private System.Windows.Forms.Panel panel8;
private System.Windows.Forms.Button button22;
private System.Windows.Forms.Button button21;
private System.Windows.Forms.ListBox listBox2;
private System.Windows.Forms.Label label23;
private System.Windows.Forms.Label label22;
private System.Windows.Forms.Button button23;
}
}
@@ -0,0 +1,545 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ATM_Machine
{
public partial class Form1 : Form
{
static Customer customer = new Customer();
public Form1()
{
InitializeComponent();
InitSQL(); // init the sql side of things
InitState(); // init our screens
}
void InitState() // reinitialize the state
{
panel8.Hide(); // hide the confirmation screen
panel7.Hide(); // hide the deposit screen
panel6.Hide(); // hide custom withdrawal screen
panel5.Hide(); // hide insufficient funds screen
panel4.Hide(); // hide withdrawal screen
panel3.Hide(); // hide statement screen
panel2.Hide(); // hide main menu
label5.Text = "Welcome User"; // dummy text
panel1.Show(); // show the login screen
textBox1.Text = string.Empty; // re-initialize the account id textbox to blank
textBox2.Text = string.Empty; // re-initialize the pin textbox to blanks
panel1.Focus(); // Focus.
}
void MainMenu()
{
panel8.Hide(); // hide the confirmation screen
panel7.Hide(); // hide the deposit screen
panel6.Hide(); // hide custom withdrawal screen
panel5.Hide(); // hide insufficient funds screen
panel4.Hide(); // hide withdrawal screen
panel3.Hide(); // hide statement screen
listBox1.Items.Clear(); // clear the statement listbox
listBox2.Items.Clear(); // clear the confirmation listbox
maskedTextBox1.Text = string.Empty; // clear the deposit custom amount field
maskedTextBox2.Text = string.Empty; // clear the withdrawal custom amount field
panel2.Show(); // show the main menu
panel2.Focus(); // focus..
PopulateTransactions(); // do the transactions
}
void InffFunds()
{
panel8.Hide(); // hide the confirmation screen
panel7.Hide(); // hide the deposit screen
panel6.Hide(); // hide custom withdrawal screen
panel4.Hide(); // hide withdrawal screen
panel3.Hide(); // hide statement screen
panel2.Hide(); // show the main menu
panel5.Show(); // show insufficient funds screen
panel5.Focus(); // focus.
}
// hackity hack!
// this property determines which panel is visible
// based on each panel's visibility property.
// if statements galore
public uint visablepanel
{
get
{
if (panel8.Visible) // transaction confirm
{
return 8;
}
else if (panel7.Visible) // custom deposit
{
return 7;
}
else if (panel6.Visible) // custom withdrawal
{
return 6;
}
else if (panel5.Visible) // Insufficient Funds
{
return 5;
}
else if (panel4.Visible) // Withdrawals
{
return 4;
}
else if (panel3.Visible) // balance screen
{
return 3;
}
else if (panel2.Visible) // main menu
{
return 2;
}
else if (panel1.Visible) // login screen
{
return 1;
}
else // or else!
{
return 0;
}
}
}
private void button1_Click(object sender, EventArgs e) // process the login form
{
if (textBox1.Text != string.Empty && textBox2.Text != string.Empty)
{
ValidatePin(uint.Parse(textBox1.Text), uint.Parse(textBox2.Text));
if (customer.AccountNumber > 0) // this is a good value
{
GetCustomerIDFromAccountNumber(customer.AccountNumber);
panel1.Hide(); // hide login
panel2.Show(); // show main menu
panel2.Focus(); // focus.
GetCustomerName(customer.CustomerID); // now that we have the customer id, find customer name
label5.Text = "Welcome " + customer.Name; // populate header
PopulateTransactions(); // populate transactions
}
else
{
// show the user an error with direction
MessageBox.Show("Invalid Card Number or Pin", "Login failure", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
else
{
// show the user an error with direction
MessageBox.Show("Please enter your Card Number and PIN", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
if (textBox1.Text == string.Empty) // what is empty should be filled
{ // help the user figure out what needs to be corrected
textBox1.Focus(); // account number empty
}
else if (textBox2.Text == string.Empty)
{
textBox2.Focus(); // pin empty
}
}
}
private void button5_Click(object sender, EventArgs e) // logoff from the main menu
{
InitState();
// thanks for using bank of biscuit
MessageBox.Show("You have been successfully logged off. Thanks for using Bank of Biscuit!", "Log-off Notification", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
customer = new Customer();
}
private void Form1_KeyDown(object sender, KeyEventArgs e) // catch the enter button
{
if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true;
//MessageBox.Show("visablepanel = " + visablepanel);
switch (visablepanel) // what to do based on the currently visible panel
{
case 1:
button1.PerformClick();
break;
case 2:
button5.PerformClick();
break;
case 3:
button6.PerformClick();
break;
case 4:
button16.PerformClick();
break;
case 5:
button17.PerformClick();
break;
case 6:
button18.PerformClick();
break;
case 7:
button19.PerformClick();
break;
case 8:
button22.PerformClick();
break;
default:
break;
}
}
}
private void panel2_Enter(object sender, EventArgs e) // on main menu entrance, focus logoff button
{
button5.Focus(); // Focus.
}
private void panel1_Enter(object sender, EventArgs e) // on login screen entrance, focus the account number
{
textBox1.Focus(); //Focus.
}
private void button4_Click(object sender, EventArgs e) // enter to statement screen
{
panel2.Hide(); // hide the main menu
doStatement(); // refresh the statement
if (customer.balance < 0)
{
label8.ForeColor = Color.Red; // in the red?
}
else
{
label8.ForeColor = Color.Black; // in the black
}
label8.Text = customer.balance.ToString("C"); // write out the balance
panel3.Show(); // show the statement screen
panel3.Focus(); // focus.
button6.Focus(); // now focus again!
}
private void button6_Click(object sender, EventArgs e) // mainmenu from statement screen
{
MainMenu(); // goto main menu
}
private void button2_Click(object sender, EventArgs e) // enter withdraw screen
{
panel2.Hide(); // hide main menu
doStatement(); // update statement
if (customer.balance < 0)
{
label11.ForeColor = Color.Red; // in the red
}
else
{
label11.ForeColor = Color.Black; // in the black
}
label11.Text = customer.balance.ToString("C"); // write out our balance
panel4.Show(); // show the panel
panel4.Focus(); // Focus.
button16.Focus(); // Focus again!
}
private void button7_Click(object sender, EventArgs e) // withdraw $20.00
{
if (customer.balance > 20)
{
this_transaction = new Transaction(0, customer.AccountNumber, 20.00M, 'W', DateTime.Now);
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
else // insufficient funds
{
InffFunds(); // go there
}
}
private void button8_Click(object sender, EventArgs e) // withdraw $40.00
{
if (customer.balance > 40)
{
this_transaction = new Transaction(0, customer.AccountNumber, 40.00M, 'W', DateTime.Now);
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
else // insufficient funds
{
InffFunds(); // go there
}
}
private void button9_Click(object sender, EventArgs e) // withdraw $80.00
{
if (customer.balance > 80)
{
this_transaction = new Transaction(0, customer.AccountNumber, 80.00M, 'W', DateTime.Now); // set the transaction
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
else // insufficient funds
{
InffFunds(); // go there
}
}
private void button10_Click(object sender, EventArgs e) // withdraw $100.00
{
if (customer.balance > 100)
{
this_transaction = new Transaction(0, customer.AccountNumber, 100.00M, 'W', DateTime.Now); // set the transaction
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
else // insufficient funds
{
InffFunds(); // go there
}
}
private void button11_Click(object sender, EventArgs e) // withdraw $120.00
{
if (customer.balance > 120)
{
this_transaction = new Transaction(0, customer.AccountNumber, 120.00M, 'W', DateTime.Now); // set the transaction
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
else // insufficient funds
{
InffFunds(); // go there
}
}
private void button12_Click(object sender, EventArgs e) // withdraw $140.00
{
if (customer.balance > 140)
{
this_transaction = new Transaction(0, customer.AccountNumber, 140.00M, 'W', DateTime.Now); // set the transaction
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
else // insufficient funds
{
InffFunds(); // go there
}
}
private void button15_Click(object sender, EventArgs e) // withdraw $180.00
{
if (customer.balance > 180)
{
this_transaction = new Transaction(0, customer.AccountNumber, 180.00M, 'W', DateTime.Now); // set the transaction
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
else // insufficient funds
{
InffFunds(); // go there
}
}
private void button13_Click(object sender, EventArgs e) // withdraw $200.00
{
if (customer.balance > 200)
{
this_transaction = new Transaction(0, customer.AccountNumber, 200.00M, 'W', DateTime.Now); // set the transaction
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
else // insufficient funds
{
InffFunds(); // go there
}
}
private void button14_Click(object sender, EventArgs e) // withdraw enter custom amount
{
panel4.Hide(); // hide withdrawals screen
doStatement(); // update balance
if (customer.balance < 0)
{
label14.ForeColor = Color.Red; // in the red
}
else
{
label14.ForeColor = Color.Black; // in the black
}
label14.Text = customer.balance.ToString("C"); // write out the balance
panel6.Show(); // show the panel
panel6.Focus(); // Focus.
}
private void button16_Click(object sender, EventArgs e)// withdraw enter main menu
{
this_transaction = null; // clean up the transaction variable
MainMenu(); // goto main menu
}
private void button17_Click(object sender, EventArgs e) // insufficient funds enter main menu
{
this_transaction = null; // clean up the transaction variable
MainMenu(); // goto main menu
}
private void button20_Click(object sender, EventArgs e) // main menu from custom withdrawals
{
this_transaction = null; // clean up the transaction variable
MainMenu(); // goto main menu
}
private void button18_Click(object sender, EventArgs e) // process custom withdrawal
{
if (Convert.ToDecimal(maskedTextBox1.Text.Substring(1)) > customer.balance) // insifficiant funds?
{
InffFunds(); // go there
}
else
{
this_transaction = new Transaction(0, customer.AccountNumber, Convert.ToDecimal(maskedTextBox1.Text.Substring(1)), 'W', DateTime.Now); // set the transaction
panel6.Hide(); // hide custom withdrawal screen
panel4.Hide(); // hide withdrawal screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
}
private void button22_Click(object sender, EventArgs e) // process transaction from confirmation
{
if (InsertTransaction())
{
if (this_transaction.type == 'D')
{ // deposit confirmation
MessageBox.Show("A Deposit of " + this_transaction.amount.ToString("C") + " has been posted to your account", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{ // withdrawal confirmation
MessageBox.Show("A Withdrawal of " + this_transaction.amount.ToString("C") + " has been posted to your account", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
else
{ // unspecified error
MessageBox.Show("We are unable to process your transaction at this time, please try again later", "Termporary Unavailibility", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
MainMenu(); // goto main menu
}
private void button21_Click(object sender, EventArgs e) // main menu from confirmation
{
MainMenu(); // goto main menu
}
private void button3_Click(object sender, EventArgs e) // deposit from mainmenu
{
panel2.Hide(); // hide main menu
doStatement(); // refresh the statement
if (customer.balance < 0)
{
label19.ForeColor = Color.Red; // in the red?
}
else
{
label19.ForeColor = Color.Black; // in the black
}
label19.Text = customer.balance.ToString("C"); // write out the balance
panel7.Show(); // show deposit screen
panel7.Focus(); // focus.
}
private void button19_Click(object sender, EventArgs e) // process from deposit
{
this_transaction = new Transaction(0, customer.AccountNumber, Convert.ToDecimal(maskedTextBox2.Text.Substring(1)), 'D', DateTime.Now); // set the transaction
panel7.Hide(); // hide custom deposit screen
panel8.Show(); // show confirmation screen
panel8.Focus(); // focus.
}
private void button23_Click(object sender, EventArgs e) // main menu from deposit
{
MainMenu();
}
private void panel8_Enter(object sender, EventArgs e) // on focus of the confirmation screen
{
if (this_transaction != null)
{
string sout = "";
int padding = 13;
listBox2.Items.Add(string.Format("{0}|{1}|{2}|{3}|{4}", "Date".PadRight(padding), "Transaction".PadRight(padding), "Withdrawal".PadRight(padding), "Deposit".PadRight(padding), "Balance".PadRight(padding)));
listBox1.Items.Add("".PadLeft(padding * 5, '-'));
if (this_transaction.type == 'W')
{
// withdrawal
sout = string.Format("{0}|{1}|{2}|{3}|{4}", this_transaction.date.ToShortDateString().PadRight(padding), (customer.CustomerID.ToString().PadLeft(4, '0') + "." + this_transaction.id.ToString().PadLeft(4, '0')).PadRight(padding), this_transaction.amount.ToString("C").PadRight(padding), "".PadRight(padding), customer.balance.ToString("C").PadRight(padding));
}
else
{
// deposit
sout = string.Format("{0}|{1}|{2}|{3}|{4}", this_transaction.date.ToShortDateString().PadRight(padding), (customer.CustomerID.ToString().PadLeft(4, '0') + "." + this_transaction.id.ToString().PadLeft(4, '0')).PadRight(padding), "".PadRight(padding), this_transaction.amount.ToString("C").PadRight(padding), customer.balance.ToString("C").PadRight(padding));
}
listBox2.Items.Add(sout);
}
else
{
MessageBox.Show("A Null transaction?!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
MainMenu();
}
button22.Focus(); // focus the process button
}
private void panel7_Enter(object sender, EventArgs e) // on entrance of deposit
{
maskedTextBox2.Focus(); // Focus.
}
private void maskedTextBox2_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) // move to process button on full input box
{
if (maskedTextBox2.MaskFull)
{
button19.Focus(); // Focus.
}
}
private void maskedTextBox1_MaskInputRejected(object sender, MaskInputRejectedEventArgs e) // move to process button on full input box
{
if (maskedTextBox1.MaskFull)
{
button18.Focus(); // Focus.
}
}
private void panel5_Enter(object sender, EventArgs e) // on entrance of insufficiant funds
{
button17.Focus(); // focus the main menu button
}
private void panel6_Enter(object sender, EventArgs e) // on entrance of custom withdrawal
{
maskedTextBox1.Focus(); // focus the input box
}
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace ATM_Machine
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ATM Machine")]
[assembly: AssemblyDescription("Project 4")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Coleman University")]
[assembly: AssemblyProduct("ATM Machine Project 4")]
[assembly: AssemblyCopyright("Copyright © Coleman University and Amrit Panesar 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f440311b-2d37-4e08-857e-ff0221109544")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1008
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ATM_Machine.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ATM_Machine.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1008
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ATM_Machine.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
@@ -0,0 +1,316 @@
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Drawing;
namespace ATM_Machine
{
public partial class Form1
{
public static SqlConnection connection;
public static Transaction this_transaction;
public bool InitSQL()
{
connection = new SqlConnection((string)(new SqlCredential("172.16.2.34", "db77260", "daeddb98", "db77260")).ToString());
if (SQLReady())
{
toolStripStatusLabel1.Text = "Connected";
return true;
}
else
{
toolStripStatusLabel1.Text = "Not connected";
MessageBox.Show("Error - unable to access server. Please try again later.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
textBox1.Enabled = false;
textBox2.Enabled = false;
button1.Enabled = false;
return false;
}
}
public bool SQLReady()
{
if (connection == null) { return false; }
try
{
connection.Open();
var canOpen = connection.State == ConnectionState.Open;
connection.Close();
return canOpen;
}
catch
{
return false;
}
}
public bool ConnIsOpen()
{
var canOpen = connection.State == ConnectionState.Open;
return canOpen;
}
public uint ValidatePin(uint cardnum, uint pin)
{
SqlCommand sql = new SqlCommand(@"SELECT * FROM ATMCard_t WHERE (card_number = " + cardnum + " AND pin = " + pin + ") "+
"OR (account_number = " + cardnum + " AND pin = " + pin + ")", connection);
object[] values = new object[4];
if (!ConnIsOpen())
{
connection.Open();
}
if (ConnIsOpen())
{
try
{
//value = Convert.ToDecimal(sql.ExecuteScalar());
SqlDataReader reader = sql.ExecuteReader();
reader.Read();
reader.GetValues(values); // grab the first row returned
}
catch (Exception ex)
{
StackTrace st = new StackTrace(new StackFrame(true));
StackFrame sf = st.GetFrame(0);
new ErrorThrower(sf, ex.Message);
}
finally
{
if (ConnIsOpen())
{
connection.Close();
}
}
if (values[0] != null) // populate the customer object
{
customer.ATMNumber = Convert.ToUInt32((int)values[0]);
customer.AccountNumber = Convert.ToUInt32((decimal)values[1]);
customer.PIN = Convert.ToUInt32((string)values[2]);
return Convert.ToUInt32((decimal)values[1]);
}
}
return 0;
}
public uint GetCustomerIDFromAccountNumber(uint accountnum)
{
SqlCommand sql = new SqlCommand(@"SELECT customer_id FROM accounts_t WHERE account_number = " + accountnum, connection);
string value = string.Empty;
if (!ConnIsOpen())
{
connection.Open();
}
try
{
value = sql.ExecuteScalar().ToString();
}
catch (Exception ex)
{
StackTrace st = new StackTrace(new StackFrame(true));
StackFrame sf = st.GetFrame(0);
new ErrorThrower(sf, ex.Message);
}
finally
{
if (ConnIsOpen())
{
connection.Close();
}
}
if (value != string.Empty)
{
customer.CustomerID = Convert.ToUInt32(value);
return Convert.ToUInt32(value);
}
else
{
return 0;
}
}
public string GetCustomerName(uint custId)
{
SqlCommand sql = new SqlCommand(@"SELECT customer_name FROM customers_t WHERE customer_id = " + custId.ToString(), connection);
string name = "";
if (!ConnIsOpen())
{
connection.Open();
}
try
{
name = Convert.ToString(sql.ExecuteScalar());
}
catch (Exception ex)
{
StackTrace st = new StackTrace(new StackFrame(true));
StackFrame sf = st.GetFrame(0);
new ErrorThrower(sf, ex.Message);
}
finally
{
if (ConnIsOpen())
{
connection.Close();
}
}
customer.Name = name;
return name;
}
public void PopulateTransactions()
{
customer.transactions.Clear();
SqlCommand sql = new SqlCommand(@"SELECT * FROM transactions_t WHERE account_number = " + customer.AccountNumber, connection);
if (!ConnIsOpen())
{
connection.Open();
}
try
{
SqlDataReader reader = sql.ExecuteReader();
object[] values = new object[6];
while (reader.Read())
{
reader.GetValues(values);
customer.transactions.Add(new Transaction(values));
}
}
catch (Exception ex)
{
StackTrace st = new StackTrace(new StackFrame(true));
StackFrame sf = st.GetFrame(0);
new ErrorThrower(sf, ex.Message);
}
finally
{
if (ConnIsOpen())
{
connection.Close();
}
}
}
public void doStatement()
{
listBox1.Items.Clear();
customer.balance = 0;
int padding = 13;
listBox1.Items.Add(string.Format("{0}|{1}|{2}|{3}|{4}","Date".PadRight(padding),"Transaction".PadRight(padding),"Withdrawal".PadRight(padding),"Deposit".PadRight(padding),"Balance".PadRight(padding)));
listBox1.Items.Add("".PadLeft(padding * 5,'-'));
ArrayList sout = new ArrayList();
foreach (Transaction tran in customer.transactions)
{
if (tran.type == 'D')
{
customer.balance += tran.amount;
sout.Add(string.Format("{0}|{1}|{2}|{3}|{4}", tran.date.ToShortDateString().PadRight(padding), (customer.CustomerID.ToString().PadLeft(4, '0') + "." + tran.id.ToString().PadLeft(4, '0')).PadRight(padding), "".PadRight(padding), tran.amount.ToString("C").PadRight(padding), customer.balance.ToString("C").PadRight(padding)));
}
else
{
customer.balance -= tran.amount;
sout.Add(string.Format("{0}|{1}|{2}|{3}|{4}", tran.date.ToShortDateString().PadRight(padding), (customer.CustomerID.ToString().PadLeft(4, '0') + "." + tran.id.ToString().PadLeft(4, '0')).PadRight(padding), tran.amount.ToString("C").PadRight(padding), "".PadRight(padding), customer.balance.ToString("C").PadRight(padding)));
}
}
sout.Reverse();
foreach (String sthis in sout)
{
listBox1.Items.Add(sthis);
}
}
public string GetAccountNumber(uint custId, string acctType)
{
string accountNumber = "";
if (!ConnIsOpen())
{
connection.Open();
}
SqlCommand sql = new SqlCommand(@"SELECT account_number FROM accounts_t WHERE customer_id = " + custId.ToString() + " AND account_type = '" + acctType + "'", connection);
try
{
accountNumber = sql.ExecuteScalar().ToString();
}
catch (Exception ex)
{
StackTrace st = new StackTrace(new StackFrame(true));
StackFrame sf = st.GetFrame(0);
new ErrorThrower(sf, ex.Message);
}
finally
{
if (ConnIsOpen())
{
connection.Close();
}
}
return accountNumber;
}
public bool InsertTransaction()
{
if (!ConnIsOpen())
{
connection.Open();
}
SqlCommand sql = new SqlCommand(@"INSERT INTO transactions_t (account_number,amount,transaction_type) " +
"VALUES ('" + this_transaction.account_number + "','" + this_transaction.amount + "','" + this_transaction.type + "')",
connection);
try
{
sql.ExecuteScalar();
}
catch (Exception ex)
{
StackTrace st = new StackTrace(new StackFrame(true));
StackFrame sf = st.GetFrame(0);
new ErrorThrower(sf, ex.Message);
return false;
}
finally
{
if (ConnIsOpen())
{
connection.Close();
}
}
return true;
}
}
class ErrorThrower
{
public ErrorThrower(StackFrame sf, string text)
{
MessageBox.Show(string.Format("Error: {0}\nLine:{1}\nFile:{2}", text, sf.GetFileLineNumber(), sf.GetFileName()), "Exception", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
}
class SqlCredential
{
public string Server { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Database { get; set; }
public SqlCredential(string server, string username, string password, string database)
{
Server = server;
Username = username;
Password = password;
Database = database;
}
public override string ToString()
{
return string.Format("Server={0};UID={1};PWD={2};Database={3}", Server, Username, Password, Database);
}
}
}
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cerealization", "Cerealization\Cerealization.csproj", "{95487408-55E2-47CB-A48E-F8720F938D3E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{95487408-55E2-47CB-A48E-F8720F938D3E}.Debug|x86.ActiveCfg = Debug|x86
{95487408-55E2-47CB-A48E-F8720F938D3E}.Debug|x86.Build.0 = Debug|x86
{95487408-55E2-47CB-A48E-F8720F938D3E}.Release|x86.ActiveCfg = Release|x86
{95487408-55E2-47CB-A48E-F8720F938D3E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{95487408-55E2-47CB-A48E-F8720F938D3E}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Cerealization</RootNamespace>
<AssemblyName>Cerealization</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RandomThings.cs" />
<Compile Include="StructuredInts.cs" />
<Compile Include="Student.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.IO;
using System.Diagnostics;
namespace Cerealization
{
public partial class Program
{
static void Main(string[] args)
{
Console.WriteLine(" -=Coffee and cerealization=-\n ( ) ;\n ;)( ;\n :----: o8Oo./\n C|====| ._o8o8o8Oo_.\n | | \\========/\n `----' `------'\n");
int HighOrder = RandNumber(10, 101); // 100 students as the maximum
Console.WriteLine("Generating {0} students...", HighOrder);
CStudent students = new CStudent();
for (int i = 0; i < HighOrder; i++)
{
// do the thing.
students.Add(new Student(i + 1, GenerateFirstName(), GenerateFirstName(), GenerateLastName(), GenerateSSN(), GenerateAddr(), "", GenerateCity(), GenerateState(), GenerateZipCode(), GeneratePhoneNumber(), GeneratePhoneNumber()));
}
XmlSerializer serializer = new XmlSerializer(typeof(CStudent));
TextWriter writer = new StreamWriter("Students.xml");
serializer.Serialize(writer, students);
writer.Close();
Console.WriteLine("Students.xml written!");
Console.WriteLine("Press enter to open in Notepad++");
Console.ReadLine();
Process.Start("notepad++", string.Format("\"{0}\\{1}\"", Directory.GetCurrentDirectory(), "Students.xml"));
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Cerealization")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Coleman University")]
[assembly: AssemblyProduct("Cerealization")]
[assembly: AssemblyCopyright("Copyright © Coleman University 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c843d1de-c3be-47d1-9ee0-1d2ca6b48d77")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,134 @@
using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Cerealization
{
/// <summary>
/// Various randomly generated things.
/// </summary>
public partial class Program
{
// generate a random number from 0 to the maximum value an integer can hold. Positive values.
public static int RandNumber(int Low = 0, int High = int.MaxValue)
{
Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber));
int rnd = rndNum.Next(Low, High);
return rnd;
}
// generate a random floating point double. positive values.
public static double RandDouble()
{
Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber));
double rnd = rndNum.NextDouble() * 28;
if (rnd < 20) // make all numbers greater than 20.
{
rnd *= RandDouble();
}
return rnd;
}
// grab a random firstname from this string array.
public static string GenerateFirstName()
{
string[] firstnames = { "Librada","Jeanne","Krishna","Roni","Kisha","Edison","Freda","Jed","Lorraine","Nelda","Corine","Lien","Daisy","Gita","Suzy","Gwyneth","Krysta","Erinn","Samual","Barney","Rosia","Malik","Franchesca","Cherryl","Ricardo","Inga","Lesley","Kory","Jaunita","Lacey","Chelsie","Kera","Isaac","Aracely","Delmy","Maggie","Rolland","Estela","Otha","Arturo","Devona",
"Wilton","Karey","Hillary","Jared","Tiffiny","Boris","Flavia","Rivka","Casimira","Adria","Odette","Wilbert","Xuan","Allyson","Rosendo","Elijah","Tad","Malisa","Kayleen","Jone","Reina","Laraine","Len","Leora","Fred","Sydney","Sona","Thuy","Sage","Sixta","Joseph","Chantell","Kiesha","Kacie","Maryellen","Fidelia","Anastasia","Stephaine","Johanne","Charlesetta",
"Crista","Jarod","Sherrell","Sebrina","Juliet","Charise","Candida","Jonnie","Daine","Jong","Maida","Danilo","Jeneva","Margret","Domenic","Luanna","Nana","Salley","Hipolito","Sanjuanita","Giuseppina","Domonique","Shayla","Melva","Leora","Ashleigh","Ruben","Delbert","Evelina","Jeanie","Margarett","Marcie","Assunta","Latoria","Jodie","Kenisha","Anamaria","Shirleen",
"Ashton","Yan","Fanny","Vanita","Marlyn","Maryland","Shandi","Adolph","Amina","Manuel","Dawne","Cristine","Alberto","Tabetha","Frida","Awilda","Louann","Karly","Dede","Kristina","Sue","Elissa","Jamika","Margret","Ninfa","Louisa","Vinita","Gigi","Quinn","Maricruz","Jeanmarie","Niesha","Marquita","Hertha","Shawnna","Jetta","Kristel","Shaunta","Kiyoko","Alana","Eduardo",
"Trish","Willa","Darline","Ching","Rosenda","Rufus","Kraig","Tia","Keely","Markita","Georgann","Nicola","Judy","Ignacio","Shantay","Cicely","Astrid","Ladawn","Nia","Babara","Deidre","Geoffrey","Leilani","Lamont","Delphine","Harrison","Anjanette","Zona","Carmen","Hui","Luvenia","Leeann","Marybelle","Shanon","Nicky","Carlene","Laquanda","Aldo","Larisa","Tony",
"Madeleine","Garnett","Shae","Shemika","Erich","Celestina","Foster","Kaitlyn","Mariela","Noe","Rafael","Jesusa","Cole","Lettie","Sherill","Trey","Marg","Shaunda","Randell","Piedad","Marjorie","Verena","Elicia","Mika","Colette","Corene","Veronika","Jerrie","Rosie","Georgene","Serafina","Sherman","Susannah","Annamae","Michell","Kelsey","Rosario","Carolina","Jeanie",
"Lyndia","Ora","Herta","Santa","Erline","Karmen","Griselda","Maud","Linnie","Nicholle","Mistie","Jordan"};
// use the positive random number function above, mod'd by the length to grab a random value
return (firstnames[RandNumber() % firstnames.Length]);
}
// grab a random lastname from this string array.
public static string GenerateLastName()
{
string[] lastnames = { "Ives","Dole","Bechtel","Gilfillan","Fahey","Montrose","Harvin","Arvizo","Letarte","Reidhead","Ahlstrom","Hyneman","Reynoso","Douglass","Prato","Mccutchen","Mohl","Sperry","Greb","Cabell","Laramore","Fujiwara","Arpin","Brumfield","Fortin","Markell","Ballengee","Sanluis","Trickey","Haake","Zirkle","Gaines","Ahern","Lafond","Jude","Robie","Runion","Runyan","Futrell",
"Rather","Kinloch","Rugg","Senecal","Vanhook","Vallance","Stillwell","Haldeman","Thrush","Shomo","Valerius","Cazares","Townley","Rakestraw","Agar","Meinecke","Coll","Redick","Saint","Spight","Mcnaught","Gayman","Yerger","Rivero","Fabela","Wilhoite","Middlebrooks","Jefferys","Massie","Reichel","Lobb","Ristow","Rucks","Heckard","Hosmer","Dingess","Schamber","Hesson",
"Torbett","Goldschmidt","Hayter","Shew","Ugalde","Vicknair","Danks","Tate","Delorme","Ormand","Laughton","Wilkerson","Dickson","Mulvey","Junkin","Camacho","Barsh","Recker","Farnsworth","Gary","Drees","Knoles","Satter","Battin","Costa","Matsumura","Shears","Devinney","Macken","Garrett","Doney","Fulmer","Hoss","Loll","Tanner","Podesta","Asaro","Morningstar","Hilyard",
"Nehls","Fonseca","Eller","Wilkinson","Lamarca","Soliz","Westervelt","Carlino","Kunkle","Loucks","Jansson","Cothren","Darlington","Zahm","Pinegar","Emerick","Tall","Eveland","Umstead","Davisson","Batz","Plata","Ryberg","Beane","Koening","Putz","Daughtrey","Sinha","Gerdes","Arno","Lorch","Shehan","Chenard","Holloway","Castleberry","Bowlin","Battin","Donovan","Calton",
"Huot","Mcmurtrie","Delapp","Lankford","Biel","Kin","Caceres","Ormand","Streicher","Kimbrel","Cornish","Barahona","Southern","Stuart","Stoke","Scharff","Hartwell","Gildersleeve","Tedrick","Rex","Chaudhry","Wetzel","Desai","Ensey","Escobedo","Matranga","Falzone","Ritzman","Marchant","Babin","Friedt","Shoup","Gunder","Seim","Shadrick","Riggs","Moret","Howes","Steenbergen",
"Rodriques","Dries","Jefferson","Hulbert","Menendez","Ellington","Housand","Whitwell","Rearick","Wagnon","Schmitmeyer","Barhorst","Rosenfield","Summerville","Matus","Marrow","Kind","Searfoss","Denn","Appling","Grim","Huffer","Kellen","Roscoe","Garofalo","Simeone","Goucher","Parkhurst","Tarpey","Bassett","Ortman","Segundo","Mattson","Pullum","Kriner","Smiddy","Cohrs",
"Loring","Strebel","Mcnemar","Grossi","Raby","Dubray","Capra","Wittrock","Fazzino","Bedard","Sera","Lisk","Heldt","Barefoot","Heimbach","Hover","Guthrie","Hartigan","Noyes","Jarrard"};
// use the positive random number function above, mod'd by the length to grab a random value
return (lastnames[RandNumber() % lastnames.Length]);
}
public static string GenerateAddr()
{
string[] set1 = { "Amber", "Auburn", "Bent", "Big", "Birch", "Blue", "Bright", "Broad", "Burning", "Calm", "Cinder", "Clear", "Cold", "Colonial", "Cool", "Cotton", "Cozy", "Crimson", "Crystal", "Dewy", "Dusty", "Easy", "Emerald", "Fallen", "Foggy", "Gentle", "Golden", "Grand", "Green", "Happy", "Harvest", "Hazy", "Heather", "Hidden", "High", "Honey", "Hush", "Indian", "Iron", "Ivory",
"Jagged", "Lazy", "Little", "Lone", "Lonely", "Long", "Lost", "Merry", "Middle", "Misty", "Noble", "Old", "Orange", "Pearl", "Pied", "Pleasant", "Pretty", "Quaint", "Quaking", "Quiet", "Red", "Rocky", "Rose", "Rough", "Round", "Rustic", "Sandy", "Shady", "Silent", "Silver", "Sleepy", "Small", "Square", "Still", "Stony", "Strong", "Sunny", "Sweet", "Tawny", "Tender",
"Thunder", "Turning", "Twin", "Umber", "Velvet", "White", "Windy" };
string[] set2 = { "Acorn", "Anchor", "Apple", "Autumn", "Axe", "Barn", "Beacon", "Bear", "Beaver", "Berry", "Bird", "Blossom", "Bluff", "Branch", "Bridge", "Brook", "Butterfly", "Butternut", "Castle", "Chestnut", "Cider", "Butt", "Cottage", "Creek", "Crow", "Dale", "Deer", "Diamond", "Dove", "Elk", "Elm", "Embers", "Fawn", "Feather", "Flower", "Forest", "Fox", "Gate", "Goat", "Goose", "Grove",
"Harbor", "Hickory", "Hills", "Holly", "Horse", "Island", "Lake", "Lamb", "Leaf", "Log", "Maple", "Mill", "Mountain", "Nectar", "Nest", "Nut", "Oak", "Panda", "Peach", "Pebble", "Pine", "Pioneer", "Pond", "Pony", "Prairie", "Pumpkin", "Quail", "Rabbit", "Rise", "River", "Robin", "Rock", "Shadow", "Sky", "Snake", "Spring", "Squirrel", "Stone", "Swan", "Timber", "Treasure",
"Turtle", "View", "Wagon", "Willow", "Zephyr" };
string[] set3 = { "Acres", "Alcove", "Arbor", "Avenue", "Bank", "Bayou", "Bend", "Bluff", "Byway", "Canyon", "Chase", "Circle", "Corner", "Court", "Cove", "Crest", "Cut", "Dale", "Dell", "Drive", "Edge", "Estates", "Falls", "Farms", "Field", "Flats", "Gardens", "Gate", "Glade", "Glen", "Grove", "Haven", "Heights", "Highlands", "Hollow", "Isle", "Jetty", "Journey", "Knoll", "Lace", "Lagoon",
"Landing", "Lane", "Ledge", "Manor", "Meadow", "Mews", "Niche", "Nook", "Orchard", "Pace", "Park", "Pass", "Path", "Pike", "Place", "Point", "Promenade", "Quay", "Race", "Ramble", "Ridge", "Road", "Round", "Rove", "Run", "Saunter", "Shoal", "Stead", "Street", "Stroll", "Summit", "Swale", "Terrace", "Trace", "Trail", "Trek", "Turn", "Twist", "Vale", "Valley", "View", "Villa",
"Vista", "Wander", "Way", "Woods" };
return string.Format("{0} {1} {2} {3}", RandNumber(0,10000), set1[RandNumber() % set1.Length], set2[RandNumber() % set2.Length], set3[RandNumber() % set3.Length]);
}
public static string GenerateState()
{
string[] states = { "AL", "AK", "AS", "AZ", "AR", "CA", "CO", "CT", "DE", "DC", "FM", "FL", "GA", "GU", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MH", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "MP", "OH", "OK", "OR", "PW", "PA", "PR", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VI", "VA", "WA", "WV", "WI", "WY" };
return states[RandNumber() % states.Length];
}
public static string GenerateCity()
{
// grabbit from https://developers.google.com/adwords/api/docs/appendix/geotargeting?csw=1
string[] cities = { "Anchorage", "Anderson", "Angoon", "Atqasuk", "Barrow", "Bethel", "Clear", "Cordova", "Craig", "Delta Junction", "Dillingham", "Eagle River", "Eielson AFB", "Elmendorf Air Force Base", "Fairbanks", "Galena", "Girdwood", "Glennallen", "Gustavus", "Haines", "Healy", "Homer", "Hoonah", "Juneau", "Kenai", "Ketchikan", "Klawock", "Kodiak", "Kotzebue", "McGrath", "Metlakatla",
"Mountain Village", "Nikiski", "Nome", "North Pole", "Palmer", "Pelican", "Petersburg", "Port Lions", "Seward", "Sitka", "Skagway", "Soldotna", "Saint Paul Island", "Tanacross", "Thorne Bay", "Tok", "Tununak", "Unalaska", "Valdez", "Wasilla", "Whittier", "Wrangell", "Yakutat", "Abbeville", "Adamsville", "Addison", "Adger", "Alabaster", "Albertville", "Alexander City",
"Alexandria", "Allgood", "Alpine", "Andalusia", "Anniston", "Arab", "Arlington", "Ashford", "Ashland", "Ashville", "Athens", "Atmore", "Attalla", "Auburn", "Auburn University", "Autaugaville", "Axis", "Bay Minette", "Berry", "Bessemer", "Birmingham", "Blountsville", "Boaz", "Bremen", "Brewton", "Brookwood", "Brownsboro", "Bucks", "Buhl", "Butler", "Calera", "Calhoun",
"Camden", "Carrollton", "Centre", "Centreville", "Chapman", "Chelsea", "Cherokee", "Childersburg", "Clanton", "Clayton", "Clio", "Coffeeville", "Columbia", "Columbiana", "Cottondale", "Cottonwood", "Cowarts", "Creola", "Crossville", "Cullman", "Daleville", "Daphne", "Dauphin Island", "Deatsville", "Decatur", "Demopolis", "Dixons Mills", "Dothan", "Eastaboga", "Eclectic",
"Eight Mile", "Elba", "Elberta", "Enterprise", "Eufaula", "Eutaw", "Evergreen", "Excel", "Fairfield", "Fairhope", "Fayette", "Florence", "Foley", "Fruitdale", "Fort Deposit", "Fort Payne", "Fort Rucker", "Fulton", "Fultondale", "Gadsden", "Gardendale", "Geneva", "Glenwood", "Goodwater", "Gordo", "Grand Bay", "Graysville", "Greensboro", "Greenville", "Grove Hill", "Guin",
"Gulf Shores", "Guntersville", "Haleyville", "Hamilton", "Hanceville", "Hartselle", "Hatchechubbee", "Hayden", "Hayneville", "Hazel Green", "Headland", "Heflin", "Helena", "Hodges", "Hope Hull", "Huntsville", "Huxford", "Ider", "Jack", "Jackson", "Jacksonville", "Jasper", "Jefferson", "Kellyton", "Killen", "Laceys Spring", "La Fayette", "Lanett", "Leeds", "Leesburg",
"Lillian", "Lincoln", "Linden", "Lineville", "Livingston", "Loachapoka", "Locust Fork", "Loxley", "Luverne", "Madison", "Marion", "Mathews", "Millport", "Millry", "Mobile", "Monroeville", "Montevallo", "Montgomery", "Montrose", "Morris", "Moulton", "Munford", "Muscle Shoals", "New Brockton", "New Market", "Newton", "Newville", "Normal", "Northport", "Notasulga",
"Oakman", "Oneonta", "Opelika", "Opp", "Orange Beach", "Oxford", "Ozark", "Paint Rock", "Pelham", "Pell City", "Pennington", "Perdue Hill", "Phenix City", "Piedmont", "Pike Road", "Pine Hill", "Pinson", "Pleasant Grove", "Prattville", "Quinton", "Ragland", "Rainbow City", "Rainsville", "Ramer", "Red Bay", "Reform", "Roanoke", "Robertsdale", "Russellville", "Rutledge",
"Saginaw", "Saraland", "Scottsboro", "Selma", "Semmes", "Shannon", "Sheffield", "Shelby", "Spanish Fort", "Springville", "Sulligent", "Sumiton", "Summerdale", "Sycamore", "Sylacauga", "Talladega", "Tallassee", "Theodore", "Thomasville", "Toney", "Troy", "Trussville", "Tuscaloosa", "Tuscumbia", "Tuskegee", "Tuskegee University", "Union Springs", "Valley", "Vernon",
"Vinemont", "Wadley", "Walnut Grove", "Warrior", "Webb", "Wedowee", "Wetumpka", "Winfield", "York", "Adona", "Alexander", "Alma", "Altheimer", "Amity", "Arkadelphia", "Armorel", "Ash Flat", "Ashdown", "Augusta", "Bald Knob", "Barling", "Batesville", "Bauxite", "Bay", "Beebe", "Bella Vista", "Benton", "Bentonville", "Berryville", "Bigelow", "Blytheville", "Booneville",
"Bradford", "Branch", "Brinkley", "Brockwell", "Brookland", "Bryant", "Burdette", "Cabot", "Calico Rock", "Camden", "Carlisle", "Carthage", "Cave City", "Center Ridge", "Charleston", "Charlotte", "Cherokee Village", "Clarendon", "Clarksville", "Clinton", "Compton", "Conway", "Corning", "Crossett", "Danville", "Dardanelle", "De Queen", "DeWitt", "Decatur", "Dermott",
"Des Arc", "Dumas", "Dyess", "El Dorado", "Elm Springs", "England", "Enola", "Eureka Springs", "Fairfield Bay", "Farmington", "Fayetteville", "Flippin", "Floral", "Fordyce", "Forrest City", "Fountain Hill", "Friendship", "Fort Smith", "Gassville", "Gentry", "Gillham", "Glenwood", "Gould", "Grady", "Gravette", "Greenbrier", "Greenwood", "Guion", "Hackett", "Hamburg",
"Hardy", "Harrisburg", "Harrison", "Hartford", "Hattieville", "Hazen", "Heber Springs", "Hector", "Helena", "Higden", "Hope", "Hot Springs National Park", "Hot Springs Village", "Hoxie", "Humphrey", "Huntsville", "Imboden", "Jacksonville", "Jasper", "Jessieville", "Joiner", "Jonesboro", "Keiser", "Kensett", "Lake Village", "Lavaca", "Lead Hill", "Lepanto", "Leslie",
"Little Rock", "Little Rock Air Force Base", "Lockesburg", "London", "Lonoke", "Lowell", "Luxora", "Lynn", "Mabelvale", "Magnolia", "Malvern", "Mammoth Spring", "Mansfield", "Marianna", "Marion", "Marked Tree", "Marmaduke", "Marshall", "Maumelle", "Maynard", "McCrory", "McGehee", "McRae", "Melbourne", "Mena", "Monticello", "Morrilton", "Mount Holly", "Mount Ida",
"Mount Pleasant", "Mount Vernon", "Mountain Home", "Mountain View", "Mountainburg", "Nashville", "Newark", "Newport", "Norfork", "Norman", "North Little Rock", "Osceola", "Ozark", "Palestine", "Paragould", "Paris", "Pea Ridge", "Pearcy", "Piggott", "Pine Bluff", "Plainview", "Plumerville", "Pocahontas", "Poplar Grove", "Pottsville", "Prairie Grove", "Prescott",
"Quitman", "Rector", "Rison", "Rogers", "Romance", "Rosston", "Russellville", "Salem", "Saratoga", "Scotland", "Searcy", "Sheridan", "Sherwood", "Siloam Springs", "Smackover", "Springdale", "Stamps", "Star City", "Arkansas State University", "Stuttgart", "Subiaco", "Sulphur Rock", "Swifton", "Texarkana", "Timbo", "Tontitown", "Trumann", "Valley Springs", "Van Buren" };
return cities[RandNumber() % cities.Length];
}
// make a random social security number
public static SocialSecurityNumber GenerateSSN()
{
int G1 = RandNumber(1, 1000); // 999
int G2 = RandNumber(1, 100); // 99
int G3 = RandNumber(1, 10000); // 9999
// return a socialsecuritynumber
return new SocialSecurityNumber(G1, G2, G3);
}
// make a random phonenumber
public static PhoneNumber GeneratePhoneNumber()
{
int G1 = RandNumber(1, 1000); // 999
int G2 = RandNumber(1, 1000); // 999
int G3 = RandNumber(1, 10000); // 9999
// return a phonenumber
return new PhoneNumber(G1, G2, G3);
}
public static ZipCode GenerateZipCode()
{
int G1 = RandNumber(1, 100000); //99999
int G2 = RandNumber(1, 10000); //9999
return new ZipCode(G1, G2);
}
}
}
@@ -0,0 +1,116 @@
// Structured ints for things that are structured.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Cerealization
{
[Serializable]
public class PhoneNumber
{
///<summary>
/// phone numbers are composed of three parts:
/// area code, phone prefix, line number
/// this aggregates all three
///</summary>
public int AreaCode { get; set; }
public int Prefix { get; set; }
public int LineNumber { get; set; }
new public string ToString
{
get
{
return string.Format("({0:D3}) {1:D3}-{2:D4}",AreaCode,Prefix,LineNumber);
}
set
{
}
}
public PhoneNumber(int area, int pre, int line)
{
AreaCode = area;
Prefix = pre;
LineNumber = line;
}
public PhoneNumber() // default constructor for XMLSerialization
{
}
}
[Serializable]
public class SocialSecurityNumber
{
///<summary>
/// Social Security Numbers are composed of 3 parts
/// Group 1 - 3 digits
/// Group 2 - 2 digits
/// Group 3 - 4 digits
/// this class aggregates all groups
///</summary>
public int GroupOne { get; set; }
public int GroupTwo { get; set; }
public int GroupThree { get; set; }
new public string ToString
{
get
{
return string.Format("{0:D3}-{1:D2}-{2:D4}", GroupOne, GroupTwo, GroupThree);
}
set
{
}
}
public SocialSecurityNumber(int g1, int g2, int g3)
{
GroupOne = g1;
GroupTwo = g2;
GroupThree = g3;
}
public SocialSecurityNumber() // default constructor for XMLSerialization
{
}
}
[Serializable]
public class ZipCode
{
/// <summary>
/// Zipcodes are composed of 3 parts
/// Zip code - Maximum of 5 digits
/// Plus four code - maximum of 4 digits
/// this class aggregates all parts
/// </summary>
public int Zip { get; set; }
public int PlusFour { get; set; }
new public string ToString
{
get
{
return string.Format("{0:D5}-{1:D4}", Zip, PlusFour);
}
set
{
}
}
public ZipCode(int zip, int four)
{
Zip = zip;
PlusFour = four;
}
public ZipCode() // default constructor for XMLSerialization
{
}
}
}
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Xml.Serialization;
namespace Cerealization
{
/// <summary>
/// Student class aggregates the following information:
/// Student ID, First Name, Middle Name, Last Name,
/// Social Secuirty Number, Address, City, State, Zipcode
/// and 2 phone numbers
/// </summary>
[Serializable]
public class Student
{
public int StudentID { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public SocialSecurityNumber SSN { get; set; }
public string Address1 { get; set; }
public string Address2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public ZipCode ZipCode { get; set; }
public PhoneNumber Phone1 { get; set; }
public PhoneNumber Phone2 { get; set; }
public Student(int id, string fn, string mn, string ln, SocialSecurityNumber ssn, string addr1, string addr2, string city, string state, ZipCode zip, PhoneNumber phone1, PhoneNumber phone2)
{
StudentID = id;
FirstName = fn;
MiddleName = mn;
LastName = ln;
SSN = ssn;
Address1 = addr1;
Address2 = addr2;
City = city;
State = state;
ZipCode = zip;
Phone1 = phone1;
Phone2 = phone2;
}
public Student() // default constructor for XMLSerialization
{
}
}
[Serializable]
[XmlRoot("Students_XML")]
public class CStudent
{
/// <summary>
/// The CStudent class is here to allow the XMLSerilizer
/// access to a List without having to loop thorugh the list
/// before writing it to a file. - This is essentially a
/// glue class.
/// </summary>
[XmlAttribute("Count")]
public int Count { get; set; }
[XmlArray("Student_List")]
[XmlArrayItem("Student")]
public List<Student> Students;
public CStudent(List<Student> stud)
{
Students = new List<Student>();
Students = stud;
}
public CStudent() // default constructor for XMLSerialization
{
Students = new List<Student>();
}
public void Add(Student s)
{
Students.Add(s);
Count = Students.Count;
}
}
}
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project 1", "Project 1\Project 1.csproj", "{BF828070-B0E7-4F6E-B98E-39486C05DFD0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BF828070-B0E7-4F6E-B98E-39486C05DFD0}.Debug|x86.ActiveCfg = Debug|x86
{BF828070-B0E7-4F6E-B98E-39486C05DFD0}.Debug|x86.Build.0 = Debug|x86
{BF828070-B0E7-4F6E-B98E-39486C05DFD0}.Release|x86.ActiveCfg = Release|x86
{BF828070-B0E7-4F6E-B98E-39486C05DFD0}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,82 @@
/******************************************************************************
* Author: Amrit Panesar *
* Project: 1 *
* Date: 8/9/2013 *
* Due Date: Date Due: Monday Week 2 ( Midnight) *
* Class: COM 271 *
* Teacher: S. Ganore *
* *
* Filename: Consultant.cs *
* File Description: *
* derived from parttimeemployee requires the same variables as parttimeemp.. *
* Consultants may work more than 40 hours a week. they also have a consultant*
* fee. this class's calculate wage function assists in the calculation of *
* the concultant's wage. the print function assists in the display of *
* consultant specific data. *
* *
* Description: *
* Finish the inheritance chain with a class, which contains the Main method. *
* The students must script all the corresponding source code and produce a *
* clean compile of each step along the way towards the class with the Main *
* method. *
* The final step is the execution of the .exe file, which assigns values *
* through the public interface of the object and then displays the correct *
* values. This lab is to be coded individually and shown to the instructor. *
* *
* Project Specification: *
* We have Employee, PartTimeEmployee, FullTimeEmployee and Consultant *
* classes. Employee is the base class, PartTimeEmployee and FullTimeEmployee *
* are derived from it. Consultant is the derived class of PartTimeEmployee *
* (so Constultant is indirect derived class of Employee) and therefore we *
* have 3 level inheritance. Employee class contains name, id and *
* dateOfHire as the member variables. PartTimeEmployee contains hourlyRate *
* and hoursWorked as member variables. FullTimeEmployee contains salary as *
* the member variables. Consultant contains extraHours and consultantFee as *
* the member variables. Hours over 40 are considered as extra hours and is *
* applicable only to the consultant, more over the consultant will get paid *
* an additional 50% for the extra hours. *
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project_1
{
class Consultant : PartTimeEmployee
{
//Consultant contains extraHours and consultantFee as the member variables.
double extraHours;
decimal consultantFee;
public double ExtraHours { get { return extraHours; } set { extraHours = value; } }
public decimal ConsultantFee { get { return consultantFee; } set { consultantFee = value; } }
// call the base class with name, id, doh, hourly rate, and hours worked
public Consultant(string name, int id, DateTime doh, double hourlyRate, double hoursWorked, double extraHours, decimal consultantFee)
: base(name, id, doh, hourlyRate, hoursWorked)
{
this.ExtraHours = extraHours;
this.ConsultantFee = consultantFee;
}
// ( ( hours worked * hourly rate ) + ( extra hours * ( hourly rate * 1.5 ) ) + consultant fee ) = wage
new public decimal CalcWage()
{
return (decimal)((this.HoursWorked * this.HourlyRate) + (this.ExtraHours * (this.HourlyRate * 1.5))) + ConsultantFee;
}
// print consultant specific information
public static void Print(Consultant e)
{
PartTimeEmployee.Print(e, false);
Console.Out.WriteLine("Type of Employee: Consultant");
Console.Out.WriteLine("Wage: {0}", e.CalcWage().ToString("C").PadLeft(9));
Console.Out.WriteLine("Extra Hours worked: {0}", e.ExtraHours);
Console.Out.WriteLine("Extra Hours rate: {0}", (e.HourlyRate * 1.5));
Console.Out.WriteLine("Consultant Fee: {0}", e.ConsultantFee.ToString("C").PadLeft(9));
}
}
}
@@ -0,0 +1,72 @@
/******************************************************************************
* Author: Amrit Panesar *
* Project: 1 *
* Date: 8/9/2013 *
* Due Date: Date Due: Monday Week 2 ( Midnight) *
* Class: COM 271 *
* Teacher: S. Ganore *
* *
* Filename: Employee.cs *
* File Description: *
* base class for the project. includes member variables for name, id and *
* date of hire. also includes a print function to ease displaying data. *
* *
* Description: *
* Finish the inheritance chain with a class, which contains the Main method. *
* The students must script all the corresponding source code and produce a *
* clean compile of each step along the way towards the class with the Main *
* method. *
* The final step is the execution of the .exe file, which assigns values *
* through the public interface of the object and then displays the correct *
* values. This lab is to be coded individually and shown to the instructor. *
* *
* Project Specification: *
* We have Employee, PartTimeEmployee, FullTimeEmployee and Consultant *
* classes. Employee is the base class, PartTimeEmployee and FullTimeEmployee *
* are derived from it. Consultant is the derived class of PartTimeEmployee *
* (so Constultant is indirect derived class of Employee) and therefore we *
* have 3 level inheritance. Employee class contains name, id and *
* dateOfHire as the member variables. PartTimeEmployee contains hourlyRate *
* and hoursWorked as member variables. FullTimeEmployee contains salary as *
* the member variables. Consultant contains extraHours and consultantFee as *
* the member variables. Hours over 40 are considered as extra hours and is *
* applicable only to the consultant, more over the consultant will get paid *
* an additional 50% for the extra hours. *
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project_1
{
class Employee
{
//name, id and dateOfHire as the member variables.
string name;
int id;
DateTime dateOfHire;
public string Name { get { return this.name; } set { this.name = value; } }
public int Id { get { return id; } set { this.id = value; } }
public DateTime DateOfHire { get { return this.dateOfHire; } set { this.dateOfHire = value; } }
// constructor to include name, id, and date of hire.
public Employee(string name, int id, DateTime doh)
{
this.Name = name;
this.Id = id;
this.DateOfHire = doh;
}
// print employee specific information
public static void Print(Employee e)
{
Console.Out.WriteLine("\n============Employee {0}============", e.Id);
Console.Out.WriteLine("Name: {0}", e.Name);
Console.Out.WriteLine("ID: {0}", e.Id);
Console.Out.WriteLine("Date of Hire: {0}", e.DateOfHire.ToShortDateString());
}
}
}
@@ -0,0 +1,72 @@
/******************************************************************************
* Author: Amrit Panesar *
* Project: 1 *
* Date: 8/9/2013 *
* Due Date: Date Due: Monday Week 2 ( Midnight) *
* Class: COM 271 *
* Teacher: S. Ganore *
* *
* Filename: FullTimeEmployee.cs *
* File Description: *
* derived from employee. constructor requires same variables as employee. *
* full time employess are based on salarey and includes appropriate variables*
* this class also includes a print function to assist in the display of data *
* *
* Description: *
* Finish the inheritance chain with a class, which contains the Main method. *
* The students must script all the corresponding source code and produce a *
* clean compile of each step along the way towards the class with the Main *
* method. *
* The final step is the execution of the .exe file, which assigns values *
* through the public interface of the object and then displays the correct *
* values. This lab is to be coded individually and shown to the instructor. *
* *
* Project Specification: *
* We have Employee, PartTimeEmployee, FullTimeEmployee and Consultant *
* classes. Employee is the base class, PartTimeEmployee and FullTimeEmployee *
* are derived from it. Consultant is the derived class of PartTimeEmployee *
* (so Constultant is indirect derived class of Employee) and therefore we *
* have 3 level inheritance. Employee class contains name, id and *
* dateOfHire as the member variables. PartTimeEmployee contains hourlyRate *
* and hoursWorked as member variables. FullTimeEmployee contains salary as *
* the member variables. Consultant contains extraHours and consultantFee as *
* the member variables. Hours over 40 are considered as extra hours and is *
* applicable only to the consultant, more over the consultant will get paid *
* an additional 50% for the extra hours. *
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project_1
{
class FullTimeEmployee : Employee
{
//FullTimeEmployee contains salary as the member variables.
decimal salary;
public decimal Salary { get { return salary; } set { salary = value; } }
// constructor passes the values: name, id, and doh to the based constructor
public FullTimeEmployee(string name, int id, DateTime doh, decimal salary)
: base(name, id, doh)
{
this.Salary = salary;
}
// wage = salary.
public decimal CalcWage()
{
return Salary;
}
// print full time information.
public static void Print(FullTimeEmployee e)
{
Employee.Print(e);
Console.Out.WriteLine("Type of Employee: Full time");
Console.Out.WriteLine("Wage: {0}", e.CalcWage().ToString("C").PadLeft(9));
}
}
}
@@ -0,0 +1,111 @@
/******************************************************************************
* Author: Amrit Panesar *
* Project: 1 *
* Date: 8/9/2013 *
* Due Date: Date Due: Monday Week 2 ( Midnight) *
* Class: COM 271 *
* Teacher: S. Ganore *
* *
* Filename: PartTimeEmployee.cs *
* File Description: *
* base class for consultant. derived from employee. requires same variables *
* as employee but also includes hourlyrate and hours worked. this also *
* includes a print function to assist in the displaying of data. *
* *
* Description: *
* Finish the inheritance chain with a class, which contains the Main method. *
* The students must script all the corresponding source code and produce a *
* clean compile of each step along the way towards the class with the Main *
* method. *
* The final step is the execution of the .exe file, which assigns values *
* through the public interface of the object and then displays the correct *
* values. This lab is to be coded individually and shown to the instructor. *
* *
* Project Specification: *
* We have Employee, PartTimeEmployee, FullTimeEmployee and Consultant *
* classes. Employee is the base class, PartTimeEmployee and FullTimeEmployee *
* are derived from it. Consultant is the derived class of PartTimeEmployee *
* (so Constultant is indirect derived class of Employee) and therefore we *
* have 3 level inheritance. Employee class contains name, id and *
* dateOfHire as the member variables. PartTimeEmployee contains hourlyRate *
* and hoursWorked as member variables. FullTimeEmployee contains salary as *
* the member variables. Consultant contains extraHours and consultantFee as *
* the member variables. Hours over 40 are considered as extra hours and is *
* applicable only to the consultant, more over the consultant will get paid *
* an additional 50% for the extra hours. *
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project_1
{
class PartTimeEmployee : Employee
{
//hourlyRate and hoursWorked as the member variables.
double hourlyRate, hoursWorked;
public double HourlyRate { get { return this.hourlyRate; } set { this.hourlyRate = value; } }
// data validation: part time employees can only work 40 hours.
public double HoursWorked {
get {
if (this.hoursWorked > 40)
{
this.hoursWorked = 40;
}
return this.hoursWorked;
}
set {
if (this.hoursWorked > 40)
{
this.hoursWorked = 40;
}
else
{
this.hoursWorked = value;
}
}
}
// the constructor passes name, id, and dateofhire to the base class.
public PartTimeEmployee(string name, int id, DateTime doh, double hourlyRate, double hoursWorked)
: base(name, id, doh)
{
this.HourlyRate = hourlyRate;
this.HoursWorked = hoursWorked;
}
// hourly rate * hours worked = wage
public decimal CalcWage()
{
return (decimal)(this.HourlyRate * this.hoursWorked);
}
// print what is necessary.
public void Print()
{
Console.Out.WriteLine("Hours worked: {0}", this.HoursWorked);
Console.Out.WriteLine("Hourly rate: {0}", this.HourlyRate);
}
// stub for printing as a part time employee.
public static void Print(PartTimeEmployee e)
{
Print(e, true);
}
// print the detailed information
public static void Print(PartTimeEmployee e, bool choice)
{
Employee.Print(e);
if (choice)
{
Console.Out.WriteLine("Type of Employee: Part time");
Console.Out.WriteLine("Wage: {0}", e.CalcWage().ToString("C").PadLeft(9));
}
e.Print();
}
}
}
@@ -0,0 +1,67 @@
/******************************************************************************
* Author: Amrit Panesar *
* Project: 1 *
* Date: 8/9/2013 *
* Due Date: Date Due: Monday Week 2 ( Midnight) *
* Class: COM 271 *
* Teacher: S. Ganore *
* *
* Filename: Program.cs *
* File Description: *
* Main driver for the project, instanciates employees and prints appropriate *
* output. *
* *
* Description: *
* Finish the inheritance chain with a class, which contains the Main method. *
* The students must script all the corresponding source code and produce a *
* clean compile of each step along the way towards the class with the Main *
* method. *
* The final step is the execution of the .exe file, which assigns values *
* through the public interface of the object and then displays the correct *
* values. This lab is to be coded individually and shown to the instructor. *
* *
* Project Specification: *
* We have Employee, PartTimeEmployee, FullTimeEmployee and Consultant *
* classes. Employee is the base class, PartTimeEmployee and FullTimeEmployee *
* are derived from it. Consultant is the derived class of PartTimeEmployee *
* (so Constultant is indirect derived class of Employee) and therefore we *
* have 3 level inheritance. Employee class contains name, id and *
* dateOfHire as the member variables. PartTimeEmployee contains hourlyRate *
* and hoursWorked as member variables. FullTimeEmployee contains salary as *
* the member variables. Consultant contains extraHours and consultantFee as *
* the member variables. Hours over 40 are considered as extra hours and is *
* applicable only to the consultant, more over the consultant will get paid *
* an additional 50% for the extra hours. *
******************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project_1
{
class Program
{
// the driver.
static void Main(string[] args)
{
// make one employee for each type of employee
Employee LazaroKeller = new Employee("Lazaro T. Keller", 0, DateTime.Parse("1/9/2013"));
PartTimeEmployee JudithFranklin = new PartTimeEmployee("Judith J. Franklin", 1, DateTime.Parse("3/14/2013"), 15.50, 25);
FullTimeEmployee SandraStockton = new FullTimeEmployee("Sandra E. Stockton", 2, DateTime.Parse("5/27/2013"), 68000);
Consultant RichardRojas = new Consultant("Richard M. Rojas", 3, DateTime.Parse("8/28/2013"), 20, 40, 20.8, 500);
// print them with their specific methods.
Employee.Print(LazaroKeller);
PartTimeEmployee.Print(JudithFranklin);
FullTimeEmployee.Print(SandraStockton);
Consultant.Print(RichardRojas);
// finalize.
Console.WriteLine("\n\nPress ENTER to continue...");
Console.ReadLine();
}
}
}
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{BF828070-B0E7-4F6E-B98E-39486C05DFD0}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Project_1</RootNamespace>
<AssemblyName>Project 1</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Consultant.cs" />
<Compile Include="Employee.cs" />
<Compile Include="FullTimeEmployee.cs" />
<Compile Include="PartTimeEmployee.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Project 1")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Project 1")]
[assembly: AssemblyCopyright("Copyright © 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4176b7fc-df5b-4a97-a695-8e7abac6c644")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project2", "Project2\Project2.csproj", "{FFA33A1C-42BF-4496-A1B4-1A00294803D4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Debug|x86.ActiveCfg = Debug|x86
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Debug|x86.Build.0 = Debug|x86
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Release|x86.ActiveCfg = Release|x86
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,43 @@
/*****************************************************************************
* Project 2 will implement a payroll system using abstract classes. *
* *
* A company pays its employees on a weekly basis. The employees are of four *
* types: Salaried employees are paid a fixed weekly salary regardless of the *
* number of hours worked, hourly employees are paid by the hour and receive *
* overtime pay for all hours worked in excess of 40 hours, commission *
* employees are paid a percentage of their sales, and salaried commission *
* employees receive a base salary plus a percentage of their sales. For the *
* current pay period, the company has decided to reward salaried-commission *
* employees by adding 10% to their base salaries. The company wants to *
* implement a C# application that performs its payroll calculations *
* polymorphically. *
* *
* Abstract base class Employee declares the “interface” to the hierarchy— *
* that is, the set of methods that an application can invoke on all *
* employee objects. Each employee, regardless of the way his earnings are *
* calculated has a first name, a last name and a social security number, so *
* private instance variables firstName, lastName and socialSecurityNumber *
* appear in abstract base class Employee. *
* *
* Class Employee provides methods Earnings and ToString, in addition to the *
* properties that manipulate Employee’s instance variables. An Earnings *
* method certainly applies to all employees. But each earnings calculation *
* depends on the employee’s class. So we declare Earnings as abstract in *
* base class Employee. Each derived class overrides Earnings with an *
* appropriate implementation. To calculate an employee’s earnings, the *
* application assigns a reference to the employee’s object to a base class *
* Employee variable, then invokes the Earnings method on that variable. *
* You will maintain an array of Employee variables, each of which holds a *
* reference to an Employee object. The application iterates through the *
* array and calls method Earnings for each Employee object. C# processes *
* theses method calls polymorphically. Including Earnings as an abstract *
* method in Employee forces every directly derived class of Employee to *
* override Earnings with a method that performs an appropriate pay *
* calculation. *
* *
* Method ToString in class Employee returns a string containing the first *
* name, last name, and social security number of the employee. Each derived *
* class of Employee overrides method ToString to create a string *
* representation of an object of that class containing the employee’s type, *
* followed by the rest of the employee’s information. *
*****************************************************************************/
@@ -0,0 +1,43 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for hybrid *
* commission/salary based employees. *
* For further description please see ARCHITECTURE.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project2
{
public class BasePlusCommissionEmployee : CommissionEmployee
{
// overloaded constructor to call the Commission Employee's overloaded constructor
public BasePlusCommissionEmployee(string FirstName, string LastName, string SSN, double ComissionRate, decimal GrossSales, decimal basesalary)
: base(FirstName, LastName, SSN, ComissionRate, GrossSales)
{
BaseSalary = basesalary;
}
public decimal BaseSalary { get; set; }
public override decimal Earnings()
{
// a salary/commission employee's wage is their salary + commission rate * gross sales
return (((decimal)ComissionRate * GrossSales) + BaseSalary);
}
// override the tostring method.
public override string ToString()
{
// report employee tostring, gross sales, commission rate, and base salary
return String.Format("base salaried commission employee: {0} {1}\nssn: {2}\ngross sales: {3}\ncommission rate: {4}\nbase salary: {5}\nearnings: {6}\n", FirstName, LastName, SocialSecuityNumber, GrossSales.ToString("C"), ComissionRate.ToString("F2"), BaseSalary.ToString("C"), Earnings().ToString("C"));
// NOTE: we couldn't use the base.tostring method because it outputs commission employee strings.
}
}
}
@@ -0,0 +1,57 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for *
* commission based employees. *
* For further description please see ARCHITECTURE.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project2
{
public class CommissionEmployee : Employee
{
// the main overloaded constructor, also call the base class Employee with it's overloaded constructor.
public CommissionEmployee(string FirstName, string LastName, string SSN, double comissionrate, decimal grosssales ) : base( FirstName, LastName, SSN)
{
ComissionRate = comissionrate;
GrossSales = grosssales;
}
// constructor to pass an employee and arguments, if necessary.
public CommissionEmployee(Employee empn, double comissionrate, decimal grosssales) : base (empn)
{
ComissionRate = comissionrate;
GrossSales = grosssales;
}
// constructor to pass an entire commission employee if necessary.
public CommissionEmployee(CommissionEmployee empn) : base (empn)
{
ComissionRate = empn.ComissionRate;
GrossSales = empn.GrossSales;
}
public double ComissionRate { get; set; }
public decimal GrossSales { get; set; }
public override decimal Earnings()
{
// a commission employee's earnings are the commission rate * gross sales
return ((decimal)ComissionRate * GrossSales);
}
// override the tostring method
public override string ToString()
{
// the base tostring, gross sales, commission rate, and earnings
return String.Format("commission {0}\ngross sales: {1}\ncommission rate: {2}\nearnings: {3}\n", base.ToString(), GrossSales.ToString("C"), ComissionRate.ToString("F2"), Earnings().ToString("C"));
}
}
}
@@ -0,0 +1,49 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Impliment a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Houses the main driver for the program. Instantiates an *
* array of 10 Employees that demonstrates polymorphic behavior *
* For further description please see ARCHITECTURE.txt *
*****************************************************************************/
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace Project2
{
public abstract class Employee
{
// empty constructor, don't do anything.
public Employee() { }
// main constructor, each value as a parameter.
public Employee(string fname, string lname, string ssn)
{
FirstName = fname; LastName = lname; SocialSecuityNumber = ssn;
}
// we have the flexibility to pass in an entire new employee if necessary.
public Employee(Employee empn)
{
FirstName = empn.FirstName; LastName = empn.LastName; SocialSecuityNumber = empn.SocialSecuityNumber;
}
public string FirstName { get; set; }
public string LastName { get; set; }
public string SocialSecuityNumber { get; set; }
// abstract. must be implemented by all other inherited classes.
public abstract decimal Earnings();
// override the tostring. this is the base tostring.
public override string ToString()
{
// The standard employee: employee first name, last name, and social security number
return String.Format("employee: {0} {1}\nssn: {2}", FirstName, LastName, SocialSecuityNumber);
}
}
}
@@ -0,0 +1,67 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for hourly *
* employees. *
* For further description please see ARCHITECTURE.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project2
{
public class HourlyEmployee : Employee
{
// main constructor. pass variables to the Employee constructor
public HourlyEmployee(string FirstName, string LastName, string SSN, decimal wage, double hours) : base(FirstName, LastName, SSN)
{
Wage = wage;
Hours = hours;
}
// We can pass in an employee object and extra variables, if necessary
public HourlyEmployee(Employee empn, decimal wage, double hours) : base (empn)
{
Wage = wage;
Hours = hours;
}
// Or we can pass in an entire Hourly Employee and work with that.
public HourlyEmployee(HourlyEmployee empn) : base(empn)
{
Wage = empn.Wage;
Hours = empn.Hours;
}
public decimal Wage { get; set; }
public double Hours { get; set; }
public override decimal Earnings()
{
if (Hours <= 40) // if the employee's hours are less than 40 inclusive
{
return (Wage * 40); // multiply the wage by 40 hours
}
else if (Hours > 40) // if the employee's hours are more than 40
{
return (decimal)(40 * (double)Wage + (Hours - 40) * (double)Wage * 1.5); // the standard wage + time and a half for all hours over 40
}
else // this should never happen.
{
return 0;
}
}
// override the tostring
public override string ToString()
{
//the standard employee tostring, hourly wage, hours worked, and earnings
return String.Format("hourly {0}\nhourly wage: {1}\nhours worked: {2}\nearnings: {3}\n", base.ToString(), Wage.ToString("C"), Hours.ToString("F2"), Earnings().ToString("C"));
}
}
}
@@ -0,0 +1,65 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Houses the main driver for the program. Instantiates an *
* array of 10 Employees that demonstrates polymorphic behavior *
* For further description please see ARCHITECTURE.txt *
*****************************************************************************/
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace Project2
{
public partial class Program
{
static void Main(string[] args)
{
// Use an array list to house our employees.
ArrayList empn = new ArrayList();
// generate 5 to 30 random employees..
int highOrder = RandNumber(5, 30);
Console.WriteLine("Generating {0} Employees...", highOrder);
// loop though the random number above
for (int i = 0; i < highOrder; i++)
{
int thisN = RandNumber() % 5; // Generate a random number between 1 and the max integer size moded by 5 (to generate a number 1-4)
switch (thisN)
{
case 4: // BasePlus
empn.Add(new BasePlusCommissionEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), RandDouble(), (decimal)RandDouble(), (decimal)RandDouble()));
break;
case 3: // Commission
empn.Add(new CommissionEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), RandDouble(), (decimal)RandDouble()));
break;
case 2: // Salary
empn.Add(new SalariedEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), (decimal)RandDouble()));
break;
default: // Hourly
empn.Add(new HourlyEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), (decimal)RandDouble(), RandDouble()));
break;
}
}
// Loop through the new array list.
for (int i = 0; i < empn.Count; i++ )
{
Console.WriteLine("\n================Employee #: {0}================", (i + 1)); // spit out the squence number
Console.WriteLine(empn[i]); // tostring method. so much easier.
// remind me to always override the tostring() method.
}
// courtesy line and direction.
Console.WriteLine("----------------------------------------\nPress ENTER to continue");
// let's keep the console from closing.
Console.ReadLine();
}
}
}
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{FFA33A1C-42BF-4496-A1B4-1A00294803D4}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Project2</RootNamespace>
<AssemblyName>Project2</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BasePlusCommissionEmployee.cs" />
<Compile Include="CommissionEmployee.cs" />
<Compile Include="Employee.cs" />
<Compile Include="HourlyEmployee.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RandomThings.cs" />
<Compile Include="SalariedEmployee.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<None Include="ARCHITECTURE.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Project2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Coleman University")]
[assembly: AssemblyProduct("Project2")]
[assembly: AssemblyCopyright("Copyright © Coleman University 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("49380830-1af5-4d23-9477-5145a019c8bf")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,76 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Houses the random functions found in the file Program.cs *
* The functions RandNumber(), RandDouble(), GenerateFirstName(), and *
* GenerateLastName() can all be found in this file. *
* For further description please see ARCHITECTURE.txt *
*****************************************************************************/
using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project2
{
public partial class Program
{
// generate a random number from 0 to the maximum value an integer can hold. Positive values.
public static int RandNumber(int Low = 0, int High = int.MaxValue)
{
Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber));
int rnd = rndNum.Next(Low, High);
return rnd;
}
// generate a random floating point double. positive values.
public static double RandDouble()
{
Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber));
double rnd = rndNum.NextDouble() * 28;
return rnd;
}
// grab a random firstname from this string array.
public static string GenerateFirstName()
{
string[] firstnames = { "Librada","Jeanne","Krishna","Roni","Kisha","Edison","Freda","Jed","Lorraine","Nelda","Corine","Lien","Daisy","Gita","Suzy","Gwyneth","Krysta","Erinn","Samual","Barney","Rosia","Malik","Franchesca","Cherryl","Ricardo","Inga","Lesley","Kory","Jaunita","Lacey","Chelsie","Kera","Isaac","Aracely","Delmy","Maggie","Rolland","Estela","Otha","Arturo","Devona",
"Wilton","Karey","Hillary","Jared","Tiffiny","Boris","Flavia","Rivka","Casimira","Adria","Odette","Wilbert","Xuan","Allyson","Rosendo","Elijah","Tad","Malisa","Kayleen","Jone","Reina","Laraine","Len","Leora","Fred","Sydney","Sona","Thuy","Sage","Sixta","Joseph","Chantell","Kiesha","Kacie","Maryellen","Fidelia","Anastasia","Stephaine","Johanne","Charlesetta",
"Crista","Jarod","Sherrell","Sebrina","Juliet","Charise","Candida","Jonnie","Daine","Jong","Maida","Danilo","Jeneva","Margret","Domenic","Luanna","Nana","Salley","Hipolito","Sanjuanita","Giuseppina","Domonique","Shayla","Melva","Leora","Ashleigh","Ruben","Delbert","Evelina","Jeanie","Margarett","Marcie","Assunta","Latoria","Jodie","Kenisha","Anamaria","Shirleen",
"Ashton","Yan","Fanny","Vanita","Marlyn","Maryland","Shandi","Adolph","Amina","Manuel","Dawne","Cristine","Alberto","Tabetha","Frida","Awilda","Louann","Karly","Dede","Kristina","Sue","Elissa","Jamika","Margret","Ninfa","Louisa","Vinita","Gigi","Quinn","Maricruz","Jeanmarie","Niesha","Marquita","Hertha","Shawnna","Jetta","Kristel","Shaunta","Kiyoko","Alana","Eduardo",
"Trish","Willa","Darline","Ching","Rosenda","Rufus","Kraig","Tia","Keely","Markita","Georgann","Nicola","Judy","Ignacio","Shantay","Cicely","Astrid","Ladawn","Nia","Babara","Deidre","Geoffrey","Leilani","Lamont","Delphine","Harrison","Anjanette","Zona","Carmen","Hui","Luvenia","Leeann","Marybelle","Shanon","Nicky","Carlene","Laquanda","Aldo","Larisa","Tony",
"Madeleine","Garnett","Shae","Shemika","Erich","Celestina","Foster","Kaitlyn","Mariela","Noe","Rafael","Jesusa","Cole","Lettie","Sherill","Trey","Marg","Shaunda","Randell","Piedad","Marjorie","Verena","Elicia","Mika","Colette","Corene","Veronika","Jerrie","Rosie","Georgene","Serafina","Sherman","Susannah","Annamae","Michell","Kelsey","Rosario","Carolina","Jeanie",
"Lyndia","Ora","Herta","Santa","Erline","Karmen","Griselda","Maud","Linnie","Nicholle","Mistie","Jordan"};
// use the positive random number function above, mod'd by the length to grab a random value
return (firstnames[RandNumber() % firstnames.Length]);
}
// grab a random lastname from this string array.
public static string GenerateLastName()
{
string[] lastnames = { "Ives","Dole","Bechtel","Gilfillan","Fahey","Montrose","Harvin","Arvizo","Letarte","Reidhead","Ahlstrom","Hyneman","Reynoso","Douglass","Prato","Mccutchen","Mohl","Sperry","Greb","Cabell","Laramore","Fujiwara","Arpin","Brumfield","Fortin","Markell","Ballengee","Sanluis","Trickey","Haake","Zirkle","Gaines","Ahern","Lafond","Jude","Robie","Runion","Runyan","Futrell",
"Rather","Kinloch","Rugg","Senecal","Vanhook","Vallance","Stillwell","Haldeman","Thrush","Shomo","Valerius","Cazares","Townley","Rakestraw","Agar","Meinecke","Coll","Redick","Saint","Spight","Mcnaught","Gayman","Yerger","Rivero","Fabela","Wilhoite","Middlebrooks","Jefferys","Massie","Reichel","Lobb","Ristow","Rucks","Heckard","Hosmer","Dingess","Schamber","Hesson",
"Torbett","Goldschmidt","Hayter","Shew","Ugalde","Vicknair","Danks","Tate","Delorme","Ormand","Laughton","Wilkerson","Dickson","Mulvey","Junkin","Camacho","Barsh","Recker","Farnsworth","Gary","Drees","Knoles","Satter","Battin","Costa","Matsumura","Shears","Devinney","Macken","Garrett","Doney","Fulmer","Hoss","Loll","Tanner","Podesta","Asaro","Morningstar","Hilyard",
"Nehls","Fonseca","Eller","Wilkinson","Lamarca","Soliz","Westervelt","Carlino","Kunkle","Loucks","Jansson","Cothren","Darlington","Zahm","Pinegar","Emerick","Tall","Eveland","Umstead","Davisson","Batz","Plata","Ryberg","Beane","Koening","Putz","Daughtrey","Sinha","Gerdes","Arno","Lorch","Shehan","Chenard","Holloway","Castleberry","Bowlin","Battin","Donovan","Calton",
"Huot","Mcmurtrie","Delapp","Lankford","Biel","Kin","Caceres","Ormand","Streicher","Kimbrel","Cornish","Barahona","Southern","Stuart","Stoke","Scharff","Hartwell","Gildersleeve","Tedrick","Rex","Chaudhry","Wetzel","Desai","Ensey","Escobedo","Matranga","Falzone","Ritzman","Marchant","Babin","Friedt","Shoup","Gunder","Seim","Shadrick","Riggs","Moret","Howes","Steenbergen",
"Rodriques","Dries","Jefferson","Hulbert","Menendez","Ellington","Housand","Whitwell","Rearick","Wagnon","Schmitmeyer","Barhorst","Rosenfield","Summerville","Matus","Marrow","Kind","Searfoss","Denn","Appling","Grim","Huffer","Kellen","Roscoe","Garofalo","Simeone","Goucher","Parkhurst","Tarpey","Bassett","Ortman","Segundo","Mattson","Pullum","Kriner","Smiddy","Cohrs",
"Loring","Strebel","Mcnemar","Grossi","Raby","Dubray","Capra","Wittrock","Fazzino","Bedard","Sera","Lisk","Heldt","Barefoot","Heimbach","Hover","Guthrie","Hartigan","Noyes","Jarrard"};
// use the positive random number function above, mod'd by the length to grab a random value
return (lastnames[RandNumber() % lastnames.Length]);
}
// make a random social security number
public static string GenerateSSN()
{
int G1 = RandNumber(1, 1000);
int G2 = RandNumber(1, 100);
int G3 = RandNumber(1, 10000);
// use the string.format and tostring methods to numerically pad each tuple of a social security number
return String.Format("{0}-{1}-{2}", G1.ToString("D3"), G2.ToString("D2"), G3.ToString("D4"));
}
}
}
@@ -0,0 +1,39 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for salaried *
* employees. *
* For further description please see ARCHITECTURE.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project2
{
public class SalariedEmployee : Employee
{
// main constructor for the salaried employee
public SalariedEmployee(string FirstName, string LastName, string SSN, decimal weeklysal) : base(FirstName, LastName, SSN)
{
WeeklySalary = weeklysal;
}
public decimal WeeklySalary { get; set; }
public override decimal Earnings()
{
// a salaried employee's earnings are his/her weekly salary.
return WeeklySalary;
}
public override string ToString()
{
// the standard employee tostring, weekly salary, and earnings
return String.Format("salaried {0}\nweekly salary: {1}\nearnings: {2}\n",base.ToString(),WeeklySalary.ToString("C"),Earnings().ToString("C"));
}
}
}
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Project3", "Project3\Project3.csproj", "{FFA33A1C-42BF-4496-A1B4-1A00294803D4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Debug|x86.ActiveCfg = Debug|x86
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Debug|x86.Build.0 = Debug|x86
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Release|x86.ActiveCfg = Release|x86
{FFA33A1C-42BF-4496-A1B4-1A00294803D4}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
@@ -0,0 +1,43 @@
/*****************************************************************************
* Project 2 will implement a payroll system using abstract classes. *
* *
* A company pays its employees on a weekly basis. The employees are of four *
* types: Salaried employees are paid a fixed weekly salary regardless of the *
* number of hours worked, hourly employees are paid by the hour and receive *
* overtime pay for all hours worked in excess of 40 hours, commission *
* employees are paid a percentage of their sales, and salaried commission *
* employees receive a base salary plus a percentage of their sales. For the *
* current pay period, the company has decided to reward salaried-commission *
* employees by adding 10% to their base salaries. The company wants to *
* implement a C# application that performs its payroll calculations *
* polymorphically. *
* *
* Abstract base class Employee declares the “interface” to the hierarchy— *
* that is, the set of methods that an application can invoke on all *
* employee objects. Each employee, regardless of the way his earnings are *
* calculated has a first name, a last name and a social security number, so *
* private instance variables firstName, lastName and socialSecurityNumber *
* appear in abstract base class Employee. *
* *
* Class Employee provides methods Earnings and ToString, in addition to the *
* properties that manipulate Employee’s instance variables. An Earnings *
* method certainly applies to all employees. But each earnings calculation *
* depends on the employee’s class. So we declare Earnings as abstract in *
* base class Employee. Each derived class overrides Earnings with an *
* appropriate implementation. To calculate an employee’s earnings, the *
* application assigns a reference to the employee’s object to a base class *
* Employee variable, then invokes the Earnings method on that variable. *
* You will maintain an array of Employee variables, each of which holds a *
* reference to an Employee object. The application iterates through the *
* array and calls method Earnings for each Employee object. C# processes *
* theses method calls polymorphically. Including Earnings as an abstract *
* method in Employee forces every directly derived class of Employee to *
* override Earnings with a method that performs an appropriate pay *
* calculation. *
* *
* Method ToString in class Employee returns a string containing the first *
* name, last name, and social security number of the employee. Each derived *
* class of Employee overrides method ToString to create a string *
* representation of an object of that class containing the employee’s type, *
* followed by the rest of the employee’s information. *
*****************************************************************************/
@@ -0,0 +1,85 @@
/******************************************************************************
* Project 3 uses interfaces to extend the payroll system developed *
* in Project 2. *
* *
* Suppose that the company involved wants to perform several accounting *
* operations in a single accounts-payable application—in addition to *
* calculating the payroll earnings that must be paid to each employee, the *
* company must also calculate the payment due on each of several invoices. *
* Though applied to unrelated things, both operations have to do with *
* calculating some kind of payment amount. For an employee, the payment *
* refers to the employee’s earnings. For an invoice, the payment refers to *
* the total cost of the goods listed on the invoice. Can we calculate such *
* different things as the payments due for employees and invoices *
* polymorphically in a single application? Does C# offer a capability that *
* requires that unrelated classes implement a set of common methods? C# *
* interfaces offer exactly this capability. *
* *
* Interfaces define and standardize the ways in which people and systems can *
* interact with each other. For example, the controls on a radio serve as an *
* interface between a user and the radio’s internal components. The controls *
* allow users to perform a limited set of operations (e.g., changing the *
* station, adjusting the volume, choosing between AM and FM), and different *
* radios may implement the controls in different ways (e.g., using push *
* buttons, dials, voice commands). The interface specifies what operations a *
* radio must permit users to perform but does specify how the operations are *
* performed. Similarly, the interface between a driver and a car with a *
* manual transmission includes the steering wheel, the gear shift, the *
* clutch pedal, the gas pedal and the brake pedal. This same interface is *
* found in nearly all manual-transmission cars, enabling someone who knows *
* how to drive one particular manual-transmission car to drive just about *
* any manual-transmission car. The components may look a bit different, but *
* the general purpose is the same—to allow people to drive the car. *
* *
* Software objects also communicate via interfaces. A C# interface describes *
* a set of methods that can be called on an object, to tell the object to *
* perform some task or return some piece of information, for example. The *
* next part of Project Two introduces an interface named IPayable that *
* describes the functionality of any object that must be capable of being *
* paid and thus must offer a method to determine the proper amount due. an *
* interface declaration begins with the keyword interface and can contain *
* only abstract methods, properties, indexers, and events. All interface *
* members are implicitly declared both public and abstract. In addition, *
* each interface can extend one or more other interfaces to create a more *
* elaborate interface that other classes can implement. *
* *
* To use an interface, a class must specify that it implements the *
* interface by listing the interface after the colon ( : ) in the class *
* declaration. Note that this is the same syntax used to indicate *
* inheritance from a base class. A class implementing the interface must *
* declare each member of the interface with the signature specified in the *
* interface declaration. A class the implements an interface but does not *
* implement all the interface’s members is an abstract class—it must be *
* declared abstract and must contain an abstract declaration for each *
* unimplemented member of the interface. Implementing an interface is like *
* signing a contract with the compiler that states, “I will provide an *
* implementation for all the members specified by the interface, or I will *
* declare them abstract.” *
* *
* An interface is typically used when unrelated classes need to share common *
* methods. This allows objects of unrelated classes to be processed *
* polymorphically—objects of classes that implement the same interface can *
* respond to the same method calls. Programmers can create an interface that *
* describes the desired functionality, then implement this interface in any *
* classes requiring that functionality. For example, in the accounts-payable *
* application for this project, we implement interface IPayable in any class *
* that must be able to calculate a payment amount. *
* *
* An interface often is used in place of an abstract class when there is no *
* default implementation to inherit—that is, no fields and no default method *
* implementations. Like public abstract classes, interfaces are typically *
* public types, so they are normally declared in files by themselves with *
* the same name as the interface and the .cs filename extension. *
* *
* To build an application that can determine payments for employees and *
* invoices, you will create an interface named IPayable. Interface IPayable *
* contains method GetPaymentAmount that returns a decimal amount that must *
* be paid for an object of any class that implements the interface. Method *
* GetPaymentAmount is a general purpose version of method Earnings of the *
* Employee hierarchy—method Earnings calculates a payment amount specifically*
* for an Employee, while GetPaymentAmount can be applied to a broad range of *
* unrelated objects. After declaring interface IPayable, you will create *
* class Invoice, which implements interface IPayable. Finally, you will *
* update Employee derived classs SalariedEmployee to ‘fit’ into the IPayable *
* hierarchy. *
******************************************************************************/
@@ -0,0 +1,43 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for hybrid *
* commission/salary based employees. *
* For further description please see ARCHITECTURE2.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project3
{
public class BasePlusCommissionEmployee : CommissionEmployee
{
// overloaded constructor to call the Commission Employee's overloaded constructor
public BasePlusCommissionEmployee(string FirstName, string LastName, string SSN, double ComissionRate, decimal GrossSales, decimal basesalary)
: base(FirstName, LastName, SSN, ComissionRate, GrossSales)
{
BaseSalary = basesalary;
}
public decimal BaseSalary { get; set; }
public override decimal Earnings()
{
// a salary/commission employee's wage is their salary + commission rate * gross sales
return (((decimal)ComissionRate * GrossSales) + BaseSalary);
}
// override the tostring method.
public override string ToString()
{
// report employee tostring, gross sales, commission rate, and base salary
return String.Format("base salaried commission employee: {0} {1}\nssn: {2}\ngross sales: {3}\ncommission rate: {4}\nbase salary: {5}\nearnings: {6}\n", FirstName, LastName, SocialSecuityNumber, GrossSales.ToString("C"), ComissionRate.ToString("F2"), BaseSalary.ToString("C"), Earnings().ToString("C"));
// NOTE: we couldn't use the base.tostring method because it outputs commission employee strings.
}
}
}
@@ -0,0 +1,57 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for *
* commission based employees. *
* For further description please see ARCHITECTURE2.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project3
{
public class CommissionEmployee : Employee
{
// the main overloaded constructor, also call the base class Employee with it's overloaded constructor.
public CommissionEmployee(string FirstName, string LastName, string SSN, double comissionrate, decimal grosssales ) : base( FirstName, LastName, SSN)
{
ComissionRate = comissionrate;
GrossSales = grosssales;
}
// constructor to pass an employee and arguments, if necessary.
public CommissionEmployee(Employee empn, double comissionrate, decimal grosssales) : base (empn)
{
ComissionRate = comissionrate;
GrossSales = grosssales;
}
// constructor to pass an entire commission employee if necessary.
public CommissionEmployee(CommissionEmployee empn) : base (empn)
{
ComissionRate = empn.ComissionRate;
GrossSales = empn.GrossSales;
}
public double ComissionRate { get; set; }
public decimal GrossSales { get; set; }
public override decimal Earnings()
{
// a commission employee's earnings are the commission rate * gross sales
return ((decimal)ComissionRate * GrossSales);
}
// override the tostring method
public override string ToString()
{
// the base tostring, gross sales, commission rate, and earnings
return String.Format("commission {0}\ngross sales: {1}\ncommission rate: {2}\nearnings: {3}\n", base.ToString(), GrossSales.ToString("C"), ComissionRate.ToString("F2"), Earnings().ToString("C"));
}
}
}
@@ -0,0 +1,56 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Houses the main driver for the program. Instantiates an *
* array of 10 Employees that demonstrates polymorphic behavior *
* For further description please see ARCHITECTURE2.txt *
*****************************************************************************/
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace Project3
{
public abstract class Employee : IPayable
{
// empty constructor, don't do anything.
public Employee() { }
// main constructor, each value as a parameter.
public Employee(string fname, string lname, string ssn)
{
FirstName = fname; LastName = lname; SocialSecuityNumber = ssn;
}
// we have the flexibility to pass in an entire new employee if necessary.
public Employee(Employee empn)
{
FirstName = empn.FirstName; LastName = empn.LastName; SocialSecuityNumber = empn.SocialSecuityNumber;
}
public string FirstName { get; set; }
public string LastName { get; set; }
public string SocialSecuityNumber { get; set; }
// abstract. must be implemented by all other inherited classes.
public abstract decimal Earnings();
// implement the IPayable interface in the employee class
// this was the easiest thing to do since Earnings() already exists.
public decimal GetPaymentAmount() // this is a project 3 addition
{
return Earnings();
}
// override the tostring. this is the base tostring.
public override string ToString()
{
// The standard employee: employee first name, last name, and social security number
return String.Format("employee: {0} {1}\nssn: {2}", FirstName, LastName, SocialSecuityNumber);
}
}
}
@@ -0,0 +1,67 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for hourly *
* employees. *
* For further description please see ARCHITECTURE2.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project3
{
public class HourlyEmployee : Employee
{
// main constructor. pass variables to the Employee constructor
public HourlyEmployee(string FirstName, string LastName, string SSN, decimal wage, double hours) : base(FirstName, LastName, SSN)
{
Wage = wage;
Hours = hours;
}
// We can pass in an employee object and extra variables, if necessary
public HourlyEmployee(Employee empn, decimal wage, double hours) : base (empn)
{
Wage = wage;
Hours = hours;
}
// Or we can pass in an entire Hourly Employee and work with that.
public HourlyEmployee(HourlyEmployee empn) : base(empn)
{
Wage = empn.Wage;
Hours = empn.Hours;
}
public decimal Wage { get; set; }
public double Hours { get; set; }
public override decimal Earnings()
{
if (Hours <= 40) // if the employee's hours are less than 40 inclusive
{
return (Wage * 40); // multiply the wage by 40 hours
}
else if (Hours > 40) // if the employee's hours are more than 40
{
return (decimal)(40 * (double)Wage + (Hours - 40) * (double)Wage * 1.5); // the standard wage + time and a half for all hours over 40
}
else // this should never happen.
{
return 0;
}
}
// override the tostring
public override string ToString()
{
//the standard employee tostring, hourly wage, hours worked, and earnings
return String.Format("hourly {0}\nhourly wage: {1}\nhours worked: {2}\nearnings: {3}\n", base.ToString(), Wage.ToString("C"), Hours.ToString("F2"), Earnings().ToString("C"));
}
}
}
@@ -0,0 +1,24 @@
/*****************************************************************************
* Project: 3 - Payroll Interface *
* Description: Implement a payroll system using abstract classes and *
* interfaces *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the required functions to be implemented in *
* classes that implement this interface *
* For further description please see ARCHITECTURE3.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project3
{
interface IPayable
{
// GetPaymentAmount() must be implemented by everyone who uses this interface
decimal GetPaymentAmount();
}
}
@@ -0,0 +1,39 @@
/*****************************************************************************
* Project: 3 - Payroll Interface *
* Description: Implement a payroll system using abstract classes and *
* interfaces *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for a *
* generic Invoice and accounts payable interface. *
* For further description please see ARCHITECTURE3.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project3
{
class Invoice : IPayable
{
// default constructor
public Invoice() { }
// the main constructor, sets payment right away
public Invoice(decimal payment)
{
PaymentAmount = payment;
}
// implement the IPayable interface
public decimal PaymentAmount { get; set; }
// return the payment amount variable for the interface
public decimal GetPaymentAmount()
{
return PaymentAmount;
}
}
}
@@ -0,0 +1,87 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Houses the main driver for the program. Instantiates an *
* array of 10 Employees that demonstrates polymorphic behavior *
* For further description please see ARCHITECTURE2.txt *
*****************************************************************************/
using System;
using System.Collections;
using System.Linq;
using System.Text;
namespace Project3
{
public partial class Program
{
static void Main(string[] args)
{
// Use an array list to house our employees.
ArrayList empn = new ArrayList();
// generate 5 to 30 random employees..
int highOrder = RandNumber(5, 30);
Console.WriteLine("Generating {0} Employees...", highOrder);
// loop though the random number above
for (int i = 0; i < highOrder; i++)
{
int thisN = RandNumber() % 5; // Generate a random number between 1 and the max integer size moded by 5 (to generate a number 1-4)
switch (thisN)
{
case 4: // BasePlus
empn.Add(new BasePlusCommissionEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), RandDouble(), (decimal)RandDouble(), (decimal)RandDouble()));
break;
case 3: // Commission
empn.Add(new CommissionEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), RandDouble(), (decimal)RandDouble()));
break;
case 2: // Salary
empn.Add(new SalariedEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), (decimal)RandDouble()));
break;
default: // Hourly
empn.Add(new HourlyEmployee(GenerateFirstName(), GenerateLastName(), GenerateSSN(), (decimal)RandDouble(), RandDouble()));
break;
}
}
// Loop through the new array list.
for (int i = 0; i < empn.Count; i++ )
{
Console.WriteLine("\n================Employee #: {0}================", (i + 1)); // spit out the sequence number
Console.WriteLine(empn[i]); // tostring method. so much easier.
Console.WriteLine("GetPaymentAmount(): {0}", ((Employee)empn[i]).GetPaymentAmount().ToString("C")); // project 3 change
// remind me to always override the tostring() method.
}
/**************************begin project 3 changes****************/
// make an array list to satisfy the project 3 requirements
ArrayList invoices = new ArrayList();
// generate a new highOrder for invoices. between 5 and 30 again
highOrder = RandNumber(5, 30);
// add a random amount of invoices with a random value to our array list
for (int i = 0; i < highOrder; i++)
{
invoices.Add(new Invoice((decimal)RandDouble())); //instantiate a new Invoice with a new random value
}
// loop through our newly added invoices
for (int i = 0; i < invoices.Count; i++)
{
Console.WriteLine("\n================Invoice #: {0}================", (i + 1)); // output sequence number
Console.WriteLine("GetPaymentAmount: {0}", ((Invoice)invoices[i]).GetPaymentAmount().ToString("C")); // and information
}
// courtesy line and direction.
Console.WriteLine("\n----------------------------------------\nPress ENTER to continue");
// let's keep the console from closing.
Console.ReadLine();
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{FFA33A1C-42BF-4496-A1B4-1A00294803D4}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Project3</RootNamespace>
<AssemblyName>Project3</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<StartupObject>Project3.Program</StartupObject>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="BasePlusCommissionEmployee.cs" />
<Compile Include="Invoice.cs" />
<Compile Include="CommissionEmployee.cs" />
<Compile Include="Employee.cs" />
<Compile Include="HourlyEmployee.cs" />
<Compile Include="IPayable.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RandomThings.cs" />
<Compile Include="SalariedEmployee.cs" />
</ItemGroup>
<ItemGroup>
<None Include="ARCHITECTURE3.txt" />
</ItemGroup>
<ItemGroup>
<None Include="ARCHITECTURE2.txt" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.0,Profile=Client">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4 Client Profile %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Project2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Coleman University")]
[assembly: AssemblyProduct("Project2")]
[assembly: AssemblyCopyright("Copyright © Coleman University 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("49380830-1af5-4d23-9477-5145a019c8bf")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,80 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Houses the random functions found in the file Program.cs *
* The functions RandNumber(), RandDouble(), GenerateFirstName(), and *
* GenerateLastName() can all be found in this file. *
* For further description please see ARCHITECTURE2.txt *
*****************************************************************************/
using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project3
{
public partial class Program
{
// generate a random number from 0 to the maximum value an integer can hold. Positive values.
public static int RandNumber(int Low = 0, int High = int.MaxValue)
{
Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber));
int rnd = rndNum.Next(Low, High);
return rnd;
}
// generate a random floating point double. positive values.
public static double RandDouble()
{
Random rndNum = new Random(int.Parse(Guid.NewGuid().ToString().Substring(0, 8), NumberStyles.HexNumber));
double rnd = rndNum.NextDouble() * 28;
if (rnd < 20) // make all numbers greater than 20.
{
rnd *= RandDouble();
}
return rnd;
}
// grab a random firstname from this string array.
public static string GenerateFirstName()
{
string[] firstnames = { "Librada","Jeanne","Krishna","Roni","Kisha","Edison","Freda","Jed","Lorraine","Nelda","Corine","Lien","Daisy","Gita","Suzy","Gwyneth","Krysta","Erinn","Samual","Barney","Rosia","Malik","Franchesca","Cherryl","Ricardo","Inga","Lesley","Kory","Jaunita","Lacey","Chelsie","Kera","Isaac","Aracely","Delmy","Maggie","Rolland","Estela","Otha","Arturo","Devona",
"Wilton","Karey","Hillary","Jared","Tiffiny","Boris","Flavia","Rivka","Casimira","Adria","Odette","Wilbert","Xuan","Allyson","Rosendo","Elijah","Tad","Malisa","Kayleen","Jone","Reina","Laraine","Len","Leora","Fred","Sydney","Sona","Thuy","Sage","Sixta","Joseph","Chantell","Kiesha","Kacie","Maryellen","Fidelia","Anastasia","Stephaine","Johanne","Charlesetta",
"Crista","Jarod","Sherrell","Sebrina","Juliet","Charise","Candida","Jonnie","Daine","Jong","Maida","Danilo","Jeneva","Margret","Domenic","Luanna","Nana","Salley","Hipolito","Sanjuanita","Giuseppina","Domonique","Shayla","Melva","Leora","Ashleigh","Ruben","Delbert","Evelina","Jeanie","Margarett","Marcie","Assunta","Latoria","Jodie","Kenisha","Anamaria","Shirleen",
"Ashton","Yan","Fanny","Vanita","Marlyn","Maryland","Shandi","Adolph","Amina","Manuel","Dawne","Cristine","Alberto","Tabetha","Frida","Awilda","Louann","Karly","Dede","Kristina","Sue","Elissa","Jamika","Margret","Ninfa","Louisa","Vinita","Gigi","Quinn","Maricruz","Jeanmarie","Niesha","Marquita","Hertha","Shawnna","Jetta","Kristel","Shaunta","Kiyoko","Alana","Eduardo",
"Trish","Willa","Darline","Ching","Rosenda","Rufus","Kraig","Tia","Keely","Markita","Georgann","Nicola","Judy","Ignacio","Shantay","Cicely","Astrid","Ladawn","Nia","Babara","Deidre","Geoffrey","Leilani","Lamont","Delphine","Harrison","Anjanette","Zona","Carmen","Hui","Luvenia","Leeann","Marybelle","Shanon","Nicky","Carlene","Laquanda","Aldo","Larisa","Tony",
"Madeleine","Garnett","Shae","Shemika","Erich","Celestina","Foster","Kaitlyn","Mariela","Noe","Rafael","Jesusa","Cole","Lettie","Sherill","Trey","Marg","Shaunda","Randell","Piedad","Marjorie","Verena","Elicia","Mika","Colette","Corene","Veronika","Jerrie","Rosie","Georgene","Serafina","Sherman","Susannah","Annamae","Michell","Kelsey","Rosario","Carolina","Jeanie",
"Lyndia","Ora","Herta","Santa","Erline","Karmen","Griselda","Maud","Linnie","Nicholle","Mistie","Jordan"};
// use the positive random number function above, mod'd by the length to grab a random value
return (firstnames[RandNumber() % firstnames.Length]);
}
// grab a random lastname from this string array.
public static string GenerateLastName()
{
string[] lastnames = { "Ives","Dole","Bechtel","Gilfillan","Fahey","Montrose","Harvin","Arvizo","Letarte","Reidhead","Ahlstrom","Hyneman","Reynoso","Douglass","Prato","Mccutchen","Mohl","Sperry","Greb","Cabell","Laramore","Fujiwara","Arpin","Brumfield","Fortin","Markell","Ballengee","Sanluis","Trickey","Haake","Zirkle","Gaines","Ahern","Lafond","Jude","Robie","Runion","Runyan","Futrell",
"Rather","Kinloch","Rugg","Senecal","Vanhook","Vallance","Stillwell","Haldeman","Thrush","Shomo","Valerius","Cazares","Townley","Rakestraw","Agar","Meinecke","Coll","Redick","Saint","Spight","Mcnaught","Gayman","Yerger","Rivero","Fabela","Wilhoite","Middlebrooks","Jefferys","Massie","Reichel","Lobb","Ristow","Rucks","Heckard","Hosmer","Dingess","Schamber","Hesson",
"Torbett","Goldschmidt","Hayter","Shew","Ugalde","Vicknair","Danks","Tate","Delorme","Ormand","Laughton","Wilkerson","Dickson","Mulvey","Junkin","Camacho","Barsh","Recker","Farnsworth","Gary","Drees","Knoles","Satter","Battin","Costa","Matsumura","Shears","Devinney","Macken","Garrett","Doney","Fulmer","Hoss","Loll","Tanner","Podesta","Asaro","Morningstar","Hilyard",
"Nehls","Fonseca","Eller","Wilkinson","Lamarca","Soliz","Westervelt","Carlino","Kunkle","Loucks","Jansson","Cothren","Darlington","Zahm","Pinegar","Emerick","Tall","Eveland","Umstead","Davisson","Batz","Plata","Ryberg","Beane","Koening","Putz","Daughtrey","Sinha","Gerdes","Arno","Lorch","Shehan","Chenard","Holloway","Castleberry","Bowlin","Battin","Donovan","Calton",
"Huot","Mcmurtrie","Delapp","Lankford","Biel","Kin","Caceres","Ormand","Streicher","Kimbrel","Cornish","Barahona","Southern","Stuart","Stoke","Scharff","Hartwell","Gildersleeve","Tedrick","Rex","Chaudhry","Wetzel","Desai","Ensey","Escobedo","Matranga","Falzone","Ritzman","Marchant","Babin","Friedt","Shoup","Gunder","Seim","Shadrick","Riggs","Moret","Howes","Steenbergen",
"Rodriques","Dries","Jefferson","Hulbert","Menendez","Ellington","Housand","Whitwell","Rearick","Wagnon","Schmitmeyer","Barhorst","Rosenfield","Summerville","Matus","Marrow","Kind","Searfoss","Denn","Appling","Grim","Huffer","Kellen","Roscoe","Garofalo","Simeone","Goucher","Parkhurst","Tarpey","Bassett","Ortman","Segundo","Mattson","Pullum","Kriner","Smiddy","Cohrs",
"Loring","Strebel","Mcnemar","Grossi","Raby","Dubray","Capra","Wittrock","Fazzino","Bedard","Sera","Lisk","Heldt","Barefoot","Heimbach","Hover","Guthrie","Hartigan","Noyes","Jarrard"};
// use the positive random number function above, mod'd by the length to grab a random value
return (lastnames[RandNumber() % lastnames.Length]);
}
// make a random social security number
public static string GenerateSSN()
{
int G1 = RandNumber(1, 1000);
int G2 = RandNumber(1, 100);
int G3 = RandNumber(1, 10000);
// use the string.format and tostring methods to numerically pad each tuple of a social security number
return String.Format("{0}-{1}-{2}", G1.ToString("D3"), G2.ToString("D2"), G3.ToString("D4"));
}
}
}
@@ -0,0 +1,39 @@
/*****************************************************************************
* Project: 2 - Payroll *
* Description: Implement a payroll system using abstract classes *
* Author: Amrit Panesar - 77260 *
* License: Public Domain *
* File description: Contains the member variables and functions for salaried *
* employees. *
* For further description please see ARCHITECTURE2.txt *
*****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project3
{
public class SalariedEmployee : Employee
{
// main constructor for the salaried employee
public SalariedEmployee(string FirstName, string LastName, string SSN, decimal weeklysal) : base(FirstName, LastName, SSN)
{
WeeklySalary = weeklysal;
}
public decimal WeeklySalary { get; set; }
public override decimal Earnings()
{
// a salaried employee's earnings are his/her weekly salary.
return WeeklySalary;
}
public override string ToString()
{
// the standard employee tostring, weekly salary, and earnings
return String.Format("salaried {0}\nweekly salary: {1}\nearnings: {2}\n",base.ToString(),WeeklySalary.ToString("C"),Earnings().ToString("C"));
}
}
}
@@ -0,0 +1,20 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinForms", "WinForms\WinForms.csproj", "{CAE2B321-A68E-499D-A420-8B3B96C7E015}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CAE2B321-A68E-499D-A420-8B3B96C7E015}.Debug|x86.ActiveCfg = Debug|x86
{CAE2B321-A68E-499D-A420-8B3B96C7E015}.Debug|x86.Build.0 = Debug|x86
{CAE2B321-A68E-499D-A420-8B3B96C7E015}.Release|x86.ActiveCfg = Release|x86
{CAE2B321-A68E-499D-A420-8B3B96C7E015}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
+205
View File
@@ -0,0 +1,205 @@
namespace WinForms
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.radioButton2 = new System.Windows.Forms.RadioButton();
this.radioButton1 = new System.Windows.Forms.RadioButton();
this.button1 = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.listBox1 = new System.Windows.Forms.ListBox();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(30, 42);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(125, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Enter Customer Number: ";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(161, 39);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 20);
this.textBox1.TabIndex = 1;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.radioButton2);
this.groupBox1.Controls.Add(this.radioButton1);
this.groupBox1.Location = new System.Drawing.Point(326, 27);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(181, 46);
this.groupBox1.TabIndex = 2;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Account Type";
//
// radioButton2
//
this.radioButton2.AutoSize = true;
this.radioButton2.Location = new System.Drawing.Point(101, 19);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(63, 17);
this.radioButton2.TabIndex = 1;
this.radioButton2.TabStop = true;
this.radioButton2.Text = "Savings";
this.radioButton2.UseVisualStyleBackColor = true;
//
// radioButton1
//
this.radioButton1.AutoSize = true;
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(6, 19);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(70, 17);
this.radioButton1.TabIndex = 0;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "Checking";
this.radioButton1.UseVisualStyleBackColor = true;
//
// button1
//
this.button1.Location = new System.Drawing.Point(482, 105);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 3;
this.button1.Text = "&Display";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(57, 79);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(57, 13);
this.label2.TabIndex = 4;
this.label2.Text = "Customer: ";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(27, 105);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(87, 13);
this.label3.TabIndex = 5;
this.label3.Text = "Acount Number: ";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Location = new System.Drawing.Point(120, 79);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(39, 13);
this.label4.TabIndex = 6;
this.label4.Text = "********";
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(120, 105);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(39, 13);
this.label5.TabIndex = 7;
this.label5.Text = "********";
//
// listBox1
//
this.listBox1.Font = new System.Drawing.Font("OCR A Extended", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listBox1.FormattingEnabled = true;
this.listBox1.ItemHeight = 12;
this.listBox1.Items.AddRange(new object[] {
"Unable to establish and validate the SQL connection.",
"Please correct the error and re-launch the application."});
this.listBox1.Location = new System.Drawing.Point(12, 134);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(545, 220);
this.listBox1.TabIndex = 8;
//
// button2
//
this.button2.Location = new System.Drawing.Point(482, 379);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 9;
this.button2.Text = "&Close";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(569, 414);
this.Controls.Add(this.button2);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.label5);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Review Transactions";
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton radioButton1;
private System.Windows.Forms.RadioButton radioButton2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.Button button2;
}
}
@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WinForms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
if (!SQLInit())
{
textBox1.Enabled = false;
radioButton1.Enabled = false; radioButton2.Enabled = false;
listBox1.Enabled = false;
button1.Enabled = false;
}
else
{
InitControls();
}
}
public void InitControls()
{
listBox1.Items.Clear();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
if (!textBox1.Text.Equals(String.Empty))
{
int id = Convert.ToInt32(this.textBox1.Text);
string acctType = "";
if (radioButton1.Checked)
{
acctType = "C";
}
else
{
acctType = "S";
}
label4.Text = GetCustomerName(id);
label5.Text = GetAccountNumber(id, acctType);
PopulateListBox(label5.Text);
}
else
{
MessageBox.Show("Please enter a customer number", "No Customer number");
}
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WinForms
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WinForms")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Coleman University")]
[assembly: AssemblyProduct("WinForms")]
[assembly: AssemblyCopyright("Copyright © Coleman University 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("ad379435-2304-4b00-b50e-e76781aef660")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1008
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WinForms.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get
{
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinForms.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1008
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WinForms.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
@@ -0,0 +1,254 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace WinForms
{
public partial class Form1
{
public static SqlConnection connection;
public bool SQLInit()
{
connection = new SqlConnection((string)(new SqlCredential("172.16.2.34", "db77260", "daeddb98", "db77260")).ToString());
if (SQLReady())
{
connection.Open();
SqlCommand sql = new SqlCommand(
@"
DECLARE @return_status int;
IF EXISTS
(
SELECT name
FROM sysobjects
WHERE name=N'transactions_t'
AND type='U'
)
BEGIN
SET @return_status = 0
END
ELSE
BEGIN
SET @return_status = 1
END
SELECT 'Return Status' = @return_status;
"
, connection);
if ((int)sql.ExecuteScalar() == 1)
{
MessageBox.Show("Creating transaction table","Notice",MessageBoxButtons.OK,MessageBoxIcon.Information);
sql = new SqlCommand(
@"CREATE TABLE transactions_t
(
transaction_number INT NOT NULL IDENTITY(1,10),
account_number NUMERIC(6),
amount MONEY,
transaction_type CHAR(1),
last_date_modified DATETIME
DEFAULT GETDATE(),
CONSTRATINT INT
PRIMARY KEY CLUSTERED (transaction_number)
)"
, connection);
sql.ExecuteScalar();
sql = new SqlCommand(
@"DECLARE @return_status int;
IF EXISTS
(
SELECT name
FROM sysobjects
WHERE name=N'transactions_t'
AND type='U'
)
BEGIN
SET @return_status = 0
END
ELSE
BEGIN
SET @return_status = 1
END
SELECT 'Return Status' = @return_status;"
, connection);
if ((int)sql.ExecuteScalar() == 1)
{
MessageBox.Show("Error: Table generation failed.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
else
{
sql = new SqlCommand(
@"INSERT INTO transactions_t (account_number, amount, transaction_type) VALUES(2222, 1000, 'D');
INSERT INTO transactions_t (account_number, amount, transaction_type) VALUES(2222, 4000, 'D');
INSERT INTO transactions_t (account_number, amount, transaction_type) VALUES(2222, 3000, 'W');
INSERT INTO transactions_t (account_number, amount, transaction_type) VALUES(3333, 12000, 'D');
INSERT INTO transactions_t (account_number, amount, transaction_type) VALUES(3333, 7000, 'D');
INSERT INTO transactions_t (account_number, amount, transaction_type) VALUES(2222, 10000, 'D');
INSERT INTO transactions_t (account_number, amount, transaction_type) VALUES(3333, 4000, 'W');
INSERT INTO transactions_t (account_number, amount, transaction_type) VALUES(3333, 3000, 'D');
",connection);
sql.ExecuteScalar();
MessageBox.Show("Sample data inserted correctly","Notice",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
return true;
}
else
{
return false;
}
}
public bool SQLReady()
{
if (connection == null) { return false; }
try
{
connection.Open();
var canOpen = connection.State == ConnectionState.Open;
connection.Close();
return canOpen;
}
catch
{
return false;
}
}
public bool ConnIsOpen()
{
var canOpen = connection.State == ConnectionState.Open;
return canOpen;
}
public string GetCustomerName(int custId)
{
SqlCommand sql = new SqlCommand(@"SELECT customer_name FROM customers_t WHERE customer_id = " + custId.ToString(), connection);
string name = "";
if (!ConnIsOpen())
{
connection.Open();
}
try
{
name = sql.ExecuteScalar().ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (ConnIsOpen())
{
connection.Close();
}
}
return name;
}
public string GetAccountNumber(int custId, string acctType)
{
string accountNumber = "";
if (!ConnIsOpen())
{
connection.Open();
}
SqlCommand sql = new SqlCommand(@"SELECT account_number FROM accounts_t WHERE customer_id = " + custId.ToString() + " AND account_type = '" + acctType + "'", connection);
try
{
accountNumber = sql.ExecuteScalar().ToString();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (ConnIsOpen())
{
connection.Close();
}
}
return accountNumber;
}
public void PopulateListBox(string acct_num)
{
decimal totalDeposits = 0.00M;
decimal totalWithdrawals = 0.00M;
string strAmount = "";
listBox1.BeginUpdate();
listBox1.Items.Add("Deposits".PadLeft(19) + "Withdrawals".PadLeft(14));
SqlDataAdapter da = null;
DataSet ds = null;
DataTable dt = null;
string query = @"
SELECT transaction_type, amount
FROM transactions_t
WHERE account_number = " + acct_num;
if (!ConnIsOpen())
{
connection.Open();
}
da = new SqlDataAdapter(query, connection);
ds = new DataSet();
da.Fill(ds, "transactions_t");
dt = ds.Tables["transactions_t"];
foreach (DataRow row in dt.Rows)
{
if (row["transaction_type"].Equals("D"))
{
totalDeposits += Convert.ToDecimal(row["amount"]);
strAmount = String.Format("+{0:N}", row["amount"]);
listBox1.Items.Add(strAmount.PadLeft(19));
}
else
{
totalWithdrawals += Convert.ToDecimal(row["amount"]);
strAmount = String.Format("-{0:N}", row["amount"]);
listBox1.Items.Add("".PadLeft(19) + strAmount.PadLeft(14));
}
}
listBox1.Items.Add("Total:" + String.Format("{0:N}", totalDeposits).PadLeft(13) +
String.Format("{0:N}", totalWithdrawals).PadLeft(14));
listBox1.EndUpdate();
}
}
class SqlCredential
{
public string Server { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Database { get; set; }
public SqlCredential(string server, string username, string password, string database)
{
Server = server;
Username = username;
Password = password;
Database = database;
}
public override string ToString()
{
return string.Format("Server={0};UID={1};PWD={2};Database={3}",Server,Username,Password,Database);
}
}
}
@@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{CAE2B321-A68E-499D-A420-8B3B96C7E015}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WinForms</RootNamespace>
<AssemblyName>WinForms</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SQLStuff.cs">
<SubType>Form</SubType>
</Compile>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>