Esempio n. 1
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            //提示确定要保存吗?如果是执行下面操作
            if (MessageService.AskQuestion(StringParser.Parse("${res:FanHai.Hemera.Addins.Msg.SaveRemind}"), StringParser.Parse("${res:Global.SystemInfo}")))
            {
                DataSet dsReturn = new DataSet();
                try
                {
                    //check--if ok 输入信息判定
                    if (CheckSaveInfo())
                    {
                        //set data to entity
                        MapDataToEntity();
                        //判定状态如果为新增执行下面的操作
                        if (State == ControlState.New)
                        {
                            //call method of saveData of entity
                            dsReturn = _locationEntity.SaveNewLocation();
                        }
                        //判定状态为修改Edit时执行下面修改操作
                        else if (State == ControlState.Edit)
                        {
                            //call method of saveData of entity 调用保存修改方法
                            dsReturn = _locationEntity.SaveUpdateLocation();
                        }
                        //check result
                        if (_locationEntity.ErrorMsg != "")
                        {
                            //ClearEntityValue();
                            if (State == ControlState.New)
                            {
                                ClearEntityValue();
                            }
                            MessageBox.Show(StringParser.Parse(_locationEntity.ErrorMsg));
                        }
                        else
                        {
                            //set title
                            if (WorkbenchSingleton.Workbench.ActiveViewContent.TitleName == StringParser.Parse("${res:FanHai.Hemera.Addins.EMS.LocationCtrl.ViewContentPartTile}"))
                            {
                                State = ControlState.Edit;
                                //set title
                                WorkbenchSingleton.Workbench.ActiveViewContent.TitleName = StringParser.Parse("${res:FanHai.Hemera.Addins.EMS.LocationCtrl.ViewContentPartTile}") + "_" + _locationEntity.LocationName;
                            }
                            //bind data again
                            int parentLevel = 5;
                            Int32.TryParse(_locationEntity.ParentLocationLevel, out parentLevel);

                            BindDataToLookUpEditContol(parentLevel);
                            //提示“数据保存成功”
                            MessageBox.Show(StringParser.Parse("${res:FanHai.Hemera.Addins.EMS.LocationCtrl.MsgDataSaveSuccessfully}"));
                            tsbSearch_Click(sender, e);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }