private void button_ChangeInfo_Click(object sender, EventArgs e) { if (dataGridView_List.SelectedRows.Count > 0) { var selected = dataGridView_List.SelectedCells; string id = Convert.ToString(selected[1].Value); string type = Convert.ToString(selected[3].Value); if (BufferContainer == null) { BufferContainer = new InventorySystemContainer(ChosenDate); BufferContainer = (InventorySystemContainer)Get_MainInvSysContainer(ChosenDate).Clone(); } if (MainInvSysController.Edit_Device(ref BufferContainer, id, type)) { if (BufferDate == DateTime.MinValue) { BufferDate = DateTime.Now; BufferContainer.CreationDate = BufferDate; } Saved = false; //Set_MainInvSysContainer(ISC, ChosenDate); Set_dataGridView_List(BufferContainer); } } }
private void button_Load_Click(object sender, EventArgs e) { DateTime bufferTime = Convert.ToDateTime(comboBox_Dates.SelectedItem); if (!Saved) { Form_Save_Attention FSA = new Form_Save_Attention(); FSA.StartPosition = FormStartPosition.CenterParent; FSA.ShowDialog(); if (FSA.DialogResult == DialogResult.Yes) { button_Save_Click(null, null); } else { Saved = true; BufferContainer = new InventorySystemContainer(); BufferContainer = null; BufferDate = DateTime.MinValue; } } else if (Saved && BufferContainer != null) { BufferContainer = new InventorySystemContainer(); BufferContainer = null; BufferDate = DateTime.MinValue; } ChosenDate = bufferTime; comboBox_Dates.SelectedItem = bufferTime; Set_dataGridView_List(); }
private void button_Add_Section_Click(object sender, EventArgs e) { Form_Add_Device FAD = new Form_Add_Device(); if (BufferContainer == null) { BufferContainer = new InventorySystemContainer(ChosenDate); BufferContainer = (InventorySystemContainer)Get_MainInvSysContainer(ChosenDate).Clone(); } if (MainInvSysController.Add_Device(FAD, ref BufferContainer)) { if (BufferDate == DateTime.MinValue) { BufferDate = DateTime.Now; BufferContainer.CreationDate = BufferDate; } Saved = false; //Set_MainInvSysContainer(ISC, ChosenDate); Set_dataGridView_List(BufferContainer); } }
public void Set_dataGridView_List(InventorySystemContainer ISC) { dataGridView_List.Rows.Clear(); if (Loaded) { List <DevicePC> list_pc = ISC.Get_Main_Device_List().Get_PCList(); int list_size_pc = list_pc.Count; int i; for (i = 0; i < list_size_pc; i++) { dataGridView_List.Rows.Add(); dataGridView_List.Rows[i].Cells[0].Value = i + 1; dataGridView_List.Rows[i].Cells[1].Value = list_pc[i].ID; dataGridView_List.Rows[i].Cells[2].Value = list_pc[i].Name; dataGridView_List.Rows[i].Cells[3].Value = list_pc[i].Type; dataGridView_List.Rows[i].Cells[4].Value = list_pc[i].RegistrationDate; } List <DeviceMonitor> list_mon = ISC.Get_Main_Device_List().Get_MonList(); int list_size_mon = list_mon.Count; int j = 0; for (i = list_size_pc; i < list_size_pc + list_size_mon; i++) { dataGridView_List.Rows.Add(); dataGridView_List.Rows[i].Cells[0].Value = i + 1; dataGridView_List.Rows[i].Cells[1].Value = list_mon[j].ID; dataGridView_List.Rows[i].Cells[2].Value = list_mon[j].Name; dataGridView_List.Rows[i].Cells[3].Value = list_mon[j].Type; dataGridView_List.Rows[i].Cells[4].Value = list_mon[j].RegistrationDate; j++; } List <DevicePrinter> list_pr = ISC.Get_Main_Device_List().Get_PrList(); int list_size_pr = list_pr.Count; j = 0; for (i = list_size_pc + list_size_mon; i < list_size_pc + list_size_mon + list_size_pr; i++) { dataGridView_List.Rows.Add(); dataGridView_List.Rows[i].Cells[0].Value = i + 1; dataGridView_List.Rows[i].Cells[1].Value = list_pr[j].ID; dataGridView_List.Rows[i].Cells[2].Value = list_pr[j].Name; dataGridView_List.Rows[i].Cells[3].Value = list_pr[j].Type; dataGridView_List.Rows[i].Cells[4].Value = list_pr[j].RegistrationDate; j++; } } }
private void button_Save_Click(object sender, EventArgs e) { if (!Saved) { if (BufferContainer.Get_Main_Device_List().Get_MonList().Count != 0 || BufferContainer.Get_Main_Device_List().Get_PCList().Count != 0 || BufferContainer.Get_Main_Device_List().Get_PrList().Count != 0) { MainInvSysContainers.Add(BufferContainer); Saved = true; BufferContainer = new InventorySystemContainer(); BufferContainer = null; BufferDate = DateTime.MinValue; FileSystem.Save_Container_List(MainInvSysContainers); Create_Dates_List(); Set_dataGridView_List(); } } else if (Saved) { BufferContainer = new InventorySystemContainer(ChosenDate); BufferContainer = (InventorySystemContainer)Get_MainInvSysContainer(ChosenDate).Clone(); BufferDate = DateTime.Now; BufferContainer.CreationDate = BufferDate; MainInvSysContainers.Add(BufferContainer); Saved = true; BufferContainer = new InventorySystemContainer(); BufferContainer = null; BufferDate = DateTime.MinValue; FileSystem.Save_Container_List(MainInvSysContainers); Create_Dates_List(); Set_dataGridView_List(); } }
private void InventorySystemGUI_FormClosing(Object sender, FormClosingEventArgs e) { if (!Saved) { Form_Save_Attention FSA = new Form_Save_Attention(); FSA.StartPosition = FormStartPosition.CenterParent; FSA.ShowDialog(); if (FSA.DialogResult == DialogResult.Yes) { button_Save_Click(null, null); } else { Saved = true; BufferContainer = new InventorySystemContainer(); BufferContainer = null; BufferDate = DateTime.MinValue; } } }
public void Load_Data() { Loaded = FileSystem.Load_Container_List(ref MainInvSysContainers); if (!Loaded) { BufferDate = DateTime.Now; BufferContainer = new InventorySystemContainer(BufferDate); Saved = false; } Loaded = true; Create_Dates_List(); if (Saved != false) { Set_dataGridView_List(); } }
public void Set_MainInvSysContainer(InventorySystemContainer ISC, DateTime date) { MainInvSysContainers[MainInvSysContainers.FindIndex(getInfo => getInfo.CreationDate.Date == date.Date && getInfo.CreationDate.Hour == date.Hour && getInfo.CreationDate.Minute == date.Minute && getInfo.CreationDate.Second == date.Second)] = ISC; }