Inheritance: ViewModelBase, ISupportModifiableView, IDisposable
Example #1
0
 private void MillPipeNewEditXtraForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     commandManager.Dispose();
     if (viewModel != null)
     {
         viewModel.Dispose();
         viewModel = null;
     }
 }
Example #2
0
 public NewSavePipeCommand(
     MillPipeNewEditViewModel viewModel,
     IMillRepository repo,
     IUserNotify notify,
     ISecurityContext ctx)
 {
     this.viewModel = viewModel;
     this.repo      = repo;
     this.notify    = notify;
     this.ctx       = ctx;
 }
 public NewSavePipeCommand(
     MillPipeNewEditViewModel viewModel,
     IMillRepository repo,
     IUserNotify notify,
     ISecurityContext ctx)
 {
     this.viewModel = viewModel;
     this.repo = repo;
     this.notify = notify;
     this.ctx = ctx;
 }
 public ExtractHeatsCommand(MillPipeNewEditViewModel viewModel, IHeatRepository repo, IUserNotify notify)
 {
     this.viewModel = viewModel;
     this.repo      = repo;
     this.notify    = notify;
 }
Example #5
0
 public GetPipeCommand(MillPipeNewEditViewModel viewModel, IMillRepository repo)
 {
     this.viewModel = viewModel;
     this.repo      = repo;
 }
 public ExtractPipeTypeCommand(MillPipeNewEditViewModel viewModel, IMillPipeSizeTypeRepository repo)
 {
     this.viewModel = viewModel;
     this.repo = repo;
 }
Example #7
0
 public GetProjectCommand(MillPipeNewEditViewModel viewModel, IProjectRepository repo)
 {
     this.viewModel = viewModel;
     this.repo = repo;
 }
Example #8
0
 public ExtractPipeTypeCommand(MillPipeNewEditViewModel viewModel, IMillPipeSizeTypeRepository repo)
 {
     this.viewModel = viewModel;
     this.repo      = repo;
 }
        public void TestMillPipeNewEdit()
        {
            var modifiableView = new Mock<IModifiable>();

            var repoPipe = new Mock<IPipeRepository>();
            var notify = new Mock<IUserNotify>();
            var repoPlate = new Mock<IPlateRepository>();
            var repoHeat = new Mock<IHeatRepository>();
            var repoWeld = new Mock<IWeldRepository>();
            var repoPipeType = new Mock<IMillPipeSizeTypeRepository>();
            var repoPurchaseOrder = new Mock<IPurchaseOrderRepository>();
            var repoWelder = new Mock<IWelderRepository>();
            var repoPipeTestResult = new Mock<IPipeTestResultRepository>();
            var repoPipeTest = new Mock<IPipeTestRepository>();
            var repoInspector = new Mock<IInspectorRepository>();
            var repoProject = new Mock<IProjectRepository>();
            var ctx = new Mock<ISecurityContext>();
            var pipe = new Pipe();

            repoPipe.Setup(x => x.GetActiveByNumber(pipe)).Returns(new List<Pipe>());
            repoProject.Setup(x => x.GetSingle()).Returns(new Project() { IsNative = true});
            repoPipeTest.Setup(x => x.GetByCriteria(It.IsAny<NHibernate.Criterion.DetachedCriteria>())).Returns(new List<PipeTest>());

            Mock<IMillRepository> millRepos = new Mock<IMillRepository>();
            millRepos.SetupGet(_ => _.RepoPipe).Returns(repoPipe.Object);
            millRepos.SetupGet(_ => _.RepoPlate).Returns(repoPlate.Object);
            millRepos.SetupGet(_ => _.RepoHeat).Returns(repoHeat.Object);
            millRepos.SetupGet(_ => _.RepoWeld).Returns(repoWeld.Object);
            millRepos.SetupGet(_ => _.RepoPipeType).Returns(repoPipeType.Object);
            millRepos.SetupGet(_ => _.RepoPurchaseOrder).Returns(repoPurchaseOrder.Object);
            millRepos.SetupGet(_ => _.WelderRepo).Returns(repoWelder.Object);
            millRepos.SetupGet(_ => _.RepoPipeTestResult).Returns(repoPipeTestResult.Object);
            millRepos.SetupGet(_ => _.RepoPipeTest).Returns(repoPipeTest.Object);
            millRepos.SetupGet(_ => _.RepoInspector).Returns(repoInspector.Object);
            millRepos.SetupGet(_ => _.RepoProject).Returns(repoProject.Object);

            modifiableView.SetupGet(x => x.IsModified).Returns(false);



            var viewModel = new MillPipeNewEditViewModel(
                millRepos.Object,
                Guid.Empty, 
                notify.Object,
                ctx.Object);
            var validatable = new Mock<IValidatable>();
            validatable.Setup(x => x.Validate()).Returns(true);
            viewModel.ValidatableView = validatable.Object;
            viewModel.Pipe = pipe;
            viewModel.ModifiableView = modifiableView.Object;

            var command = new NewSavePipeCommand(
                viewModel, 
                millRepos.Object, 
                notify.Object,
                ctx.Object);

            command.Execute();

            millRepos.Verify(_ => _.BeginTransaction(), Times.Once());
            repoPipe.Verify(_ => _.SaveOrUpdate(It.IsAny<Pipe>()), Times.Once());
            millRepos.Verify(_ => _.Commit(), Times.Once());
            repoPipe.Verify(_ => _.Evict(It.IsAny<Pipe>()), Times.Once());
        }
 private void MillPipeNewEditXtraForm_FormClosed(object sender, FormClosedEventArgs e)
 {
     commandManager.Dispose();
     if(viewModel != null)
     {
         viewModel.Dispose();
         viewModel = null;
     }
 }
        public MillPipeNewEditXtraForm(Guid id)
        {
            this.Id = id;

            InitializeComponent();
            SetControlsTextLength();
            viewModel = (MillPipeNewEditViewModel)Program
                .Kernel
                .Get<MillPipeNewEditViewModel>(
                new ConstructorArgument("id", id));
            viewModel.ModifiableView = this;
            viewModel.ValidatableView = this;


            pipeCreationDate.Properties.NullDate = DateTime.MinValue;
            pipeCreationDate.Properties.NullText = string.Empty;

            #region --- Colouring of required controls ---
            pipeNumber.SetRequiredText();
            pipeSize.SetRequiredCombo();
            pipeCreationDate.SetRequiredText();
            heatsLookUp.SetRequiredGridLookUp();
            ordersLookUp.SetRequiredText();
            plateNumber.SetRequiredText();
            #endregion //--- Colouring of required controls ---

            #region --- Read-only controls and edit mode ---
            SetAlwaysReadOnly(plateManufacturer);
            SetAlwaysReadOnly(purchaseOrderDate);
            SetAlwaysReadOnly(railcarNumber);
            SetAlwaysReadOnly(releaseNoteNumber);
            SetAlwaysReadOnly(releaseNoteDate);
            SetAlwaysReadOnly(certificateNumber);
            SetAlwaysReadOnly(destination);
            SetAlwaysReadOnly(steelGrade);
            SetAlwaysReadOnly(weight);
            SetAlwaysReadOnly(length);
            SetAlwaysReadOnly(pipeLength);
            SetAlwaysReadOnly(diameter);
            SetAlwaysReadOnly(thickness);
            SetAlwaysReadOnly(millStatus);
            attachmentsButton.Enabled = true;

            SetConditional(pipeNumber, delegate(bool editMode)
                    {
                        return (viewModel.PipeIsActive);
                    });

            SetConditional(pipeSize, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            SetConditional(heatsLookUp, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            SetConditional(heatsLookUp, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            SetConditional(ordersLookUp, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            SetConditional(pipeCreationDate, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            SetConditional(plateNumber, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            SetConditional(coatingHistory, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            SetConditional(weldingHistory, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            SetConditional(inspections, delegate(bool editMode)
            {
                return (viewModel.PipeIsActive);
            });

            #endregion //--- Read-only controls ---

            #region --- Set Properties.CharacterCasing to Upper ---
            pipeNumber.SetAsIdentifier();
            plateNumber.SetAsIdentifier();
            certificateNumber.SetAsIdentifier();
            #endregion //--- Set Properties.CharacterCasing to Upper ---

            plateThickness.SetFloatMask(Constants.DigitsBeforeDecimalPoint);
            heatsLookUp.ButtonSetup();
            ordersLookUp.ButtonSetup();

            // Allow change focus or close while heatsLookUp or ordersLookUp validation error
            AutoValidate = AutoValidate.EnableAllowFocusChange;

            // Select tab depending on is new pipe or existed
            tabbedControlGroup.SelectedTabPage = (id == Guid.Empty) ?
                pipeTabLayoutControlGroup : inspectionsTabLayoutControlGroup;
        }
Example #12
0
 public ExtractHeatsCommand(MillPipeNewEditViewModel viewModel, IHeatRepository repo)
 {
     this.viewModel = viewModel;
     this.repo      = repo;
 }
 public ExtractHeatsCommand(MillPipeNewEditViewModel viewModel, IHeatRepository repo, IUserNotify notify)
 {
     this.viewModel = viewModel;
     this.repo = repo;
     this.notify = notify;
 }
Example #14
0
 public ExtractPurchaseOrderCommand(MillPipeNewEditViewModel viewModel, IPurchaseOrderRepository repo)
 {
     this.viewModel = viewModel;
     this.repo      = repo;
 }
Example #15
0
        public MillPipeNewEditXtraForm(Guid id)
        {
            this.id = id;

            InitializeComponent();
            SetControlsTextLength();
            viewModel = (MillPipeNewEditViewModel)Program
                        .Kernel
                        .Get <MillPipeNewEditViewModel>(
                new ConstructorArgument("id", id));
            viewModel.ModifiableView  = this;
            viewModel.ValidatableView = this;


            pipeCreationDate.Properties.NullDate = DateTime.MinValue;
            pipeCreationDate.Properties.NullText = string.Empty;

            #region --- Colouring of required controls ---
            pipeNumber.SetRequiredText();
            pipeSize.SetRequiredCombo();
            pipeCreationDate.SetRequiredText();
            heatsLookUp.SetRequiredGridLookUp();
            ordersLookUp.SetRequiredText();
            plateNumber.SetRequiredText();
            #endregion //--- Colouring of required controls ---

            #region --- Read-only controls and edit mode ---
            SetAlwaysReadOnly(plateManufacturer);
            SetAlwaysReadOnly(purchaseOrderDate);
            SetAlwaysReadOnly(railcarNumber);
            SetAlwaysReadOnly(releaseNoteNumber);
            SetAlwaysReadOnly(releaseNoteDate);
            SetAlwaysReadOnly(certificateNumber);
            SetAlwaysReadOnly(destination);
            SetAlwaysReadOnly(steelGrade);
            SetAlwaysReadOnly(weight);
            SetAlwaysReadOnly(length);
            SetAlwaysReadOnly(pipeLength);
            SetAlwaysReadOnly(diameter);
            SetAlwaysReadOnly(thickness);
            SetAlwaysReadOnly(millStatus);
            IsEditMode = ctx.HasAccess(global::Domain.Entity.Security.Privileges.EditPipe);
            attachmentsButton.Enabled = true;
            #endregion //--- Read-only controls ---

            #region --- Set Properties.CharacterCasing to Upper ---
            pipeNumber.SetAsIdentifier();
            plateNumber.SetAsIdentifier();
            heatsLookUp.SetAsIdentifier();
            ordersLookUp.SetAsIdentifier();
            certificateNumber.SetAsIdentifier();
            #endregion //--- Set Properties.CharacterCasing to Upper ---

            heatsLookUp.ButtonSetup();
            ordersLookUp.ButtonSetup();

            // Allow change focus or close while heatsLookUp or ordersLookUp validation error
            AutoValidate = AutoValidate.EnableAllowFocusChange;

            IsEditMode = true;

            // Select tab depending on is new pipe or existed
            tabbedControlGroup.SelectedTabPage = (id == Guid.Empty) ?
                                                 pipeTabLayoutControlGroup : inspectionsTabLayoutControlGroup;

            CannotOpenForViewing = id == Guid.Empty;
        }