Esempio n. 1
0
 private void btnAddEdit_Click(object sender, EventArgs e)
 {
     try
     {
         int index = 0;
         foreach (string item in Properties.Settings.Default.Items)
         {
             if (txtID.Text == item.Split('⎖')[0])
             {
                 ItemManagementSystem.EditItem(txtID.Text, txtName.Text, txtLocation.Text, txtDescription.Text, index);
                 listPopulate();
                 operationCompleted();
                 return;
             }
             index++;
         }
         ItemManagementSystem.CreateItem(txtID.Text, txtName.Text, txtLocation.Text, txtDescription.Text);
         listPopulate();
         operationCompleted();
         return;
     }
     catch (Exception ex)
     {
         operationFailed();
     }
 }
Esempio n. 2
0
        private void btnDown_Click(object sender, EventArgs e)
        {
            if (lbItems.SelectedIndex == -1)
            {
                operationFailed(); return;
            }
            int index = 0;

            foreach (string item in Properties.Settings.Default.Items)
            {
                if (lbItems.SelectedItem.ToString() == item.Split('⎖')[1])
                {
                    if (index == (lbItems.Items.Count - 1))
                    {
                        operationFailed(); return;
                    }
                    string[] parts       = item.Split('⎖');
                    string   id          = parts[0];
                    string   name        = parts[1];
                    string   location    = parts[2];
                    string   description = parts[3];
                    ItemManagementSystem.EditItem(id, name, location, description, index + 1);
                    listPopulate();
                    operationCompleted();
                    lbItems.SelectedItem = name;
                    return;
                }
                index++;
            }
            operationFailed();
        }