Beispiel #1
0
        private void Btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (GlobalUtil.EngineUnconnectioned(this))
                {
                    return;
                }
                if (curItem == null)
                {
                    SalesPromotion item = new SalesPromotion()
                    {
                    };

                    SetItem(item);
                    if (!Validate(item))
                    {
                        return;
                    }
                    item.CreateTime = DateTime.Now;
                    item.ID         = IDHelper.GetID(OrderPrefix.SalesPromotion, OrderPrefix.ShopCode4Admin);
                    InsertResult result = GlobalCache.ServerProxy.InsertSalesPromotion(item);
                    switch (result)
                    {
                    case InsertResult.Error:
                        GlobalMessageBox.Show("内部错误!");
                        break;

                    default:
                        CommonGlobalCache.InsertSalesPromotion(item);
                        GlobalMessageBox.Show("添加成功!");

                        TabPage_Close(this.CurrentTabPage, this.SourceCtrlType);
                        break;
                    }
                }
                else
                {
                    SetItem(curItem);
                    if (!Validate(curItem))
                    {
                        return;
                    }
                    UpdateResult result = GlobalCache.ServerProxy.UpdateSalesPromotion(curItem);
                    switch (result)
                    {
                    case UpdateResult.Error:
                        GlobalMessageBox.Show("内部错误!");
                        break;

                    default:
                        CommonGlobalCache.UpdateSalesPromotion(curItem);
                        GlobalMessageBox.Show("保存成功!");
                        TabPage_Close(this.CurrentTabPage, this.SourceCtrlType);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalUtil.ShowError(ex);
            }
            finally
            {
                GlobalUtil.UnLockPage(this);
            }
        }