예제 #1
0
        //remove customer
        private void btnRemoveCustomerData_Click(object sender, EventArgs e)
        {
            if (lvCustomerData.SelectedItems.Count > 0)
            {
                ListViewItem item = lvCustomerData.SelectedItems[0];
                int          id;
                bool         evalTest = int.TryParse(item.SubItems[0].Text, out id);
                if (evalTest)
                {
                    Tuple <int, string, string> ret = customerUtility.RemoveCustomer(id);
                    switch (ret.Item1)
                    {
                    case 1:
                        lvCustomerData.SelectedItems[0].Remove();
                        txtCustomerDataFirstName.Text = ""; txtCustomerDataLastName.Text = "";
                        MessageBox.Show(ret.Item2, ret.Item3, MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
                        break;

                    case 2:
                    case 3:
                        MessageBox.Show(ret.Item2, ret.Item3, MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Bank id not converted properly!", "Conversion Error", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
            }
            else
            {
                MessageBox.Show("No customer was selected!", "No Customer selected", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
            }
        }