예제 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int     itemNo      = Convert.ToInt32(txtItemNo.Text);
            string  description = txtDescription.Text;
            decimal price       = Convert.ToDecimal(txtPrice.Text);

            if (IsValidData())
            {
                // Add code here that creates a new item
                invItem = new InvItem(itemNo, description, price);
                // and closes the form.
                this.Close();
            }
        }
예제 #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            // Add code here that creates an instance of the New Item form
            // and then gets a new item from that form.
            frmNewItem newItemForm = new frmNewItem();
            InvItem    invItem     = newItemForm.GetNewItem();

            if (invItem != null)
            {
                invItems.Add(invItem);
                InvItemDB.SaveItems(invItems);
                FillItemListBox();
            }
        }
예제 #3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (IsValidData())
     {
         // Add code here that creates a new item
         // and closes the form.
         if (IsValidData())
         {
             invItem = new InvItem(Convert.ToInt32(txtItemNo.Text), txtDescription.Text,
                                   Convert.ToDecimal(txtPrice.Text));
             this.Close();
         }
     }
 }
예제 #4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (IsValidData())
     {
         if (rdoPlant.Checked)
         {
             invItem = new Plant(Convert.ToInt32(txtItemNo.Text), cboSizeOrManufacturer.Text,
                                 txtDescription.Text, Convert.ToDecimal(txtPrice.Text));
         }
         else
         {
             invItem = new Supply(Convert.ToInt32(txtItemNo.Text), cboSizeOrManufacturer.Text,
                                  txtDescription.Text, Convert.ToDecimal(txtPrice.Text));
         }
         this.Close();
     }
 }
예제 #5
0
        private void btnDelete_Click(object sender, System.EventArgs e)
        {
            int i = lstItems.SelectedIndex;

            if (i != -1)
            {
                InvItem invItem = invItems[i];
                string  message = "Are you sure you want to delete "
                                  + invItem.Description + "?";
                DialogResult button =
                    MessageBox.Show(message, "Confirm Delete",
                                    MessageBoxButtons.YesNo);
                if (button == DialogResult.Yes)
                {
                    invItems -= invItem;
                }
            }
        }
예제 #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (IsValidData())
            {
                if (rdoPlant.Checked == true)
                {
                    string size = cboSizeOrManufacturer.SelectedItem.ToString();

                    invItem = new Plant(Convert.ToInt32(txtItemNo.Text),
                                        txtDescription.Text, Convert.ToDecimal(txtPrice.Text), size);
                }
                else if (rdoSupply.Checked == true)
                {
                    invItem = new Supply(Convert.ToInt32(txtItemNo.Text),
                                         txtDescription.Text, Convert.ToDecimal(txtPrice.Text), cboSizeOrManufacturer.SelectedItem.ToString());
                }
                this.Close();
            }
        }
예제 #7
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int i = lstItems.SelectedIndex;

            if (i != -1)
            {
                InvItem invItem = invItems.GetItemByIndex(i);
                string  message = "Are you sure you want to delete "
                                  + invItem.Description + "?";
                DialogResult button =
                    MessageBox.Show(message, "Confirm Delete",
                                    MessageBoxButtons.YesNo);
                if (button == DialogResult.Yes)
                {
                    invItems.Remove(invItem);
                    invItems.Save();
                    FillItemListBox();
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int i = lstItems.SelectedIndex;

            if (i != -1)             // check if an inventory item has been selected
            {
                // Add code here that displays a dialog box to confirm
                // the deletion and then removes the item from the list,
                // saves the list of products, and refreshes the list box
                // if the deletion is confirmed.
                InvItem invItem = invItems[i];                                                               // create & set variable for selected inventory item
                string  message = "Are you sure you want to delete: "
                                  + invItem.ItemNo + " " + invItem.Description + "?";                        // create delete confirmation message
                DialogResult button = MessageBox.Show(message, "Confirm Delete", MessageBoxButtons.YesNo,
                                                      MessageBoxIcon.Stop, MessageBoxDefaultButton.Button2); // display confirmation to delete
                if (button == DialogResult.Yes)                                                              // check if user confirmed deletion
                {
                    invItems.Remove(invItem);                                                                // remove selected item from list
                    InvItemDB.SaveItems(invItems);                                                           // save updated items list
                    FillItemListBox();                                                                       // call method to refresh items list box
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            int i = lstItems.SelectedIndex;

            if (i != -1)
            {
                // Add code here that displays a dialog box to confirm
                // the deletion and then removes the item from the list,
                // saves the list of products, and refreshes the list box
                // if the deletion is confirmed.
                InvItem invItem = invItems[i];
                string  message = "Are you sure you want to delete "
                                  + invItem.Description + "?";
                DialogResult button = MessageBox.Show(message, "Confirm Delete",
                                                      MessageBoxButtons.YesNo);
                if (button == DialogResult.Yes)
                {
                    invItems.Remove(invItem);
                    InvItemDB.SaveItems(invItems);
                    FillItemListBox();
                }
            }
        }
예제 #10
0
 public void Remove(InvItem invItem)
 {
     invItems.Remove(invItem);
     Changed(this);
 }
예제 #11
0
 public void Add(InvItem invItem)
 {
     invItems.Add(invItem);
     Changed(this);
 }
예제 #12
0
 private static void ReadBase(XmlReader xmlIn, InvItem i)
 {
     i.ItemNo      = xmlIn.ReadElementContentAsInt();
     i.Description = xmlIn.ReadElementContentAsString();
     i.Price       = xmlIn.ReadElementContentAsDecimal();
 }
예제 #13
0
 private static void WriteBase(InvItem item, XmlWriter xmlOut)
 {
     xmlOut.WriteElementString("ItemNo", Convert.ToString(item.ItemNo));
     xmlOut.WriteElementString("Description", item.Description);
     xmlOut.WriteElementString("Price", Convert.ToString(item.Price));
 }
예제 #14
0
 public void Add(InvItem invItem)
 {
     invItems.Add(invItem);
 }
예제 #15
0
 public void Add(InvItem invItem) => invItems.Add(invItem);
예제 #16
0
        public void Add(int itemNo, string description, decimal price)
        {
            InvItem i = new InvItem(itemNo, description, price);

            invItems.Add(i);
        }
예제 #17
0
 public void Remove(InvItem invItem)
 {
     invItems.Remove(invItem);
 }