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;
using System.Data.SqlServerCe;
using System.IO;
using System.Threading;
namespace Front_Office_Helper
{
public partial class Form1 : Form
{
string[] quantum = new string[50];
string[] quantum2 = new string[50];
delegate void SetTextCallback(string text);
static volatile bool StartStop;
static volatile bool StartStop2;
int i = 0;
public Form1()
{
InitializeComponent();
TextReader strField1 = new StreamReader("txtField1.txt");
txtField1.Text = strField1.ReadToEnd();
strField1.Close();
TextReader strField2= new StreamReader("txtField2.txt");
txtField2.Text = strField2.ReadToEnd();
strField2.Close();
TextReader strField3= new StreamReader("txtField3.txt");
txtField3.Text = strField3.ReadToEnd();
strField3.Close();
TextReader strField4= new StreamReader("txtField4.txt");
txtField4.Text = strField4.ReadToEnd();
strField4.Close();
TextReader strField5 = new StreamReader("txtField5.txt");
txtField5.Text = strField5.ReadToEnd();
strField5.Close();
TextReader strField6= new StreamReader("txtField6.txt");
txtField6.Text = strField6.ReadToEnd();
strField6.Close();
TextReader strField7= new StreamReader("txtField7.txt");
txtField7.Text = strField7.ReadToEnd();
strField7.Close();
TextReader strField8= new StreamReader("txtField8.txt");
txtField8.Text = strField8.ReadToEnd();
strField8.Close();
}
private void reviewToolStripMenuItem_Click(object sender, EventArgs e)
{
Review checkIt = new Review();
checkIt.Show();
}
private void button1_Click(object sender, EventArgs e)
{
{
try
{
string conString = Properties.Settings.Default.office_helperConnectionString;
using (SqlCeConnection conn = new SqlCeConnection(conString))
{
conn.Open();
using (SqlCeCommand cox = new SqlCeCommand("Insert into Notes (Date,Field1,Field2,Field3,Field4,Field5,Field6,Field7,Field8,Note) VALUES (@date,@Col1,@Col2,@Col3,@col4,@Col5,@Col6,@Col7,@Col8,@Note)", conn))
{
MessageBox.Show(Convert.ToString(DateTime.Now));
cox.Parameters.AddWithValue("@date", Convert.ToString(DateTime.Now));
cox.Parameters.AddWithValue("@Col1", txtFieldOne.Text);
cox.Parameters.AddWithValue("@Col2", txtFieldTwo.Text);
cox.Parameters.AddWithValue("@Col3", txtFieldThree.Text);
cox.Parameters.AddWithValue("@Col4", txtFieldFour.Text);
cox.Parameters.AddWithValue("@Col5", txtFieldFive.Text);
cox.Parameters.AddWithValue("@Col6", txtFieldSix.Text);
cox.Parameters.AddWithValue("@Col7", txtFieldSeven.Text);
cox.Parameters.AddWithValue("@Col8", txtFieldEight.Text);
cox.Parameters.AddWithValue("@Note", txtNote.Text);
cox.ExecuteNonQuery();
conn.Close();
}
}
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
dateDate.Text = "";
txtFieldOne.Text = "";
txtFieldTwo.Text = "";
txtFieldThree.Text = "";
txtFieldFour.Text = "";
txtFieldFive.Text = "";
txtFieldSix.Text = "";
txtFieldSeven.Text = "";
txtFieldEight.Text = "";
txtNote.Text = "";
}
}
private void quitToolStripMenuItem_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}
private void dateDate_ValueChanged(object sender, EventArgs e)
{
}
private void saveFieldTitlesToolStripMenuItem_Click(object sender, EventArgs e)
{
TextWriter stream1 = new StreamWriter("txtField1.txt");
string strField1 = txtField1.Text;
stream1.WriteLine(strField1);
stream1.Close();
TextWriter stream2 = new StreamWriter("txtField2.txt");
string strField2 = txtField2.Text;
stream2.WriteLine(strField2);
stream2.Close();
TextWriter stream3 = new StreamWriter("txtField3.txt");
string strField3 = txtField3.Text;
stream3.WriteLine(strField3);
stream3.Close();
TextWriter stream4= new StreamWriter("txtField4.txt");
string strField4= txtField4.Text;
stream4.WriteLine(strField4);
stream4.Close();
TextWriter stream5= new StreamWriter("txtField5.txt");
string strField5 = txtField5.Text;
stream5.WriteLine(strField5);
stream5.Close();
TextWriter stream6 = new StreamWriter("txtField6.txt");
string strField6 = txtField6.Text;
stream6.WriteLine(strField6);
stream6.Close();
TextWriter stream7 = new StreamWriter("txtField7.txt");
string strField7= txtField7.Text;
stream7.WriteLine(strField7);
stream7.Close();
TextWriter stream8 = new StreamWriter("txtField8.txt");
string strField8 = txtField8.Text;
stream8.WriteLine(strField8);
stream8.Close();
}
private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
{
About about = new About();
about.Show();
}
private void helpToolStripMenuItem_Click(object sender, EventArgs e)
{
Help help = new Help();
help.Show();
}
private void button1_Click_1(object sender, EventArgs e)
{
quantum[i] = txtFieldOne.Text;
quantum[i + 1] = txtFieldTwo.Text;
quantum[i + 2] = txtFieldThree.Text;
quantum[i + 3] = txtFieldFour.Text;
quantum[i + 4] = txtFieldFive.Text;
quantum[i + 5] = txtFieldSix.Text;
quantum[i + 6] = txtFieldSeven.Text;
quantum[i + 7] = txtFieldEight.Text;
//MessageBox.Show(quantum[i]);
txtFieldEight.Text = quantum[i];
//MessageBox.Show(txtNote.Text);
//MessageBox.Show(quantum[i]);
//MessageBox.Show(quantum[1] + quantum[2]);
txtNote.Text = quantum[i] + "\r\n" + quantum[i + 1] + "\r\n"+quantum[i + 2] + "\r\n" + quantum[i + 3] +"\r\n"+quantum[i+4] + "\r\n" + quantum[i + 5] +"\r\n"+ quantum[i + 6] + "\r\n" + quantum[i + 7];
i = i + 1;
StartStop = false;
Thread myThread=new Thread(myThreadedMethod);
myThread.Start();
}
public void myThreadedMethod()
{
//MultiThreadForm testing = new MultiThreadForm();
//testing.Show();
while(!StartStop)
{
Random firstRandomNumber = new Random();
Int32 x = firstRandomNumber.Next() %7;
//MessageBox.Show("boner");
string strRandom = Convert.ToString(quantum[x]);
string what = Convert.ToString(strRandom);
SetText(what);
Thread.Sleep(500);
}
}
private void SetText(string text)
{
if (this.txtwhich.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText);
this.Invoke(d, new object[] { text });
}
else
{
this.txtwhich.Text = text;
}
}
private void button2_Click(object sender, EventArgs e)
{
StartStop = true;
}
private void btnStart2_Click(object sender, EventArgs e)
{
quantum2[i] = txtFieldOne.Text;
quantum2[i + 1] = txtFieldTwo.Text;
quantum2[i + 2] = txtFieldThree.Text;
quantum2[i + 3] = txtFieldFour.Text;
quantum2[i + 4] = txtFieldFive.Text;
quantum2[i + 5] = txtFieldSix.Text;
quantum2[i + 6] = txtFieldSeven.Text;
quantum2[i + 7] = txtFieldEight.Text;
//MessageBox.Show(quantum[i]);
txtFieldEight2.Text = quantum2[i];
//MessageBox.Show(txtNote.Text);
//MessageBox.Show(quantum[i]);
//MessageBox.Show(quantum[1] + quantum[2]);
txtNote.Text = quantum2[i] + "\r\n" + quantum2[i + 1] + "\r\n" + quantum2[i + 2] + "\r\n" + quantum2[i + 3] + "\r\n" + quantum2[i + 4] + "\r\n" + quantum2[i + 5] + "\r\n" + quantum2[i + 6] + "\r\n" + quantum2[i + 7];
i = i + 1;
StartStop2 = false;
Thread myThread2 = new Thread(myThreadedMethod2);
myThread2.Start();
}
public void myThreadedMethod2()
{
//MultiThreadForm testing = new MultiThreadForm();
//testing.Show();
while (!StartStop2)
{
Random firstRandomNumber = new Random();
Int32 x = firstRandomNumber.Next() % 7;
//MessageBox.Show("boner");
string strRandom = Convert.ToString(quantum2[x]);
string what = Convert.ToString(strRandom);
SetText2(what);
Thread.Sleep(500);
}
}
private void SetText2(string text)
{
if (this.txtwhich2.InvokeRequired)
{
SetTextCallback d = new SetTextCallback(SetText2);
this.Invoke(d, new object[] { text });
}
else
{
this.txtwhich2.Text = text;
}
}
private void button3_Click(object sender, EventArgs e)
{
StartStop2 = true;
}
}
}