Beispiel #1
0
        public static void AddSupplier(Control ctrl, SkinComboBox skinComboBox)
        {
            List <Supplier>         list    = (List <Supplier>)skinComboBox.DataSource;
            NewSupplierComboBoxForm addForm = new NewSupplierComboBoxForm(list);

            if (addForm.ShowDialog(ctrl) == DialogResult.OK)
            {
                if (list == null)
                {
                    list = new List <Supplier>();
                }
                Supplier item     = addForm.Result;
                Supplier listItem = list.Find(t => t.Name == item.Name || t.ID == item.ID);
                if (listItem == null)
                {
                    item.Enabled    = true;
                    item.CreateTime = DateTime.Now;
                    InteractResult result = GlobalCache.SupplierList_OnChange(item);
                    switch (result.ExeResult)
                    {
                    case ExeResult.Success:
                        skinComboBox.DataSource = null;
                        list.Add(item);
                        skinComboBox.DisplayMember = "Name";
                        skinComboBox.ValueMember   = "ID";
                        skinComboBox.DataSource    = list;
                        skinComboBox.SelectedIndex = list.IndexOf(item);
                        break;

                    case ExeResult.Error:
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    // this.skinComboBox_SupplierID.SelectedItem = listItem;
                }
            }
        }