コード例 #1
0
        private void SaveContractMasterAndContinue()
        {
            SmpUcContractMasterEdit.CommitContext();
            if (!(SmpUcContractMasterEdit.DataContext is ContractMaster newItem))
            {
                return;
            }
            var contractFields = newItem.MainGroup.CurrentContractFields.ToList();

            contractFields.ForEach(gft => newItem.ContractDetails.Add(new ContractDetail {
                ContractField = gft
            }));
            Context.ContractMasters.Add(newItem);
            Context.SaveChanges();
            SmpUcFormState.CurrentState            = FormCurrentState.AddDetails;
            DataGridEmployeeContracts.SelectedItem = newItem;
            SmpUcContractDetailsEdit.Refresh();
            SmpUcContractDetailsEdit.Select();
        }
コード例 #2
0
        private void Save_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            switch (SmpUcFormState.CurrentState)
            {
            case FormCurrentState.AddMaster:
                SaveContractMasterAndContinue();
                SmpUcFormState.CurrentState = FormCurrentState.Edit;
                break;

            case FormCurrentState.Edit:
                SmpUcContractDetailsEdit.CommitContext();
                SmpUcContractMasterEdit.CommitContext();
                SmpUcContractDetailsEdit.Refresh();
                SmpUcContractDetailsEdit.GetBindingExpression(DataContextProperty)?.UpdateSource();
                SmpUcFormState.CurrentState = FormCurrentState.Select;
                break;
            }

            Context.SaveChanges();
        }