Exemplo n.º 1
0
 public ViewSite(MainWindow parent, MODEL.SiteModel siteModel)
 {
     this.parent            = parent;
     this.viewSiteViewModel = new VIEWMODEL.ViewSiteViewModel(siteModel);
     this.DataContext       = this.viewSiteViewModel;
     InitializeComponent();
 }
        public AddSiteView(SiteMgmtView parent, string action, MODEL.SiteModel siteModel)
        {
            this.parent = parent;

            this.DataContext = new VIEWMODEL.AddSiteViewModel(this, action, siteModel);
            InitializeComponent();

            this.Activate();
        }
        public AddSiteViewModel(AddSiteView parent, string action, MODEL.SiteModel siteModel)
        {
            db          = Database.getInstance();
            this.parent = parent;
            if (siteModel != null)
            {
                this.siteModel = siteModel;
                SiteName       = siteModel.SiteName;
                SiteAddress    = siteModel.SiteAddress;
                SiteHeight     = siteModel.SiteHeight;
                SiteWidth      = siteModel.SiteWidth;
                SiteAmount     = siteModel.SiteAmount;
                SiteImage      = siteModel.SiteImage;
            }
            this.action = action;
            switch (action)
            {
            case "ADD":
            {
                ActionLable  = "Add New Site";
                ActionButton = "Add";
                break;
            }

            case "MDFY":
            {
                ActionLable  = "Modify Site";
                ActionButton = "Modify";
                break;
            }

            case "ACTV":
            {
                var messageBoxResult = CustomMessageBox.Show("Confirmation", "Do you want to Active Site " + siteModel.SiteSeqNum + " ?", MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    string output = db.db_IactvSite(siteModel, "ACTV");
                    if (output.Equals(Status.SUCC))
                    {
                        parent.close();
                    }
                }
                break;
            }

            case "IACT":
            {
                var messageBoxResult = CustomMessageBox.Show("Confirmation", "Do you want to Inactive Site " + siteModel.SiteSeqNum + " ?", MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    string output = db.db_IactvSite(siteModel, "IACT");
                    if (output.Equals(Status.SUCC))
                    {
                        parent.close();
                    }
                }
                break;
            }

            default:
            {
                break;
            }
            }
            StatusString     = "";
            StatusStringFlag = Visibility.Collapsed;
        }