private void Submit_Nodes(object sender, RoutedEventArgs e) { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); Hardware h = new Hardware(); try { nodes = AddNodes.Text; repeaters = AddRepeaters.Text; hubs = AddHubs.Text; h.Nodes = Convert.ToInt32(nodes); h.Repeaters = Convert.ToInt32(repeaters); h.Hubs = Convert.ToInt32(hubs); t.AddHardware(h); ShowHardware sh = new ShowHardware(); sh.Show(); this.Close(); } catch { MessageBox.Show("Add a numerical value"); } }
private void IDList() { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); List <Hardware> hardware = t.GetHardware(); IDlist.ItemsSource = hardware; }
static void Main(string[] args) { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); Hardware h6 = new Hardware(); h6.Nodes = 4000; h6.Repeaters = 2600; h6.Hubs = 1400; //t.AddHardware(h6); /* Hardware hardware = new Hardware(); * * hardware.Nodes = 55; * hardware.Repeaters = 46; * hardware.Hubs = 82;*/ //t.AddHardware(hardware); //This for the remove method //Reason is that you need to get the data and through it select the object to delete. // List<Hardware> RemoveList = t.GetHardware(); /*foreach(Hardware i in RemoveList) * { * if(i.ID == 2 ) * { * t.RemoveHardware(i); //i here is the item * } * }*/ //This is updated /*List<Hardware> UpdateList = t.GetHardware(); * * foreach(Hardware i in UpdateList) * { * if(i.ID == 3) * { * //subtitution taking place * i.Nodes = 1; * i.Repeaters = 1; * i.Hubs = 1; * * t.UpdateHardware(i); * * } * }*/ }
private void Update_Hardware(object sender, RoutedEventArgs e) { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); try { //Get data List <Hardware> hardware = t.GetHardware(); //Get user input string _IDItem = IDlist.Text; int IDItem = Convert.ToInt32(_IDItem); //Prepare node/repeater/hub parameters string _node = Node.Text; int node = Convert.ToInt32(_node); string _repeater = Repeater.Text; int repeater = Convert.ToInt32(_repeater); string _hub = Hub.Text; int hub = Convert.ToInt32(_hub); //looping in list foreach (Hardware i in hardware) { if (i.ID == IDItem) { i.Nodes = node; i.Repeaters = repeater; i.Hubs = hub; t.UpdateHardware(i); } } ShowHardware sh = new ShowHardware(); sh.Show(); this.Close(); } catch { //Try or catch in care user enter invalid id number or string MessageBox.Show("Your update has failed. Please check for:" + "\n" + "- Character" + "\n" + "- String" + "\n" + "- Empty box"); } }
//method that fetches data and filters hubs based on month december private int DecemberHubs() { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); List <Hardware> decemberhubs = t.GetHardware().FindAll(x => x.Date.Month == 12); int DecemberSumOfHubs = 0; foreach (Hardware i in decemberhubs) { DecemberSumOfHubs += i.Hubs; } return(DecemberSumOfHubs); }
//Method that fetches data and filters hubs based on month March private int MarchHubs() { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); List <Hardware> marchhubs = t.GetHardware().FindAll(x => x.Date.Month == 03); int MarchSumOfHubs = 0; foreach (Hardware i in marchhubs) { MarchSumOfHubs += i.Hubs; } return(MarchSumOfHubs); }
//Method that fetches data and filters nodes based on month february private int FebruaryHubs() { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); List <Hardware> februaryhubs = t.GetHardware().FindAll(x => x.Date.Month == 02); int FebruarySumOfHubs = 0; foreach (Hardware i in februaryhubs) { FebruarySumOfHubs += i.Hubs; } return(FebruarySumOfHubs); }
//Method that fetches data and filters repeaters based on month January private int JanuaryRepeaters() { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); List <Hardware> januaryrepeaters = t.GetHardware().FindAll(x => x.Date.Month == 01); int JanuarySumOfRepeaters = 0; foreach (Hardware i in januaryrepeaters) { JanuarySumOfRepeaters += i.Repeaters; } return(JanuarySumOfRepeaters); }
//in order to reset the auto_increase of sql ID you need to truncate the table private void Remove_Hardware(object sender, RoutedEventArgs e) { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); try { //Get data List <Hardware> hardware = t.GetHardware(); //Get user input string _RemoveItem = Remove.Text; int RemoveItem = Convert.ToInt32(_RemoveItem); //loop into data to find hardware of interest foreach (Hardware i in hardware) { if (i.ID == RemoveItem) { t.RemoveHardware(i); MessageBox.Show("Hardware succesfully removed"); break; } } ShowHardware sh = new ShowHardware(); sh.Show(); this.Close(); } catch { //Try or catch in care user enter invalid id number or string MessageBox.Show("Your update has failed. Please check for:" + "\n" + "- Character" + "\n" + "- String" + "\n" + "- Empty box"); } }
public void DisplayData() { try { ManufacturingDataModel MDM = new ManufacturingDataModel(); Test t = new Test(MDM); //Retrieves the data from db List <Hardware> x = t.GetHardware(); /*HArdwareList is the x:Name in ListView * HardwareList.ItemSource = x is basically directing towards the data in list.*/ HardwareList.ItemsSource = x; /*foreach(Hardware i in x ) * { * //HardwareList.Items.Add(i); * }*/ } catch { MessageBox.Show("Check Database Connection"); } }
public Repositories(ManufacturingDataModel mdm) { MDM = mdm; }
public Test(ManufacturingDataModel mdm) : base(mdm) { }