What I believe is the olderest, marked as 'AdvertsingProfitControl Alpha' by the folder. Only had a simple 'Add Records' form, quite incomplete.
This commit is contained in:
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Data.OleDb;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AdvertsingProfitControl
|
||||
{
|
||||
public partial class frmMain : Form
|
||||
{
|
||||
private AutoCompleteStringCollection dateSuggestions = new AutoCompleteStringCollection();
|
||||
//private string connString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=apcDatabase.accdb;Persist Security Info=False";
|
||||
|
||||
public frmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
}
|
||||
|
||||
private void frmMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
//connect to the database on form load | eh?
|
||||
BuildUITables();
|
||||
addRecordToolStripMenuItem.PerformClick();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function re-orders the DataGridView to fit the
|
||||
/// column scheme of the Advertising Profit Control sheet,
|
||||
/// because SQL doesn't appear to return the columns in
|
||||
/// the desired order.
|
||||
/// </summary>
|
||||
/// <param name="dataGrid"></param>
|
||||
private void ReorderDataGridView(DataGridView dataGrid)
|
||||
{
|
||||
foreach (DataGridViewColumn column in dataGrid.Columns)
|
||||
{
|
||||
if (!column.Name.Contains("ID"))
|
||||
{
|
||||
switch (column.Name.ToLower())
|
||||
{
|
||||
//---Begin AdItem Table check-------------------
|
||||
case "aditem":
|
||||
column.DisplayIndex = 0;
|
||||
column.HeaderText = "Ad Item";
|
||||
break;
|
||||
//---End AdItem Table check---------------------
|
||||
//---Begin Projected Sales Table check----------
|
||||
case "prsold":
|
||||
column.DisplayIndex = 1;
|
||||
column.HeaderText = "Sold";
|
||||
break;
|
||||
case "prsaleprice":
|
||||
column.DisplayIndex = 2;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Sale Price";
|
||||
break;
|
||||
case "prtotalsales":
|
||||
column.DisplayIndex = 3;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Total Sales";
|
||||
break;
|
||||
case "prcost":
|
||||
column.DisplayIndex = 4;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Cost";
|
||||
break;
|
||||
case "prprofitreturn":
|
||||
column.DisplayIndex = 5;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Profit Return";
|
||||
break;
|
||||
case "prtotalprofitreturn":
|
||||
column.DisplayIndex = 6;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Total Profit Return";
|
||||
break;
|
||||
//---End Projected Sales Table check------------
|
||||
//---Begin Inventory Table check----------------
|
||||
case "invbegininginventory":
|
||||
column.DisplayIndex = 1;
|
||||
column.HeaderText = "Beginning inventory";
|
||||
break;
|
||||
case "invrecieved":
|
||||
column.DisplayIndex = 2;
|
||||
column.HeaderText = "Received";
|
||||
break;
|
||||
case "invtotal":
|
||||
column.DisplayIndex = 3;
|
||||
column.HeaderText = "Total";
|
||||
break;
|
||||
case "invending":
|
||||
column.DisplayIndex = 4;
|
||||
column.HeaderText = "Ending Inventory";
|
||||
break;
|
||||
//---End Inventory Table check------------------
|
||||
//---Begin Actual Sales Table check-------------
|
||||
case "acsold":
|
||||
column.DisplayIndex = 8;
|
||||
column.HeaderText = "Sold";
|
||||
break;
|
||||
case "acsaleprice":
|
||||
column.DisplayIndex = 9;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Sale Price";
|
||||
break;
|
||||
case "actotalsales":
|
||||
column.DisplayIndex = 10;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Total Sales";
|
||||
break;
|
||||
case "accost":
|
||||
column.DisplayIndex = 11;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Cost";
|
||||
break;
|
||||
case "acprofitreturn":
|
||||
column.DisplayIndex = 12;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Profit Return";
|
||||
break;
|
||||
case "actotalprofitreturn":
|
||||
column.DisplayIndex = 13;
|
||||
column.DefaultCellStyle.Format = "c";
|
||||
column.HeaderText = "Total Profit Return";
|
||||
break;
|
||||
//---End Actual Table check---------------------
|
||||
default:
|
||||
MessageBox.Show("This message box should never appear but if it does record this information:\n" + "Column Name: " + column.Name + "\nColumn Type: " + column.ValueType, "Unknown Column Detected", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//The column was an ID field therefore we won't bother showing it to the user.
|
||||
column.Visible = false;
|
||||
}
|
||||
}
|
||||
}//End of ReorderDataGridView() function
|
||||
|
||||
private void BuildUITables()
|
||||
{
|
||||
RetrieveTables tableData = new RetrieveTables();
|
||||
DataGridView finalWICTable = new DataGridView();
|
||||
string[] comments;
|
||||
|
||||
projectedSalesMainDataGrid.DataSource = tableData.APCProjectionSaleTable();
|
||||
ReorderDataGridView(projectedSalesMainDataGrid);
|
||||
actualSalesInvMainDataGidView.DataSource = tableData.APCActualSalesTable();
|
||||
ReorderDataGridView(actualSalesInvMainDataGidView);
|
||||
finalWICTable.DataSource = tableData.WICTable();
|
||||
comments = tableData.Comment();
|
||||
foreach (string comment in comments)
|
||||
{
|
||||
commentsMainLabel.Text = comment + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
private void addRecordToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
frmAddRecord recordForm = new frmAddRecord();
|
||||
recordForm.ShowDialog();
|
||||
BuildUITables();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user