示例#1
0
        private void StorageItemAdd_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            NewItem item = new NewItem();

            item.ShowDialog();

            if (item.ItemName != null)//check
            {
                if (itemtype == "Food&Water")
                {
                    item.itemid = string.Format(string.Format("S{0:0000}", itemid));
                    if (item.type == 1) //check if User choose Food or Water from ComboBox
                    {
                        foodlist.Add(new Food(item.itemid, item.ItemName,
                                              Convert.ToInt32(item.ItemQuantity), item.ExpireDate, item.type));
                        item.ItemQuantity = item.ItemQuantity + item.unit;//Add Kg to the end of the quantity(e.g. 10 Kg)
                        string[]     column = new string[] { item.itemid, item.ItemName, item.ItemQuantity, item.ExpireDate };
                        ListViewItem row    = new ListViewItem(column);
                        StorageListView.Items.Add(row);
                    }
                    else
                    {
                        waterlist.Add(new Water(item.itemid, item.ItemName,
                                                Convert.ToInt32(item.ItemQuantity), item.ExpireDate, item.type));
                        item.ItemQuantity = item.ItemQuantity + item.unit; //Add Liter to the end of the quantity (e.g. 10 Liter)
                        string[]     column = new string[] { item.itemid, item.ItemName, item.ItemQuantity, item.ExpireDate };
                        ListViewItem row    = new ListViewItem(column);
                        StorageListView.Items.Add(row);
                    }
                }
                else if (itemtype == "Medicine")
                {
                    item.itemid = string.Format(string.Format("M{0:0000}", itemid));
                    medicinelist.Add(new Medicine(item.itemid, item.ItemName,
                                                  Convert.ToInt32(item.ItemQuantity), item.ExpireDate));
                    string[]     column = new string[] { item.itemid, item.ItemName, item.ItemQuantity, item.ExpireDate };
                    ListViewItem row    = new ListViewItem(column);
                    StorageListView.Items.Add(row);
                }
                else
                {
                    item.itemid = string.Format(string.Format("E{0:0000}", itemid));
                    equipmentlist.Add(new equipment(item.itemid, item.ItemName,
                                                    Convert.ToInt32(item.ItemQuantity), item.ExpireDate));
                    string[]     column = new string[] { item.itemid, item.ItemName, item.ItemQuantity, item.ExpireDate };
                    ListViewItem row    = new ListViewItem(column);
                    StorageListView.Items.Add(row);
                }

                itemid++;
            }
        }
示例#2
0
        private void ChangeButton_Click(object sender, EventArgs e)
        {
            NewItem item = new NewItem();

            if (itemtype == "Food&Water")
            {
                for (int index = 0; index < foodlist.Count; index++)
                {
                    if (foodlist[index].id == StorageListView.SelectedItems[0].SubItems[0].Text)
                    {
                        foodlist[index].quantity = Convert.ToInt32(EditQtyTextBox.Text);
                        StorageListView.SelectedItems[0].SubItems[2].Text = EditQtyTextBox.Text + "Kg";
                    }
                }


                for (int index = 0; index < waterlist.Count; index++)
                {
                    if (waterlist[index].id == StorageListView.SelectedItems[0].SubItems[0].Text)
                    {
                        waterlist[index].quantity = Convert.ToInt32(EditQtyTextBox.Text);
                        StorageListView.SelectedItems[0].SubItems[2].Text = EditQtyTextBox.Text + "Liter";
                    }
                }
            }
            else if (itemtype == "Medicine")
            {
                int index = 0;
                for (index = 0; index < medicinelist.Count; index++)
                {
                    if (medicinelist[index].id == StorageListView.SelectedItems[0].SubItems[0].Text)
                    {
                        medicinelist[index].quantity = Convert.ToInt32(EditQtyTextBox.Text);
                        StorageListView.SelectedItems[0].SubItems[2].Text = EditQtyTextBox.Text;
                    }
                }
            }
            else
            {
                int index = 0;
                for (index = 0; index < equipmentlist.Count; index++)
                {
                    if (equipmentlist[index].id == StorageListView.SelectedItems[0].SubItems[0].Text)
                    {
                        equipmentlist[index].quantity = Convert.ToInt32(EditQtyTextBox.Text);
                        StorageListView.SelectedItems[0].SubItems[2].Text = EditQtyTextBox.Text;
                    }
                }
            }
            EditGroupbox.Visible = false;
        }
示例#3
0
        private void DeleteLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            NewItem item = new NewItem();

            if (itemtype == "Food&Water")
            {
                for (int index = 0; index < foodlist.Count; index++)
                {
                    if (foodlist[index].id == StorageListView.SelectedItems[0].SubItems[0].Text)
                    {
                        foodlist.RemoveAt(index);
                        StorageListView.SelectedItems[0].Remove();
                    }
                }


                for (int index = 0; index < waterlist.Count; index++)
                {
                    if (waterlist[index].id == StorageListView.SelectedItems[0].SubItems[0].Text)
                    {
                        waterlist.RemoveAt(index);
                        StorageListView.SelectedItems[0].Remove();
                    }
                }
            }
            else if (itemtype == "Medicine")
            {
                int index = 0;
                for (index = 0; index < medicinelist.Count; index++)
                {
                    if (medicinelist[index].id == StorageListView.SelectedItems[0].SubItems[0].Text)
                    {
                        medicinelist.RemoveAt(index);
                        StorageListView.SelectedItems[0].Remove();
                    }
                }
            }
            else
            {
                int index = 0;
                for (index = 0; index < equipmentlist.Count; index++)
                {
                    if (equipmentlist[index].id == StorageListView.SelectedItems[0].SubItems[0].Text)
                    {
                        equipmentlist.RemoveAt(index);
                        StorageListView.SelectedItems[0].Remove();
                    }
                }
            }
        }
示例#4
0
        private void Button2_Click(object sender, EventArgs e)
        {
            NewItem newForm = new NewItem();

            newForm.Show();
        }