Esempio n. 1
0
        public void SaveChanges()
        {
            var asset = (Asset)newAssetBindingSource.DataSource;

            asset.Status = (int)AssetStatuses.Active;
            if (!ValidateForm())
            {
                return;
            }
            try
            {
                _context.Assets.AddObject(asset);
                _context.SaveChanges();
                if (!_saveAndNew)
                {
                    Close();
                    var asdForm = new AssetDetail();
                    asdForm.MdiParent = MainParent;
                    asdForm.ShowObject(asset.AssetId);
                    asdForm.Show();
                }
                else
                {
                    ShowObject(null);
                }
            }
            catch (Exception ex)
            {
                ViewHelper.ShowErrorMessage("Error occured while saving the current asset.", ex);
            }
        }
Esempio n. 2
0
        public void OpenSelectedItem()
        {
            var selected = (Asset)GetSelectedItem();

            if (selected != null)
            {
                var assetDetail = new AssetDetail();
                assetDetail.ShowObject(selected.AssetId);
                assetDetail.MdiParent = this.MdiParent;
                assetDetail.Text      = assetDetail.Text + " " + selected.AssetNumber;
                assetDetail.Show();
                return;
            }
        }