Example #1
0
        void ListView1ItemActivate(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection list = this.listView1.SelectedItems;
            ManageItemDialog dlg  = new ManageItemDialog();
            ListViewItem     item = list[0];

            dlg.TypeBox.Text        = item.SubItems[0].Text;
            dlg.TitleBox.Text       = item.SubItems[1].Text;
            dlg.BuyDatePicker.Value = DateTime.Parse(item.SubItems[2].Text);
            dlg.Price.Value         = decimal.Parse(item.SubItems[3].Text);
            dlg.PlaceBox.Text       = item.SubItems[4].Text;
            IEnumerable <Item> result = from Item i in DBConnection.Instance.DB where i.Title.Equals(item.SubItems[1].Text) && i.type.Name.Equals(item.SubItems[0].Text) select i;
            DialogResult       res    = dlg.ShowDialog();

            if (res == DialogResult.OK)
            {
                foreach (Item it in result)
                {
                    it.type    = new ItemType(dlg.TypeBox.Text);
                    it.Title   = dlg.TitleBox.Text;
                    it.BuyDate = dlg.BuyDatePicker.Value;

                    it.Price = (float)dlg.Price.Value;
                    it.Place = dlg.PlaceBox.Text;
                    DBConnection.Instance.DB.Store(it);
                }
                this.refreshItems();
            }
            else if (res == DialogResult.No)
            {
                foreach (Item it in result)
                {
                    DBConnection.Instance.DB.Delete(it);
                    this.refreshItems();
                }
            }
        }
Example #2
0
		void ListView1ItemActivate(object sender, EventArgs e)
		{
			ListView.SelectedListViewItemCollection list = this.listView1.SelectedItems;
			ManageItemDialog dlg = new ManageItemDialog();
			ListViewItem item = list[0];
			dlg.TypeBox.Text = item.SubItems[0].Text;
			dlg.TitleBox.Text = item.SubItems[1].Text;
			dlg.BuyDatePicker.Value = DateTime.Parse(item.SubItems[2].Text);
			dlg.Price.Value = decimal.Parse(item.SubItems[3].Text);
			dlg.PlaceBox.Text = item.SubItems[4].Text;
			IEnumerable<Item> result = from Item i in DBConnection.Instance.DB where i.Title.Equals(item.SubItems[1].Text) && i.type.Name.Equals(item.SubItems[0].Text) select i;
			DialogResult res = dlg.ShowDialog();
			if ( res== DialogResult.OK)
			{
				foreach(Item it in result){
				it.type = new ItemType(dlg.TypeBox.Text);
				it.Title = dlg.TitleBox.Text;
			    it.BuyDate = dlg.BuyDatePicker.Value;
	
			    it.Price = (float)dlg.Price.Value;
				it.Place = dlg.PlaceBox.Text;
				DBConnection.Instance.DB.Store(it);
				}
				this.refreshItems();
			
			}
			else if( res == DialogResult.No){
				foreach(Item it in result){
					DBConnection.Instance.DB.Delete(it);
					this.refreshItems();
				}
				
			}
			
		}
Example #3
0
        void ManageToolStripMenuItem1Click(object sender, EventArgs e)
        {
            ManageItemDialog dlg = new ManageItemDialog();

            dlg.ShowDialog();
        }
Example #4
0
		void ManageToolStripMenuItem1Click(object sender, EventArgs e)
		{
			ManageItemDialog dlg = new ManageItemDialog();
			dlg.ShowDialog();
			
		}