internal static InsertShopResult Shop_OnInsert(Shop shop) { InsertShopResult result = InsertShopResult.GeneralStoreIsExist; //如果标识为总仓,则更新原有的默认仓库 if (shop.IsGeneralStore && GlobalCache.ShopList != null && GlobalCache.ShopList.Count > 0) { // Shop store = GlobalCache.GetShop(GlobalCache.GeneralStoreShopID); if (store != null) { if (GlobalMessageBox.Show("总仓已存在,是否覆盖?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes) { store.IsGeneralStore = false; UpdateShopResult updateShopResult = GlobalCache.ServerProxy.UpdateShop(store); if (updateShopResult != UpdateShopResult.Success) { store.IsGeneralStore = true; return(result); } } else { return(result); } } } InsertShopGetAutoCode insertShopGetAutoCode = GlobalCache.ServerProxy.InsertShop(shop); result = insertShopGetAutoCode.InsertShopResult; switch (result) { case InsertShopResult.Success: shop.AutoCode = insertShopGetAutoCode.AutoCode; //if (GlobalCache.ShopList == null) //{ // GlobalCache.ShopList = new List<Shop>(); //} //ShopList必须是属性,不要改成从字典GET GlobalCache.ShopList.Add(shop); if (shop.IsGeneralStore) { GlobalCache.currentShopID = GlobalCache.generalStoreShopID = shop.ID; } break; case InsertShopResult.GeneralStoreIsExist: break; case InsertShopResult.Error: break; default: break; } return(result); }
private void Btn_Save_Click(object sender, EventArgs e) { try { if (!CheckValidate()) { return; } ; Shop shop = Build(); if (curShop == null) { if (GlobalUtil.EngineUnconnectioned(this)) { return; } InsertShopResult result = GlobalCache.Shop_OnInsert(shop); switch (result) { case InsertShopResult.Error: GlobalMessageBox.Show("内部错误!"); break; case InsertShopResult.GeneralStoreIsExist: GlobalMessageBox.Show("总仓已存在!"); break; case InsertShopResult.IDIsExist: GlobalMessageBox.Show("编号被占用!"); break; case InsertShopResult.MoreThanShopCount: GlobalMessageBox.Show("超过授权店铺数量,如需添加请购买扩店服务。!"); break; default: GlobalMessageBox.Show("添加成功!"); TabPage_Close(this.CurrentTabPage, this.SourceCtrlType); break; } } else { UpdateShopResult result = GlobalCache.Shop_OnUpdate(shop); switch (result) { case UpdateShopResult.Error: GlobalMessageBox.Show("内部错误!"); break; case UpdateShopResult.GeneralStoreIsExist: GlobalMessageBox.Show("总仓已存在!"); break; default: GlobalMessageBox.Show("保存成功!"); curShop = shop; TabPage_Close(this.CurrentTabPage, this.SourceCtrlType); break; } } } catch (Exception ex) { GlobalUtil.ShowError(ex); } finally { GlobalUtil.UnLockPage(this); } }