Ejemplo n.º 1
0
        private void skinLabelAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (GlobalUtil.EngineUnconnectioned(this))
                {
                    return;
                }
                CostumeAddBrandForm addForm = new CostumeAddBrandForm();
                if (addForm.ShowDialog(this) == DialogResult.OK)
                {
                    List <Brand> list = (List <Brand>) this.skinComboBox.DataSource;
                    if (list == null)
                    {
                        list = new List <Brand>();
                    }
                    Brand value = addForm.Result;
                    //从所有品牌中查找
                    Brand listItem = CommonGlobalCache.BrandList.Find(t => t.Name == value.Name);
                    if (listItem == null)
                    {
                        //   Brand item = new Brand() { Name = value, FirstCharSpell = DisplayUtil.GetPYString(value) };
                        InsertResult result = GlobalCache.BrandList_OnInsert(value);
                        switch (result)
                        {
                        case InsertResult.Success:
                            this.skinComboBox.DataSource = null;
                            list.Add(value);
                            this.skinComboBox.DisplayMember = "Name";
                            this.skinComboBox.ValueMember   = "AutoID";
                            this.skinComboBox.DataSource    = list;
                            this.skinComboBox.SelectedIndex = list.IndexOf(value);
                            break;

                        case InsertResult.Error:
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        GlobalMessageBox.Show("品牌已存在");
                        //this.skinComboBox.SelectedItem = listItem;
                    }
                }
            }
            catch (Exception ex)
            {
                // GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }
        private void Edit(Brand item)
        {
            CostumeAddBrandForm AddBrand = new CostumeAddBrandForm(item, OperationEnum.Edit);

            try
            {
                if (AddBrand.ShowDialog(this) == DialogResult.OK)
                {
                    if (GlobalUtil.EngineUnconnectioned(this))
                    {
                        return;
                    }
                    InteractResult result = GlobalCache.ServerProxy.UpdateBrand(item);
                    switch (result.ExeResult)
                    {
                    case ExeResult.Success:
                        GlobalCache.UpdateBrand(item);
                        baseButton1_Click(null, null);
                        break;

                    case ExeResult.Error:
                        GlobalMessageBox.Show(result.Msg);
                        break;

                    default:
                        break;
                    }
                    //UpdateResult result = GlobalCache.ServerProxy.UpdateBrand(item);
                    //switch (result)
                    //{
                    //    case UpdateResult.Success:
                    //        GlobalCache.UpdateBrand(item);
                    //        baseButton1_Click(null, null);
                    //        break;
                    //    case UpdateResult.Error:
                    //        GlobalMessageBox.Show("内部错误!");
                    //        break;
                    //    default:
                    //        break;
                    //}
                }
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }
Ejemplo n.º 3
0
        private void baseButton2_Click(object sender, EventArgs e)
        {
            List <Brand> list = null;

            if (dataGridView1.DataSource != null)
            {
                list = DataGridViewUtil.BindingListToList <Brand>(dataGridView1.DataSource);
            }
            //List<Brand> list = DataGridViewUtil.BindingListToList<Brand>(dataGridView1.DataSource);
            CostumeAddBrandForm AddBrand = new CostumeAddBrandForm();

            try
            {
                if (AddBrand.ShowDialog(this) == DialogResult.OK)
                {
                    if (list == null)
                    {
                        list = new List <Brand>();
                    }
                    Brand item = AddBrand.Result;
                    list.Add(item);
                    InsertResult result = GlobalCache.BrandList_OnInsert(item);
                    if (GlobalUtil.EngineUnconnectioned(this))
                    {
                        return;
                    }
                    switch (result)
                    {
                    case InsertResult.Success:
                        baseButton1_Click(sender, e);
                        break;

                    case InsertResult.Error:
                        break;

                    default:
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }