Beispiel #1
0
        public static PropertiesStore SamplePropertiesStore()
        {
            var store = new PropertiesStore()
            {
                PropertyBags = new List <Properties>()
                {
                    new Properties("GUID1")
                    {
                        Items = new Properties.ItemCollection
                        {
                            { "A-Key1", "A-Value1" },
                            { "A-Key2", "A-Value2" }
                        }
                    },
                    new Properties("GUID2")
                    {
                        Items = new Properties.ItemCollection
                        {
                            { "B-Key1", "B-Value1" },
                            { "B-Key2", "B-Value2" },
                        }
                    }
                }
            };

            return(store);
        }
Beispiel #2
0
        protected void PoPuP(object sender, DirectEventArgs e)
        {
            PropertiesGrid.Disabled = false;
            int    id   = Convert.ToInt32(e.ExtraParams["id"]);
            string type = e.ExtraParams["type"];

            currentCategory.Text = id.ToString();
            PropertiesStore.Reload();
            panelRecordDetails.ActiveIndex = 0;
            switch (type)
            {
            case "imgEdit":
                //Step 1 : get the object from the Web Service
                RecordRequest r = new RecordRequest();
                r.RecordID = id.ToString();
                RecordResponse <AssetManagementCategory> response = _assetManagementService.ChildGetRecord <AssetManagementCategory>(r);
                if (!response.Success)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(response);
                    return;
                }
                //Step 2 : call setvalues with the retrieved object
                FillParent();
                //ApprovalStore.Reload();
                this.BasicInfoTab.SetValues(response.result);

                this.EditRecordWindow.Title = Resources.Common.EditWindowsTitle;
                this.EditRecordWindow.Show();
                break;

            case "imgDelete":
                X.Msg.Confirm(Resources.Common.Confirmation, Resources.Common.DeleteOneRecord, new MessageBoxButtonsConfig
                {
                    Yes = new MessageBoxButtonConfig
                    {
                        //We are call a direct request metho for deleting a record
                        Handler = String.Format("App.direct.DeleteRecord({0})", id),
                        Text    = Resources.Common.Yes
                    },
                    No = new MessageBoxButtonConfig
                    {
                        Text = Resources.Common.No
                    }
                }).Show();
                break;

            case "imgAttach":

                //Here will show up a winow relatice to attachement depending on the case we are working on
                break;

            default:
                break;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Adding new record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        ///
        protected void ADDNewRecord(object sender, DirectEventArgs e)
        {
            //Reset all values of the relative object
            //   ApprovalStore.Reload();
            currentCategory.Text = "";
            BasicInfoTab.Reset();
            FillParent();
            panelRecordDetails.ActiveIndex = 0;
            PropertiesGrid.Disabled        = true;
            PropertiesStore.Reload();
            this.EditRecordWindow.Title = Resources.Common.AddNewRecord;


            this.EditRecordWindow.Show();
        }
Beispiel #4
0
        public void DeletePropertyRecord(string propertyId)
        {
            try
            {
                //Step 1 Code to delete the object from the database
                AssetManagementCategoryProperty n = new AssetManagementCategoryProperty();
                n.categoryId = currentCategory.Text;
                n.propertyId = propertyId;



                PostRequest <AssetManagementCategoryProperty> req = new PostRequest <AssetManagementCategoryProperty>();
                req.entity = n;
                PostResponse <AssetManagementCategoryProperty> res = _assetManagementService.ChildDelete <AssetManagementCategoryProperty>(req);
                if (!res.Success)
                {
                    //Show an error saving...
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    Common.errorMessage(res);
                    return;
                }
                else
                {
                    //Step 2 :  remove the object from the store
                    PropertiesStore.Reload();

                    //Step 3 : Showing a notification for the user
                    Notification.Show(new NotificationConfig
                    {
                        Title = Resources.Common.Notification,
                        Icon  = Icon.Information,
                        Html  = Resources.Common.RecordDeletedSucc
                    });
                }
            }
            catch (Exception ex)
            {
                //In case of error, showing a message box to the user
                X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorDeletingRecord).Show();
            }
        }
        public void CreateSingleBagStoreTest()
        {
            var store = new PropertiesStore();

            var guid = System.Guid.NewGuid().ToString();

            store.Add(new Properties(guid)
            {
                Items = new Properties.ItemCollection
                {
                    { "key1", "value1" },
                    { "key2", "value2" }
                }
            });

            var bag = store.Find(guid);

            Assert.IsTrue(bag.Items.ContainsKey("key1"));
            Assert.IsTrue(bag.Items.ContainsKey("key2"));

            Assert.AreEqual(bag.Items["key1"], "value1");
            Assert.AreNotEqual(bag.Items["key2"], "value1");
        }
Beispiel #6
0
        protected void SaveNewPropertyRecord(object sender, DirectEventArgs e)
        {
            //Getting the id to check if it is an Add or an edit as they are managed within the same form.

            string propertyId = e.ExtraParams["categoryId"];

            string obj = e.ExtraParams["values"];
            AssetManagementCategoryProperty b = JsonConvert.DeserializeObject <AssetManagementCategoryProperty>(obj);

            b.categoryId = currentCategory.Text;
            b.propertyId = propertyId;

            // Define the object to add or edit as null

            if (string.IsNullOrEmpty(propertyId))
            {
                try
                {
                    //New Mode
                    //Step 1 : Fill The object and insert in the store
                    PostRequest <AssetManagementCategoryProperty> request = new PostRequest <AssetManagementCategoryProperty>();
                    request.entity = b;
                    PostResponse <AssetManagementCategoryProperty> r = _assetManagementService.ChildAddOrUpdate <AssetManagementCategoryProperty>(request);


                    //check if the insert failed
                    if (!r.Success)//it maybe be another condition
                    {
                        //Show an error saving...

                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        //Add this record to the store
                        this.PropertiesStore.Reload();

                        //Display successful notification
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordSavingSucc
                        });

                        this.EditPropertyWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    //Error exception displaying a messsage box
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorSavingRecord).Show();
                }
            }
            else
            {
                //Update Mode

                try
                {
                    PostRequest <AssetManagementCategoryProperty> request = new PostRequest <AssetManagementCategoryProperty>();
                    request.entity = b;
                    PostResponse <AssetManagementCategoryProperty> r = _assetManagementService.ChildAddOrUpdate <AssetManagementCategoryProperty>(request);                      //Step 1 Selecting the object or building up the object for update purpose

                    //Step 2 : saving to store

                    //Step 3 :  Check if request fails
                    if (!r.Success)//it maybe another check
                    {
                        X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                        Common.errorMessage(r);
                        return;
                    }
                    else
                    {
                        PropertiesStore.Reload();
                        Notification.Show(new NotificationConfig
                        {
                            Title = Resources.Common.Notification,
                            Icon  = Icon.Information,
                            Html  = Resources.Common.RecordUpdatedSucc
                        });
                        this.EditPropertyWindow.Close();
                    }
                }
                catch (Exception ex)
                {
                    X.MessageBox.ButtonText.Ok = Resources.Common.Ok;
                    X.Msg.Alert(Resources.Common.Error, Resources.Common.ErrorUpdatingRecord).Show();
                }
            }
        }