Course

  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Course as PDF for free.

More details

  • Words: 5,658
  • Pages: 35
λ //To Dispose namespace FuD2 { partial class MainForm : System.Windows.Forms.Form { /// <summary> /// Designer variable used to keep track of non-visual components. /// private System.ComponentModel.IContainer components = null; /// <summary> /// Disposes resources used by the form. /// /// <param name="disposing">true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); } /// <summary> /// This method is required for Windows Forms designer support. /// Do not change the method contents inside the source code editor. The Forms designer might /// not be able to load this method if it was changed manually. /// private void InitializeComponent() { // // MainForm // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Text = "SSAS"; this.Name = "MainForm"; } } }

λ //Assembly Info using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // // // // //

Information about this assembly is defined by the following attributes. change them to the information which is associated with the assembly you compile.

[assembly: [assembly: [assembly: [assembly: [assembly: [assembly: [assembly: [assembly:

AssemblyTitle("FuD2")] AssemblyDescription("")] AssemblyConfiguration("")] AssemblyCompany("")] AssemblyProduct("FuD2")] AssemblyCopyright("")] AssemblyTrademark("")] AssemblyCulture("")]

// This sets the default COM visibility of types in the assembly to invisible. // If you need to expose a type to COM, use [ComVisible(true)] on that type. [assembly: ComVisible(false)] // The assembly version has following format : // // Major.Minor.Build.Revision // // You can specify all values by your own or you can build default build and revision // numbers with the '*' character (the default): [assembly: AssemblyVersion("1.0.*")]

λ Data Handling Class using using using using

System; System.Drawing; System.Windows.Forms; System.IO;

namespace FuD2 { /// <summary> /// This is my data interchance class and will hold all the methods /// needed /// public class BushidoData { public int CountRecords(string FilePath) { int c = 0; StreamReader r = new StreamReader(FilePath); while(r.EndOfStream == false) { c++; r.ReadLine(); } r.Close(); return c; } public int CountFields(string FilePath, char SplitChar) { int c = 0; StreamReader r = new StreamReader(FilePath); string buf = r.ReadLine(); foreach(char ch in buf) { if(ch == SplitChar) { c++; } } r.Close(); return c; } public void UpdateRecords(string FilePath, string Record, string Index, char Seperator) { string[,] Data = To2DArray(FilePath, Seperator); string buf = null; StreamWriter w = new StreamWriter(FilePath); for(int i = 0; i < Data.GetUpperBound(0) + 1; i++) { if(Data[i,0] == Index) { w.WriteLine(Record); } else { for(int j = 0; j < Data.GetUpperBound(1)+1;j++) { buf = string.Concat(buf, Data[i,j], '#'); } w.WriteLine(buf); }

buf = null; } w.Close(); } public void InsertRecord(string FilePath, string Record, char SplitChar) { string[] Data = new string[CountRecords(FilePath) + 1]; int c = 0; StreamReader r = new StreamReader(FilePath); while(r.EndOfStream == false) { Data[c] = r.ReadLine(); c++; } Data[c] = Record; r.Close(); r.Dispose(); StreamWriter w = new StreamWriter(FilePath); foreach(string s in Data) { w.WriteLine(s); } w.Close(); } public string[,] To2DArray(string FilePath, char SplitChar) { StreamReader r = new StreamReader(FilePath); int c = 0; while(r.EndOfStream == false) { c++; r.ReadLine(); } if(c == 0) { MessageBox.Show("There are no entries!!!! w00t!"); return null; } string[] FirstBuffer = new string[c]; r.BaseStream.Position = 0; c = 0; while(r.EndOfStream == false) { FirstBuffer[c] = r.ReadLine(); c++; } int d = 0; foreach(char ch in FirstBuffer[0]) { if(ch == '#') { d++; } } string[,] OutTime = new string[c,d+1]; string[] SecondBuffer; for(int i = 0; i < c; i++) { SecondBuffer = FirstBuffer[i].Split(SplitChar);

for(int j = 0; j < SecondBuffer.Length; j++) { OutTime[i,j] = SecondBuffer[j]; } } r.Close(); return OutTime; } public void ExpandFormY(Form Fm, int HeightToBe) { if(HeightToBe > Fm.Height) { while(Fm.Height != HeightToBe) { Fm.Size = new Size(300, Fm.Height+1); } } else { while(Fm.Height != HeightToBe) { Fm.Size = new Size(300, Fm.Height-1); } } } public void Write2D(string FilePath, string[,] Data, char SplitChar) { StreamWriter w = new StreamWriter(FilePath); string Buffer = null; for(int i = 0; i < Data.GetUpperBound(0) + 1; i++) { if(Data[i,0] != null) { for(int j = 0; j < Data.GetUpperBound(1) + 1; j ++) { Buffer = string.Concat(Buffer, Data[i,j], SplitChar); } w.WriteLine(Buffer); } Buffer = null; } w.Close(); } public void SetUpSeachSection(Button b, TextBox a, ComboBox c, CheckBox d, string[] FieldNames, int LocToBe) { a.Location = new Point(10, LocToBe + a.Height); a.Size = new Size(280, a.Height); c.Location = new Point(10, a.Bottom + 20); c.Size = new Size(100, c.Height); d.Location = new Point(240 - (d.Width/2), c.Top); b.Location = new Point(100, c.Bottom + 20); b.Size = new Size(100, b.Height); b.Text = "Search"; d.Text = "Exact Search?"; foreach(string s in FieldNames) { c.Items.Add(s); } }

public void RemoveRecord(string PathName, string Id, char SplitChar) { StreamReader r = new StreamReader(PathName); string[] Records = new string[CountRecords(PathName)]; int i = 0; while(r.EndOfStream == false) { Records[i] = r.ReadLine(); i++; } r.Close(); StreamWriter w = new StreamWriter(PathName); string Buf = null; foreach(string s in Records) { foreach(char c in s) { if(c != SplitChar) { Buf += c; } else { break; } } if(Buf != Id) { w.WriteLine(s); } Buf = null; } w.Close(); } public string GenerateId(string FileName, char SplitChar) { StreamReader r = new StreamReader(FileName); string buffer = null; string ForOut = null; while(r.EndOfStream == false) { buffer = r.ReadLine(); } foreach(char c in buffer) { if(c != SplitChar) { ForOut += c; } else { break; } } return (int.Parse(ForOut) + 1).ToString(); } public string[] ReadInField(string PathName, int Field, char SplitChar) { string[] ForOut = new string[CountRecords(PathName)]; string[] Buffer2 = new string[CountFields(PathName, '#')]; string Buffer = null; StreamReader r = new StreamReader(PathName);

int i = 0; while(r.EndOfStream == false) { Buffer = r.ReadLine(); Buffer2 = Buffer.Split('#'); ForOut[i] = Buffer2[Field]; i++; } return ForOut; } public bool Validate(char In, int Type, int Len) { bool buf = false; switch(Type) { case 0: if(Len >= 11) { buf = true; } if(char.IsNumber(In) == false) { buf = true; } buf = false; break; case 1: if(Len >= 7) { return true; } switch(Len) { case 0: if(char.IsLetter(In) { buf = true; } break; case 1: if(char.IsLetter(In) { buf = true; } break; case 2: if(char.IsNumber(In) { buf = true; } break; case 3: if(char.IsNumber(In) { buf = true; } break; case 4: if(char.IsNumber(In) { buf = true; } break;

== false)

== false)

== false)

== false)

== false)

case 5: if(char.IsLetter(In) == false) { buf = true; } break; case 6: if(char.IsLetter(In) == false) { buf = true; } break; } break; } return buf; } public string[,] Where2DData(string[,] Data, int field, string Condition, bool Exact) { int c = 0; bool Counting = true; bool DoOnce = false; string[,] DataOut = new string[1,1]; for(int i = 0; i < Data.GetUpperBound(0)+1; i++) { if(Exact == true) { if(Counting == true) { if(Data[i, field] == Condition) { c++; if(i == Data.GetUpperBound(0)) { Counting = false; } } } else { if(DoOnce == false) { DataOut = new string[c, Data.GetUpperBound(1) + 1]; c = 0; DoOnce = true; } else { if(Data[i, field] == Condition) { for(int d = 0; d < Data.GetUpperBound(1)+1; d++) { DataOut[c, d] = Data[i,d]; } c++; } } } }

else { if(Counting == true) { if(Data[i, field] == Condition) { c++; if(i == Data.GetUpperBound(0)) { Counting = false; } } } if(DoOnce == false) { DataOut = new string[c, Data.GetUpperBound(1) + 1]; c = 0; DoOnce = true; } else { if(Data[i, field].Contains(Condition) == true) { for(int d = 0; d < Data.GetUpperBound(1) + 1; d++) { DataOut[c, d] = Data[i,d]; } c++; } } } } return DataOut; } } }

λ //Form itself //This is a FuD. Fuck you Dale. using using using using using using using

System; System.Collections.Generic; System.Drawing; System.Windows.Forms; System.IO; System.Data; System.Threading;

namespace FuD2 { /// <summary> /// Description of MainForm. /// public partial class MainForm { [STAThread] public static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } //Globals BushidoData Ops = new BushidoData(); int Invalidateda = 5; int Mode = 0; int SalesSelection = 0; int CustomerSelection = 0; int SiteSelection = 0; int CompanySelection = 0; int ForecastSelection = 0; int[] LL2; int[] LL3; int[] LL4; int Si = 0; int IdBuffer = 0; bool Admin = false; bool SalesSearchExact = false; bool[] LL; string SalesTbl = "C:\\Program Files\\SSAS\\Data\\TblSales.FuD"; string CompanyTbl = "C:\\Program Files\\SSAS\\Data\\TblCompanies.FuD"; string CustomersTbl = "C:\\Program Files\\SSAS\\Data\\TblCustomers.FuD"; string SitesTbl = "C:\\Program Files\\SSAS\\Data\\TblSites.FuD"; string ForecastTbl = "C:\\Program Files\\SSAS\\Data\\TblForecasts.FuD"; string[] Lab1 = {"Id Number", "First Name", "Last Name", "Mobile Number", "Work Number", ""}; string[] Lab2 = {"Id Numer", "Site Name", "Address Line 1", "Address Line 2", "Address Line 3", "PostCode"}; string EncryptionKey = null; string SalesSearchString = null; string[,] DataNow; string[,] DataMore; string[,] DataMany; Label[] Labs;

TextBox GlobalTb; TextBox GlobalTb2; CheckBox GlobalCheck; ComboBox GlobalCombo; Button GlobalButton; TextBox[] GlobalTbs; ListBox SearchResults; ListBox[] GlobalListBoxes; Button[] GlobalButtons; ComboBox[] GlobalComboBox; public MainForm() { SetUpOpening(); } void SetUpOpening() { BushidoData d = new BushidoData(); this.Size = new Size(305,305); PictureBox Menu = new PictureBox(); Menu.Size = new Size(305,150); Menu.Location = new Point(-5, 0); Menu.Image = new Bitmap(string.Concat("C:\\Program Files\\SSAS\\GUI\\SunHeader.jpg")); Menu.Name = "Header"; Menu.Click += new EventHandler(OtherBacktracker); this.BackColor = Color.Black; this.Controls.Add(Menu); this.ForeColor = Color.White; Button LoginAdmin = new Button(); Button LoginSales = new Button(); LoginAdmin.Location = new Point(0,175); LoginAdmin.Size = new Size(this.Width - 7, 25); LoginSales.Size = new Size(this.Width - 7, 25); LoginSales.Location = new Point(0, 225); LoginSales.Text = "Sales Login"; LoginSales.TextAlign = ContentAlignment.MiddleCenter; LoginAdmin.Text = "Administrator Login"; LoginAdmin.TextAlign = ContentAlignment.MiddleCenter; this.Controls.Add(LoginAdmin); this.Controls.Add(LoginSales); LoginAdmin.Click += new EventHandler(LoginAsAdmin); LoginSales.Click += new EventHandler(LoginAsSales); Mode = 1; } void LoginAsAdmin(object sender, EventArgs e) { Admin = true; Login(); } void LoginAsSales(object sender, EventArgs e) { Login(); } void DisposeControls() { for(int i = 0; i < this.Controls.Count+1; i++) { foreach(Control c in this.Controls) { if(c.Name != "Header") { this.Controls.Remove(c); c.Dispose();

} } } } TextBox[] Inputs = new TextBox[3]; void Login() { Button Login = new Button(); DisposeControls(); Inputs[0] = new TextBox(); Inputs[1] = new TextBox(); Inputs[1].PasswordChar = '*'; Inputs[2] = new TextBox(); string[] Labs = new string[3]; Labs[0] = "User Name"; Labs[1] = "Password"; Labs[2] = "Encryption Key"; while(this.Height != 450) { this.Size = new Size(305, this.Height + 1); } DeployTbs(Inputs, 150, Labs); if(Admin == false) { Inputs[2].Enabled = false; } Inputs[2].Text = EncryptionKey; Button TestLogin = new Button(); TestLogin.Click += new EventHandler(TestEntry); TestLogin.TextAlign = ContentAlignment.MiddleCenter; TestLogin.Text = "Login"; this.Controls.Add(TestLogin); TestLogin.Size = new Size(295, 25); while(TestLogin.Location.Y != Inputs[Inputs.GetUpperBound(0)].Bottom + 25) { TestLogin.Location = new Point(0, TestLogin.Location.Y + 1); } Mode = 2; } void TestEntry(object sender, EventArgs e) { if(Admin == true) { if(Inputs[0].Text != "Admin") { MessageBox.Show("Only Administrators may log in here, please use the other login page for sales people"); return; } } BushidoData d = new BushidoData(); string[] Passwords = new string[d.CountRecords(SalesTbl)]; string[] Usernames = new string[Passwords.Length]; string[,] TotalData = d.To2DArray(SalesTbl, '#'); for(int i = 0; i < Passwords.Length; i++) { Usernames[i] = TotalData[i, 2]; Passwords[i] = TotalData[i, 5];

} for(int i = 0; i< Passwords.Length; i++) { if(Inputs[0].Text == Usernames[i]) { if(Usernames[i] == "Admin") { if(Admin == true) { if(Inputs[1].Text == Passwords[i]) { MoveToMenuMode(); EncryptionKey = Inputs[2].Text; return; } } } if(Inputs[0].Text == Usernames[i]) { if(Inputs[1].Text == Passwords[i]) { MoveToMenuMode(); return; } } } } Invalidateda = Invalidateda - 1; if(Invalidateda > 0) { MessageBox.Show(string.Concat("Sorry, your username or password were incorrect, you have ", Invalidateda.ToString()," attempts remaining before lockout")); } else { MessageBox.Show("Attempts Expired"); this.Close(); } } void MoveToMenuMode() { this.Size = new Size(305, 500); DisposeControls(); Button[] MenuButtons = new Button[6]; string[] Labs = {"Sales Funtions", "Customer Functions", "Company Functions", "Site Functions", "ForecastFunctions", "Report Functions"}; Mode = 3; DeployButtons(MenuButtons, 175, Labs); if(Admin == false) { MenuButtons[0].Enabled = false; } MenuButtons[0].Click += new EventHandler(MoveToSalesMode); MenuButtons[1].Click += new EventHandler(MoveToCustomerMode); MenuButtons[2].Click += new EventHandler(MoveToCompanyMode); MenuButtons[3].Click += new EventHandler(MoveToSiteMode); MenuButtons[4].Click += new EventHandler(MoveToForecastMode); } void MoveToSalesMode(object sender, EventArgs e) { MoveToSalesModeActual(); }

void MoveToSalesModeActual() { this.Size = new Size(305,600); Mode = 4; DisposeControls(); DisposeControls(); Button[] SalesChoices = new Button[4]; string[] Labs = {"Add New", "Search Existing", "Edit Existing", "Delete Existing"}; DeployButtons(SalesChoices, 175, Labs); SalesChoices[0].Click += new EventHandler(AddNewSales); SalesChoices[1].Click += new EventHandler(ViewCurrentSales); SalesChoices[2].Click += new EventHandler(ModifyCurrentSales); SalesChoices[3].Click += new EventHandler(DeleteCurrentSales); } void AddNewSales(object sender, EventArgs e) { Mode = 5; DisposeControls(); GlobalTbs = new TextBox[6]; string[] Labs = {"ID number", "First Name", "Last Name", "Mobile Number", "WorkNumber", "Password"}; DeployTbs(GlobalTbs, 175, Labs); Button Submit = new Button(); Submit.Size = new Size(this.Width - 20, 25); Submit.Location = new Point(10, GlobalTbs[5].Bottom + 20); this.Controls.Add(Submit); Submit.Text = "Submit"; Submit.Click += new EventHandler(SubmitNewSales); GlobalTbs[0].Enabled =false; GlobalTbs[0].Text = Ops.GenerateId(SalesTbl, '#'); GlobalTbs[3].KeyPress += new KeyPressEventHandler(SalesPhoneValidate1); GlobalTbs[4].KeyPress += new KeyPressEventHandler(SalesPhoneValidate2); } void SalesPhoneValidate1(object sender, KeyPressEventArgs e) { e.Handled = Ops.Validate(e.KeyChar, 0, GlobalTbs[3].Text.Length); } void SalesPhoneValidate2(object sender, KeyPressEventArgs e) { e.Handled = Ops.Validate(e.KeyChar, 0, GlobalTbs[4].Text.Length); } void SubmitNewSales(object sender, EventArgs e) { string Record = null; foreach(TextBox t in GlobalTbs) { Record = string.Concat(Record, t.Text, '#'); } Record = Record.Remove(Record.Length - 1, 1); Ops.InsertRecord(SalesTbl, Record, '#'); for(int i = 1; i < GlobalTbs.Length;i++) { GlobalTbs[i].Text = null; } GlobalTbs[0].Text = (int.Parse(GlobalTbs[0].Text) + 1).ToString(); } void ViewCurrentSales(object sender, EventArgs e)

{ Mode = 5; SalesSelection = 1; SetUpSalesOps(); } void ModifyCurrentSales(object sender, EventArgs e) { Mode = 5; SalesSelection = 2; SetUpSalesOps(); } void DeleteCurrentSales(object sender, EventArgs e) { Mode = 5; SalesSelection = 3; SetUpSalesOps(); } void SetUpSalesOps() { DisposeControls(); Button GlobalButton = new Button(); TextBox GlobalTb = new TextBox(); GlobalCheck = new CheckBox(); GlobalCombo = new ComboBox(); string[] FieldStrings = {"Id Number", "First Name", "Last Name", "Mobile Number", "Work Number", "Password"}; this.Controls.Add(GlobalButton); this.Controls.Add(GlobalTb); this.Controls.Add(GlobalCheck); this.Controls.Add(GlobalCombo); Ops.SetUpSeachSection(GlobalButton, GlobalTb, GlobalCombo, GlobalCheck, FieldStrings, 150); GlobalButton.Click += new EventHandler(SearchThroughSales); } void SearchThroughSales(object sender, EventArgs e) { if(GlobalCombo.Text == null) { MessageBox.Show("You must search using a field"); return; } if(GlobalTb.Text == null) { MessageBox.Show("You must search for something!"); return; } Si = GlobalCombo.SelectedIndex; DataNow = Ops.To2DArray(SalesTbl, '#'); bool[] LL = new bool[DataNow.GetUpperBound(0) + 1]; for(int i = 0; i < LL.Length; i++) { if(SalesSearchExact == true) { if(DataNow[i,Si] == SalesSearchString) { LL[i] = true; } } else { if(DataNow[i,Si].Contains(SalesSearchString) == true) {

LL[i] = true; } } } DisposeControls(); SearchResults = new ListBox(); this.Controls.Add(SearchResults); int cc = 0; foreach(bool b in LL) { if(b == true) { cc++; } } LL2 = new int[cc]; cc = 0; foreach(int i in LL2) { SearchResults.Items.Add(DataNow[i, Si]); } SearchResults.Size = new Size(280, 100); SearchResults.Location = new Point(10, 150); this.Size = new Size(300, 700); GlobalTbs = new TextBox[6]; string[] Labs = {"Id Number", "First Name", "Last Name", "Mobile Number", "Work Number", "Password"}; DeployTbs(GlobalTbs, 275, Labs); GlobalTbs[0].Enabled = false; SearchResults.SelectedValueChanged += new EventHandler(ChangeSalesSelection); GlobalButtons = new Button[2]; string[] ButtonLabs = {"Save Changes", "Delete Record"}; DeployButtons(GlobalButtons, GlobalTbs[GlobalTbs.GetUpperBound(0)].Bottom + 25, ButtonLabs); switch(SalesSelection) { case 1: GlobalButtons[0].Enabled = false; GlobalButtons[1].Enabled = false; break; case 2: GlobalButtons[0].Enabled = true; GlobalButtons[1].Enabled = false; break; case 3: GlobalButtons[0].Enabled = true; GlobalButtons[1].Enabled = true; break; } GlobalButtons[0].Click += new EventHandler(SaveSalesChanges); GlobalButtons[1].Click += new EventHandler(DeleteSalesRecord); } void ChangeSalesSelection(object sender, EventArgs e) { for(int i = 0; i < DataNow.GetUpperBound(1) + 1; i++) { GlobalTbs[i].Text = DataNow[LL2[SearchResults.SelectedIndex],i]; } } void SaveSalesChanges(object sender, EventArgs e) {

for(int i = 0; i < GlobalTbs.GetUpperBound(0); i++) { DataNow[int.Parse(GlobalTbs[0].Text), i] = GlobalTbs[i].Text; } Ops.Write2D(SalesTbl, DataNow, '#'); } void DeleteSalesRecord(object sender, EventArgs e) { Ops.RemoveRecord(SalesTbl, GlobalTbs[0].Text, '#'); MoveToSalesModeActual(); } void MoveToCustomerMode(object sender, EventArgs e) { MoveToCustomerModeActual(); } void MoveToCustomerModeActual() { this.Size = new Size(305, 400); Mode = 4; DisposeControls(); DisposeControls(); GlobalButtons = new Button[4]; string[] ButtonLabs = {"Add a New Customer", "View Existing Customers", "Edit Existing Customers", "Delete Existing Customers"}; DeployButtons(GlobalButtons, 150, ButtonLabs); GlobalButtons[0].Click += new EventHandler(AddNewCustomer); GlobalButtons[1].Click += new EventHandler(ViewCurrentCustomer); GlobalButtons[2].Click += new EventHandler(EditCurrentCustomer); GlobalButtons[3].Click += new EventHandler(DeleteCurrentCustomer); } void AddNewCustomer(object sender, EventArgs e) { AddNewCustomerActual(); } void ViewCurrentCustomer(object sender, EventArgs e) { SalesSelection = 1; SetUpCustomers(); } void EditCurrentCustomer(object sender, EventArgs e) { SalesSelection = 2; SetUpCustomers(); } void DeleteCurrentCustomer(object sender, EventArgs e) { SalesSelection = 3; SetUpCustomers(); } void SetUpCustomers() { DisposeControls(); Mode = 6; for(int i = this.Height; i < 700; i++) { this.Size = new Size(305, i); } GlobalButton = new Button(); GlobalTb = new TextBox();

GlobalCombo = new ComboBox(); GlobalCheck = new CheckBox(); this.Controls.Add(GlobalButton); this.Controls.Add(GlobalTb); this.Controls.Add(GlobalCombo); this.Controls.Add(GlobalCheck); string[] FieldNames = {"Id Number", "First Name", "Last Name", "Mobile Number", "Work Number", "Company Affiliation"}; Ops.SetUpSeachSection(GlobalButton, GlobalTb, GlobalCombo, GlobalCheck, FieldNames, 150); GlobalButton.Click += new EventHandler(SearchThroughCustomers); } void SearchThroughCustomers(object sender, EventArgs e) { if(GlobalTb.Text == null) { MessageBox.Show("You must search for a value!"); return; } if(GlobalCombo.Text == null) { MessageBox.Show("You must search using a field"); return; } DataNow = Ops.To2DArray(CustomersTbl, '#'); bool[] LL = new bool[DataNow.GetUpperBound(0)+1]; int cc = 0; for(int i = 0; i < LL.Length; i++) { if(GlobalCheck.Checked == true) { if(GlobalTb.Text == DataNow[i, GlobalCombo.SelectedIndex]) { LL[i] = true; cc++; } } else { if(DataNow[i, GlobalCombo.SelectedIndex].Contains(GlobalTb.Text) == true) { LL[i] = true; cc++; } } } Si = GlobalCombo.SelectedIndex; DisposeControls(); LL2 = new int[cc]; cc = 0; for(int i = 0; i < LL.Length; i++) { if(LL[i] == true) { LL2[cc] = i; cc++; } } SearchResults = new ListBox();

this.Controls.Add(SearchResults); SearchResults.Size = new Size(280,100); SearchResults.Location = new Point(10, 150); for(int i = 0; i < LL.Length; i++) { if(LL[i] == true) { SearchResults.Items.Add(DataNow[i, Si]); } } SearchResults.SelectedIndexChanged += new EventHandler(UpdateCustomerView); GlobalTbs = new TextBox[5]; GlobalCombo = new ComboBox(); string[] FieldNames = {"Id Number", "First Name", "Last Name", "Mobile Number", "Work Number", "Company Affiliation"}; DeployTbs(GlobalTbs, SearchResults.Bottom+25, FieldNames); GlobalCombo.Size = GlobalTbs[0].Size; GlobalCombo.Location = new Point(10, GlobalTbs[4].Bottom+25); this.Controls.Add(GlobalCombo); DataMore = new string[Ops.CountRecords(CompanyTbl), 2]; int j = 0; foreach(string s in Ops.ReadInField(CompanyTbl, 0, '#')) { DataMore[j, 0] = s; j++; } j = 0; foreach(string s in Ops.ReadInField(CompanyTbl, 1, '#')) { DataMore[j, 1] = s; j++; } j = 0; for(int i = 0; i < DataMore.GetUpperBound(0) + 1; i++) { GlobalCombo.Items.Add(DataMore[i,1]); } GlobalButtons = new Button[2]; string[] ButtonLabs = {"Save Changes","Delete Record"}; DeployButtons(GlobalButtons, GlobalCombo.Bottom + 25, ButtonLabs); switch(CustomerSelection) { case 1: GlobalButtons[0].Enabled = false; GlobalButtons[1].Enabled = false; break; case 2: GlobalButtons[0].Enabled = true; GlobalButtons[1].Enabled = false; break; case 3: GlobalButtons[0].Enabled = true; GlobalButtons[1].Enabled = true; break; } GlobalButtons[0].Click += new EventHandler(SaveCustomerChanges); GlobalButtons[1].Click += new EventHandler(DeleteCustomerRecord); }

void UpdateCustomerView(object sender, EventArgs e) { for(int i = 0; i < GlobalTbs.Length; i++) { GlobalTbs[i].Text = DataNow[LL2[SearchResults.SelectedIndex], i]; } for(int i = 0; i < DataNow.GetUpperBound(0) + 1; i++) { int vuf = int.Parse(GlobalTbs[0].Text); if(vuf == int.Parse(DataNow[i,0])) { IdBuffer = i; } } for(int i = 0; i < DataMore.GetUpperBound(0)+1; i++) { if(IdBuffer == int.Parse(DataMore[i,0])) { GlobalCombo.Text = DataMore[i,1]; } } } void AddNewCustomerActual() { Mode = 6; DisposeControls(); Button Submit = new Button(); GlobalTbs = new TextBox[5]; string[] Labs = {"Id Number", "First Name", "LastName", "Mobile Number", "Work Number"}; for(int i = this.Height; i < 600; i++) { this.Size = new Size(305, i); } DeployTbs(GlobalTbs, 150, Labs); GlobalComboBox = new ComboBox[1]; GlobalComboBox[0] = new ComboBox(); this.Controls.Add(GlobalComboBox[0]); DataNow = new string[Ops.CountRecords(CompanyTbl), 2]; int j = 0; foreach(string s in Ops.ReadInField(CompanyTbl, 0, '#')) { DataNow[j, 0] = s; j++; } j = 0; foreach(string s in Ops.ReadInField(CompanyTbl, 1, '#')) { DataNow[j, 1] = s; j++; } j = 0; GlobalComboBox[0].Size = GlobalTbs[0].Size; GlobalComboBox[0].Location = new Point(10, GlobalTbs[4].Bottom + 25); for(int i = 0; i < DataNow.GetUpperBound(0)+1; i++) { GlobalComboBox[0].Items.Add(DataNow[i,1]); } GlobalTbs[0].Enabled = false; GlobalTbs[0].Text = Ops.GenerateId(CustomersTbl, '#'); Submit.Location = new Point(10, GlobalComboBox[0].Bottom +

25); Submit.Size = GlobalComboBox[0].Size; Submit.Click += new EventHandler(SubmitCustomer); Submit.Text = "Submit"; this.Controls.Add(Submit); GlobalTbs[3].KeyPress += new KeyPressEventHandler(CustomerPhoneValidate1); GlobalTbs[4].KeyPress += new KeyPressEventHandler(CustomerPhoneValidate2); } void CustomerPhoneValidate1(object sender, KeyPressEventArgs e) { e.Handled = Ops.Validate(e.KeyChar,0,GlobalTbs[3].Text.Length); } void CustomerPhoneValidate2(object sender, KeyPressEventArgs e) { e.Handled = Ops.Validate(e.KeyChar,0,GlobalTbs[4].Text.Length); } void SubmitCustomer(object sender, EventArgs e) { string Record = null; foreach(TextBox t in GlobalTbs) { Record = string.Concat(Record, t.Text, '#'); } Record = string.Concat(Record, DataNow[GlobalComboBox[0].SelectedIndex, 0]); Ops.InsertRecord(CustomersTbl, Record, '#'); GlobalTbs[0].Text = (int.Parse(GlobalTbs[0].Text) + 1).ToString(); for(int i = 1; i < GlobalTbs.Length; i++) { GlobalTbs[i].Text = null; } } void SaveCustomerChanges(object sender, EventArgs e) { int Id = IdBuffer; for(int i = 1; i < GlobalTbs.GetUpperBound(0); i++) { DataNow[Id, i] = GlobalTbs[i].Text; } if(DataNow[Id, 5] == GlobalCombo.Text) { Ops.Write2D(CustomersTbl, DataNow, '#'); } else { for(int i = 0; i < DataMore.GetUpperBound(0)+1; i++) { if(GlobalCombo.Text == DataMore[i,1]) { DataNow[Id, 5] = DataMore[i,0]; } } Ops.Write2D(CustomersTbl, DataNow, '#'); } } void DeleteCustomerRecord(object sender, EventArgs e)

{ Ops.RemoveRecord(CustomersTbl, GlobalTbs[0].Text, '#'); MoveToCustomerModeActual(); } void MoveToCompanyMode(object sender, EventArgs e) { MoveToCompanyModeActual(); } void MoveToCompanyModeActual() { Mode = 4; DisposeControls(); GlobalButtons = new Button[5]; string[] ButtonLabs = {"Add A New Company", "View Existing Company Details", "View Existing Companies", "Edit Existing Companies", "Delete Existing Companies"}; DeployButtons(GlobalButtons, 150, ButtonLabs); GlobalButtons[0].Click += new EventHandler(AddNewCompany); GlobalButtons[1].Click += new EventHandler(ViewExistingCompany); GlobalButtons[2].Click += new EventHandler(ViewExistingCompanies); GlobalButtons[3].Click += new EventHandler(EditExistingCompanies); GlobalButtons[4].Click += new EventHandler(DeleteExistingCompanies); } void ViewExistingCompanies(object sender, EventArgs e) { CompanySelection = 1; SetUpCompanies(); } void EditExistingCompanies(object sender, EventArgs e) { CompanySelection = 2; SetUpCompanies(); } void DeleteExistingCompanies(object sender, EventArgs e) { CompanySelection = 3; SetUpCompanies(); } void SetUpCompanies() { DisposeControls(); Mode = 7; GlobalButton = new Button(); GlobalCombo = new ComboBox(); GlobalTb = new TextBox(); GlobalCheck = new CheckBox(); this.Controls.Add(GlobalButton); this.Controls.Add(GlobalTb); this.Controls.Add(GlobalCheck); this.Controls.Add(GlobalCombo); string[] Fields = {"Id Number", "Company Name", "Invoice Address Line 1", "Invoice Address Line 2", "Invoice Address Line 3"}; Ops.SetUpSeachSection(GlobalButton, GlobalTb, GlobalCombo, GlobalCheck, Fields, 150); GlobalButton.Click += new EventHandler(SearchThroughCompanies); } void SearchThroughCompanies(object sender, EventArgs e) {

if(GlobalTb.Text == null) { MessageBox.Show("You must search for a value!"); return; } if(GlobalCombo.Text == null) { MessageBox.Show("You must search via a field!"); return; } Si = GlobalCombo.SelectedIndex; DataNow = Ops.To2DArray(CompanyTbl, '#'); bool[] LL = new bool[DataNow.GetUpperBound(0)+1]; if(GlobalCheck.Checked == true) { for(int i = 0; i < LL.Length; i++) { if(GlobalTb.Text == DataNow[i,Si]) { LL[i] = true; } } } else { for(int i = 0; i < LL.Length; i++) { if(DataNow[i,Si].Contains(GlobalTb.Text) == true) { LL[i] = true; } } } int cc = 0; foreach(bool b in LL) { if(b == true) { cc++; } } LL2 = new int[cc]; cc = 0; for(int i = 0; i < LL.Length; i++) { if(LL[i] == true) { LL2[cc] = i; cc++; } } DisposeControls(); this.Size = new Size(300,700); SearchResults = new ListBox(); SearchResults.Location = new Point(10,150); SearchResults.Size = new Size(280,100); this.Controls.Add(SearchResults); foreach(int i in LL2) { SearchResults.Items.Add(DataNow[i,Si]); } GlobalTbs = new TextBox[5]; string[] Labss = {"Id Number", "Company Name", "Invoice

Address Line 1", "Invoice Address Line 2", "Invoice Address Line 3"}; DeployTbs(GlobalTbs, SearchResults.Bottom+25, Labss); GlobalTbs[0].Enabled = false; SearchResults.SelectedIndexChanged += new EventHandler(UpdateCompaniesSearch2); GlobalButtons = new Button[2]; string[] BuLabs = {"Save Change to Record", "Delete Record"}; DeployButtons(GlobalButtons, GlobalTbs[4].Bottom+25, BuLabs); switch(CompanySelection) { case 1: GlobalButtons[0].Enabled = false; GlobalButtons[1].Enabled = false; break; case 2: GlobalButtons[0].Enabled = true; GlobalButtons[1].Enabled = false; break; case 3: GlobalButtons[0].Enabled = true; GlobalButtons[1].Enabled = true; break; } GlobalButtons[0].Click += new EventHandler(SaveChangesCompany); GlobalButtons[1].Click += new EventHandler(DeleteCompanyRecord); } void SaveChangesCompany(object sender, EventArgs e) { String Record = null; foreach(TextBox t in GlobalTbs) { Record = string.Concat(Record, t.Text, '#'); } Record = Record.Remove(Record.Length - 1, 1); Ops.UpdateRecords(CompanyTbl, Record, GlobalTbs[0].Text,'#'); MoveToCompanyModeActual(); } void DeleteCompanyRecord(object sender, EventArgs e) { Ops.RemoveRecord(CompanyTbl, GlobalTbs[0].Text, '#'); MoveToCompanyModeActual(); } void UpdateCompaniesSearch2(object sender, EventArgs e) { Si = SearchResults.SelectedIndex; for(int i = 0; i < GlobalTbs.Length; i++) { GlobalTbs[i].Text = DataNow[LL2[Si], i]; } } void AddNewCompany(object sender, EventArgs e) { Mode = 7; DisposeControls(); GlobalTbs = new TextBox[5]; string[] Labs = {"Company Id", "Company Name", "Invoice Address Line 1", "Invoice Address Line 2", "Invoice Address Line 3"}; DeployTbs(GlobalTbs, 150, Labs); GlobalTbs[0].Text = Ops.GenerateId(CompanyTbl, '#'); GlobalTbs[0].Enabled = false; Button Submit = new Button();

this.Controls.Add(Submit); Submit.Size = new Size(280, Submit.Height); Submit.Location = new Point(10, GlobalTbs[4].Bottom + 25); Submit.Click += new EventHandler(SubmitNewCompany); this.Height = Submit.Bottom + 25; } void SubmitNewCompany(object sender, EventArgs e) { string Record = null; foreach(TextBox t in GlobalTbs) { Record = string.Concat(Record, t.Text, '#'); } Record = Record.Remove(Record.Length-1, 1); Ops.InsertRecord(CompanyTbl, Record, '#'); int Bleh = int.Parse(GlobalTbs[0].Text) + 1; GlobalTbs[0].Text = Bleh.ToString(); for(int i = 1; i < GlobalTbs.Length; i++) { GlobalTbs[i].Text = null; } } void ViewExistingCompany(object sender, EventArgs e) { DisposeControls(); Mode = 7; GlobalButton = new Button(); GlobalCheck = new CheckBox(); GlobalCombo = new ComboBox(); GlobalTb = new TextBox(); string[] Labs = {"Company Id", "Company Name", "Invoice Address Line 1", "Invoice Address Line 2", "Invoice Address Line 3"}; this.Controls.Add(GlobalButton); this.Controls.Add(GlobalCheck); this.Controls.Add(GlobalTb); this.Controls.Add(GlobalCombo); Ops.SetUpSeachSection(GlobalButton, GlobalTb, GlobalCombo, GlobalCheck, Labs, 150); GlobalButton.Click += new EventHandler(SearchThroughCompany); GlobalCombo.Size = new Size(GlobalCombo.Width + 50, GlobalCombo.Height); } void SearchThroughCompany(object sender, EventArgs e) { string SearchString = GlobalTb.Text; int Si = GlobalCombo.SelectedIndex; if(GlobalTb.Text == null) { MessageBox.Show("Can't search for a null value"); return; } if(GlobalCombo.Text == null) { MessageBox.Show("Must search through a given field"); return; } DataNow = Ops.To2DArray(CompanyTbl, '#'); DataMore = Ops.To2DArray(SitesTbl, '#'); DataMany = Ops.To2DArray(CustomersTbl, '#'); bool[] LL = new bool[DataNow.GetUpperBound(0) + 1]; if(GlobalCheck.Checked == true) { for(int i = 0; i < LL.Length; i++)

{ if(SearchString == DataNow[i, Si]) { LL[i] = true; } } } else { for(int i = 0; i < LL.Length; i++) { if(DataNow[i,Si].Contains(SearchString) == true) { LL[i] = true; } } } int cc = 0; foreach(bool b in LL) { if(b == true) { cc++; } } LL2 = new int[cc]; cc = 0; for(int i = 0; i < LL.Length; i++) { if(LL[i] == true) { LL2[cc] = i; cc++; } } DisposeControls(); GlobalCombo = new ComboBox(); this.Controls.Add(GlobalCombo); GlobalCombo.Size = new Size(280, GlobalCombo.Height); GlobalCombo.Location = new Point(10, 150); foreach(int i in LL2) { GlobalCombo.Items.Add(DataNow[i, Si]); } GlobalListBoxes = new ListBox[2]; for(int i = 0; i < 2; i++) { GlobalListBoxes[i] = new ListBox(); this.Controls.Add(GlobalListBoxes[i]); GlobalListBoxes[i].Size = new Size(135, 100); } this.Size = new Size(305,700); GlobalListBoxes[0].Location = new Point(10, GlobalCombo.Bottom + 25); GlobalListBoxes[1].Location = new Point(GlobalListBoxes[0].Right + 10, GlobalCombo.Bottom + 25); GlobalCombo.SelectedIndexChanged += new EventHandler(UpdateCompanyView); GlobalTbs = new TextBox[6]; string[] LabBuf = new string[6]; DeployTbs(GlobalTbs, GlobalListBoxes[0].Bottom+25, LabBuf); foreach(TextBox t in GlobalTbs) {

t.Enabled = false; } GlobalListBoxes[0].SelectedIndexChanged += new EventHandler(CompanyTbsToSite); GlobalListBoxes[1].SelectedIndexChanged += new EventHandler(CompanyTbsToCustomer); } void UpdateCompanyView(object sender, EventArgs e) { int Si = GlobalCombo.SelectedIndex; int cc = 0; int c = 0; for(int i = 0; i < DataMore.GetUpperBound(0)+1;i++) { if(DataMore[i,6] == Si.ToString()) { c++; } } LL3 = new int[c]; c = 0; for(int i = 0; i < DataMany.GetUpperBound(0)+1;i++) { if(DataMany[i,5] == Si.ToString()) { c++; } } LL4 = new int[c]; foreach(ListBox l in GlobalListBoxes) { l.Items.Clear(); } for(int i = 0; i < DataMore.GetUpperBound(0)+1; i++) { if(DataMore[i,6] == Si.ToString()) { GlobalListBoxes[0].Items.Add(DataMore[i,2]); LL3[cc] = i; cc++; } } //Customers cc=0; for(int i = 0; i < DataMany.GetUpperBound(0)+1; i++) { if(DataMany[i,5] == Si.ToString()) { GlobalListBoxes[1].Items.Add(string.Concat(DataMany[i,1], " ", DataMany[i,2])); LL4[cc] = i; cc++; } } GlobalTbs[0].Enabled = false; } void CompanyTbsToSite(object sender, EventArgs e) { GlobalTbs[5].Visible = true; for(int i = 0; i < Lab2.Length; i++) { Labs[i].Text = Lab2[i];

} int Si = GlobalListBoxes[0].SelectedIndex; for(int i = 0; i < GlobalTbs.Length;i++) { GlobalTbs[i].Text = DataMore[LL3[Si], i]; } } void CompanyTbsToCustomer(object sender, EventArgs e) { GlobalTbs[5].Visible = false; for(int i = 0; i < Lab1.Length; i++) { Labs[i].Text = Lab1[i]; } int Si = GlobalListBoxes[0].SelectedIndex*-1; for(int i = 0; i < GlobalTbs.Length; i++) { GlobalTbs[i].Text = DataMany[LL4[Si], i]; } } void MoveToSiteMode(object sender, EventArgs e) { MoveToSiteModeActual(); } void MoveToSiteModeActual() { Mode = 4; DisposeControls(); GlobalButtons = new Button[4]; this.Size = new Size(300, 400); string[] Labels = {"Add A New Site", "View Existing Sites", "Edit Existing Sites", "Delete Existing Sites"}; DeployButtons(GlobalButtons, 150, Labels); GlobalButtons[0].Click += new EventHandler(AddNewSite); GlobalButtons[1].Click += new EventHandler(ViewExistingSites); GlobalButtons[2].Click += new EventHandler(EditExistingSites); GlobalButtons[3].Click += new EventHandler(DeleteExistingSites); } void AddNewSite(object sender, EventArgs e) { Mode = 8; DisposeControls(); Button Submit = new Button(); Submit.Size = new Size(280, Submit.Height); this.Controls.Add(Submit); GlobalTbs = new TextBox[6]; GlobalCombo = new ComboBox(); string[] Labels = {"Id Number", "Site Name", "Address Line 1", "Address Line 2", "Address Line 3", "PostCode"}; DeployTbs(GlobalTbs, 150, Labels); GlobalTbs[5].KeyPress += new KeyPressEventHandler(SitePostCodeValidate); GlobalCombo.Size = new Size(280, GlobalCombo.Height); GlobalCombo.Location = new Point(10, GlobalTbs[5].Bottom + 25); this.Controls.Add(GlobalCombo); Submit.Location = new Point(10, GlobalCombo.Bottom + 25); DataNow = Ops.To2DArray(CompanyTbl,'#'); Submit.Click += new EventHandler(SubmitSiteRecord); Submit.Text = "Submit Record"; GlobalTbs[0].Enabled = false; this.Size = new Size(305, 600);

GlobalTbs[0].Text = Ops.GenerateId(SitesTbl, '#'); for(int i = 0; i < DataNow.GetUpperBound(0)+1; i++) { GlobalCombo.Items.Add(DataNow[i,1]); } } void SubmitSiteRecord(object sender, EventArgs e) { string record = null; foreach(TextBox t in GlobalTbs) { record = string.Concat(record, t.Text, '#'); } record = string.Concat(record, DataNow[GlobalCombo.SelectedIndex, 0]); Ops.InsertRecord(SitesTbl, record, '#'); GlobalTbs[0].Text = (int.Parse(GlobalTbs[0].Text)+1).ToString(); for(int i = 1; i < GlobalTbs.Length; i++) { GlobalTbs[i].Text = null; } } void ViewExistingSites(object sender, EventArgs e) { SiteSelection = 1; SetUpSites(); } void EditExistingSites(object sender, EventArgs e) { SiteSelection = 2; SetUpSites(); } void DeleteExistingSites(object sender, EventArgs e) { SiteSelection = 3; SetUpSites(); } void SetUpSites() { DisposeControls(); Mode = 8; GlobalButton = new Button(); GlobalCheck = new CheckBox(); GlobalCombo = new ComboBox(); GlobalTb = new TextBox(); this.Controls.Add(GlobalButton); this.Controls.Add(GlobalCheck); this.Controls.Add(GlobalCombo); this.Controls.Add(GlobalTb); string[] FieldNames = {"Id Number", "Site Name", "Address Line 1", "Address Line 2", "Address Line 3", "PostCode", "Company Afiliation"}; Ops.SetUpSeachSection(GlobalButton, GlobalTb, GlobalCombo, GlobalCheck, FieldNames, 150); GlobalButton.Click += new EventHandler(SearchThroughSites); } void SearchThroughSites(object sender, EventArgs e) { this.Size = new Size(325, 700); this.AutoScroll = true; Si = GlobalCombo.SelectedIndex; string SearchString = GlobalTb.Text;

bool Exact = GlobalCheck.Checked; DisposeControls(); DataNow = Ops.To2DArray(SitesTbl, '#'); LL = new bool[DataNow.GetUpperBound(0)+1]; if(Exact == true) { for(int i = 0; i < LL.Length; i++) { if(DataNow[i,Si] == SearchString) { LL[i] = true; } } } else { for(int i = 0; i < LL.Length; i++) { if(DataNow[i,Si].Contains(SearchString) == true) { LL[i] = true; } } } int cc = 0; foreach(bool b in LL) { if(b == true) { cc++; } } LL2 = new int[cc]; cc = 0; for(int i = 0; i < LL.Length; i++) { if(LL[i] == true) { LL2[cc] = i; cc++; } } SearchResults = new ListBox(); foreach(int i in LL2) { SearchResults.Items.Add(DataNow[i,Si]); } SearchResults.Size = new Size(280, 100); SearchResults.Location = new Point(10, 150); this.Controls.Add(SearchResults); GlobalTbs = new TextBox[6]; string[] FieldNames = {"Id Number", "Site Name", "Address Line 1", "Address Line 2", "Address Line 3", "PostCode", "Company Afiliation"}; DeployTbs(GlobalTbs, SearchResults.Bottom+25, FieldNames); GlobalTbs[0].Enabled = false; GlobalTbs[5].KeyPress += new KeyPressEventHandler(SitePostCodeValidate); SearchResults.SelectedIndexChanged += new EventHandler(UpdateSiteSearch); GlobalButtons = new Button[2]; GlobalCombo = new ComboBox(); this.Controls.Add(GlobalCombo); GlobalCombo.Size = new Size(280, GlobalCombo.Height);

GlobalCombo.Location = new Point(10, GlobalTbs[5].Bottom+25); string[] CompanyNames = Ops.ReadInField(CompanyTbl, 1, '#'); foreach(string s in CompanyNames) { GlobalCombo.Items.Add(s); } string[] Labbs = {"Save Changes", "Delete Record"}; DeployButtons(GlobalButtons, GlobalCombo.Bottom + 25, Labbs); GlobalButtons[0].Click += new EventHandler(SaveSiteRecord); GlobalButtons[1].Click += new EventHandler(DeleteSiteRecord); switch(SiteSelection) { case 1: GlobalButtons[0].Enabled = false; GlobalButtons[1].Enabled = false; break; case 2: GlobalButtons[0].Enabled = true; GlobalButtons[1].Enabled = false; break; case 3: GlobalButtons[0].Enabled = true; GlobalButtons[1].Enabled = true; break; } } void SitePostCodeValidate(object sender, KeyPressEventArgs e) { e.Handled = Ops.Validate(e.KeyChar, 1, GlobalTbs[5].Text.Length); } void UpdateSiteSearch(object sender, EventArgs e) { string[] CompanyNames = Ops.ReadInField(CompanyTbl, 1, '#'); Si = SearchResults.SelectedIndex; for(int i = 0; i < GlobalTbs.Length; i++) { GlobalTbs[i].Text = DataNow[LL2[Si], i]; } string[] CompanyIds = Ops.ReadInField(CompanyTbl, 0, '#'); for(int i = 0; i < CompanyIds.Length; i++) { if(CompanyIds[i] == DataNow[LL2[Si], 6]) { GlobalCombo.Text = CompanyNames[i]; } } } void SaveSiteRecord(object sender, EventArgs e) { string Record = null; foreach(TextBox t in GlobalTbs) { Record = string.Concat(Record, t.Text, '#'); } Record = string.Concat(Record, GlobalCombo.Text); Ops.UpdateRecords(SitesTbl, Record, GlobalTbs[0].Text, '#'); DisposeControls(); MoveToSiteModeActual(); } void DeleteSiteRecord(object sender, EventArgs e) { Ops.RemoveRecord(SitesTbl, GlobalTbs[0].Text, '#');

for(int i = 0; i < GlobalTbs.Length; i++) { GlobalTbs[i].Text = null; } DisposeControls(); MoveToSiteModeActual(); } void MoveToForecastMode(object sender, EventArgs e) { MoveToForecastModeActual(); } void MoveToForecastModeActual() { Mode = 4; DisposeControls(); GlobalButtons = new Button[5]; string[] BuLabs = {"Add a New Forecast", "View Statistics", "View Forecasts", "Edit Forecasts", "Delete Forecasts"}; DeployButtons(GlobalButtons, 150, BuLabs); GlobalButtons[0].Click += new EventHandler(AddNewForecast); GlobalButtons[1].Click += new EventHandler(ViewStatistics); GlobalButtons[2].Click += new EventHandler(ViewForecasts); GlobalButtons[3].Click += new EventHandler(EditForecasts); GlobalButtons[4].Click += new EventHandler(DeleteForecasts); } void AddNewForecast(object sender, EventArgs e) { Mode = 9; DisposeControls(); this.AutoScroll = true; GlobalComboBox = new ComboBox[3]; GlobalTbs = new TextBox[4]; GlobalTb = new TextBox(); GlobalTb.Text = Ops.GenerateId(ForecastTbl, '#'); GlobalTb.Size = new Size(280,GlobalTb.Height); GlobalTb.Location = new Point(10, 150); GlobalTb2 = new TextBox(); GlobalTb2.Size = GlobalTb.Size; GlobalTb2.Location = new Point(10, GlobalTb.Bottom+25); GlobalTb2.Text = "Project Name"; GlobalTb.Enabled = false; this.Controls.Add(GlobalTb); this.Controls.Add(GlobalTb2); GlobalTb.Text = Ops.GenerateId(ForecastTbl, '#'); DataNow = Ops.To2DArray(SalesTbl, '#'); DataMore = Ops.To2DArray(CustomersTbl, '#'); int c = 0; if(DataNow.GetUpperBound(0) > DataMore.GetUpperBound(0)) { c = DataNow.GetUpperBound(0) + 1; } else { c = DataMore.GetUpperBound(0)+1; } DataMany = new string[3, c]; for(int i = 0; i < 4; i++) { DataMany[0,i] = (i+ 1).ToString(); } for(int i = 0; i < DataNow.GetUpperBound(0)+1; i++) { DataMany[1,i] = string.Concat(DataNow[i,1], " ",

DataNow[i,2]); } for(int i = 0; i < DataMore.GetUpperBound(0)+1; i++) { DataMany[2,i] = string.Concat(DataMore[i,1], " ", DataMore[i,2]); } DeployComboBoxes(GlobalComboBox, DataMany, GlobalTb2.Bottom+25); GlobalComboBox[0].Text = "Stage"; GlobalComboBox[1].Text = "SalesPerson"; GlobalComboBox[2].Text = "Customer"; GlobalTbs = new TextBox[4]; string[] TbLabs = {"Systems £", "Storage £", "Services £", "Delivery Date"}; DeployTbs(GlobalTbs, GlobalComboBox[2].Bottom+25, TbLabs); Button Submit = new Button(); Submit.Size = new Size(280, Submit.Height); Submit.Location = new Point(10, GlobalTbs[3].Bottom+25); Submit.Click += new EventHandler(SubmitNewForcast); this.Controls.Add(Submit); } void SubmitNewForcast(object sender, EventArgs e) { string Record = null; Record = string.Concat(GlobalTb.Text, '#', GlobalTb2, '#'); } void ViewStatistics(object sender, EventArgs e) { Mode = 9; } void ViewForecasts(object sender, EventArgs e) { } void EditForecasts(object sender, EventArgs e) { } void DeleteForecasts(object sender, EventArgs e) { } void DeployButtons(Button[] b, int LocToBe, string[] Labels) { for(int i =0; i
} void DeployTbs(TextBox[] SalesTbs, int LocToBe, string[] Labels) { Labs = new Label[Labels.Length]; for(int i =0; i <SalesTbs.Length;i++) { SalesTbs[i] = new TextBox(); Labs[i] = new Label(); Labs[i].TextAlign = ContentAlignment.MiddleCenter; Labs[i].Text = Labels[i]; Labs[i].Size = new Size(280, 25); Labs[i].ForeColor = Color.White; Labs[i].Location = new Point(0, LocToBe); SalesTbs[i].Size = new Size(280, 25); SalesTbs[i].Location = new Point(10, LocToBe); this.Controls.Add(SalesTbs[i]); this.Controls.Add(Labs[i]); while(Labs[i].Location.Y < LocToBe) { Labs[i].Location = new Point(0, Labs[i].Location.Y + (i+1)*2); this.Refresh(); } LocToBe += 25; while(SalesTbs[i].Location.Y < LocToBe) { SalesTbs[i].Location = new Point(SalesTbs[i].Location.X, SalesTbs[i].Location.Y + (i+1)*2); this.Refresh(); } LocToBe += 25; } } void DeployComboBoxes(ComboBox[] Boxes, string[,] Items, int LocToBe) { for(int i = 0; i < Boxes.Length; i++) { Boxes[i] = new ComboBox(); this.Controls.Add(Boxes[i]); Boxes[i].Size = new Size(280,Boxes[i].Height); Boxes[i].Location = new Point(10, LocToBe - 25); int c = Boxes[i].Location.Y; for(int j = 1; j < 25; j++) { Boxes[i].Location = new Point(10, c+j); } for(int j = 0; j < Items.GetUpperBound(1) + 1; j++) { if(Items[i,j] != null) { Boxes[i].Items.Add(Items[i,j]); } } LocToBe += 50; } } void OtherBacktracker(object sender, EventArgs e) { MessageBox.Show(this.Size.ToString());

switch(Mode) { case 1: this.Close(); break; case 2: DisposeControls(); SetUpOpening(); break; case 3: Login(); break; case 4: MoveToMenuMode(); break; case 5: MoveToSalesModeActual(); break; case 6: MoveToCustomerModeActual(); break; case 7: MoveToCompanyModeActual(); break; case 8: DisposeControls(); MoveToSiteModeActual(); this.AutoScroll = false; break; case 9: DisposeControls(); MoveToForecastModeActual(); break; } } } }

Related Documents

Course
August 2019 35
Course
June 2020 12
Course
June 2020 12
Course
October 2019 45
Course
November 2019 20