0% found this document useful (0 votes)
25 views6 pages

Shopazon Store Data Management Guide

Uploaded by

uofcstudent1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views6 pages

Shopazon Store Data Management Guide

Uploaded by

uofcstudent1
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

 Change the code in LoadSales in the Store Class: from Sale to ISale

 Copy the Data folder inside your Project folder (You can find the Data folder inside the folder
ICT711_Day8_UI, which is uploaded in D2L)
 After copying the Data folder, the code for the LoadStoreData() in the CustomerForm should be
like this.
CODES: Change the name of namespace depending on your project name.
using ICT711_Day5_classes;
using System;
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using [Link];
using static [Link];
/
namespace ICT7111_Day8_Try
{
public partial class CustomersForm : Form
{
private Store myStore;
private Customer? selectedCustomer = null; //JEN: Declare as nullable
public CustomersForm()
{
InitializeComponent();
}

/*public CustomersForm() => InitializeComponent();*/

private void CustomersForm_Load(object sender, EventArgs e)


{
myStore = [Link]();
LoadStoreData();
//[Link]();
[Link] = [Link](c => (Customer)c);
}

private void saveBtn_Click(object sender, EventArgs e)


{
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();

class SaleViewModel //JEN: To show only the needed purchase data


{
public int Id;
public DateTime Date { get; set; }
public decimal Total { get; set; }
}

private void customersGrid_SelectionChanged_1(object sender, EventArgs e)


{
selectedCustomer = (Customer)((DataGridView)sender).[Link];
if (selectedCustomer is null) return; //Make sure there is a current selection
[Link] = [Link]([Link]);

//JEN: OPTION 1
//Show all Sale Information in Sales
//[Link] = [Link]([Link])
//.ConvertAll(s => (Sale)s);

//JEN: OPTION 2
//Show all Sale information in a SaleViewModel form to calculate the Total
//JEN: since a new class is created to show only the columns that we want in the SaleView
[Link] = [Link]([Link])
.ConvertAll(s => new SaleViewModel { Id = [Link], Date = [Link], Total = [Link]() });
}

private void LoadStoreData()


{
[Link] = "../../../Data/associates_data.json";
[Link] = "../../../Data/customers_data.json";
[Link] = "../../../Data/inventory_data.json";
[Link] = "../../../Data/sales_data.json";
[Link] = "../../../Data/store_data.json";
[Link]();
[Link]();
[Link]();
[Link]();
}

private void mainAssociateLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)


{
if (selectedCustomer is null) return;
//Get the associate ID for the current customer
int associateID = [Link];
//Get the associate information
Associate associate = (Associate)[Link](a => [Link] == associateID);
//Show the associate data
[Link]($"{[Link]}: {[Link]()}\n" +
$"{[Link]}\n{[Link]}\n{[Link]}", "Customer Associate");
}

private void purchaseGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)


{
var grid = (DataGridView)sender;
if ([Link] < 0)
{
//They clicked the header column, do nothing
return;
}

if (grid[[Link], [Link]] is DataGridViewButtonCell)


{
var salev = (SaleViewModel)[Link][[Link]].DataBoundItem;
Sale sale = (Sale)[Link](s => [Link] == [Link]);
SaleForm sf = new SaleForm();
[Link] = sale;
[Link] = myStore;
[Link]();
//[Link]($"ID-{[Link]}: {[Link]}, {[Link]}", "Sale");
}
}
}
}
 Copy the [Link] (provided by Mostafa) into your project.

 In the [Link] code, change the namespace based on your project name.

You might also like