Пример #1
0
        protected void Store1_RefreshData(object sender, StoreReadDataEventArgs e)
        {
            //GEtting the filter from the page
            //string filter = string.Empty;
            //int totalCount = 1;



            ////Fetching the corresponding list

            ////in this test will take a list of News
            RuleTriggerListRequset Listreq = new RuleTriggerListRequset();

            Listreq.ruleId     = "0";
            Listreq.accessType = "0";
            Listreq.classId    = "0";
            ListResponse <RuleTrigger> resp = _companyStructureService.ChildGetAll <RuleTrigger>(Listreq);

            if (!resp.Success)
            {
                Common.errorMessage(resp);
                return;
            }

            this.Store1.DataSource = resp.Items;
            e.Total = resp.Items.Count;;

            this.Store1.DataBind();
        }
Пример #2
0
        protected void ruleSelectorStore_ReadData(object sender, StoreReadDataEventArgs e)
        {
            if (string.IsNullOrEmpty(accessType.SelectedItem.Value))
            {
                return;
            }


            ListRequest Listreq = new ListRequest();

            Listreq.Filter = "";
            ListResponse <Model.Company.Structure.Rule> allRulesTrigger = _companyStructureService.ChildGetAll <Model.Company.Structure.Rule>(Listreq);



            if (!allRulesTrigger.Success)
            {
                Common.errorMessage(allRulesTrigger);
                return;
            }

            RuleTriggerListRequset selectedRequest = new RuleTriggerListRequset();

            selectedRequest.ruleId     = string.IsNullOrEmpty(CurrentRuleId.Text) ? "0" : CurrentRuleId.Text;
            selectedRequest.accessType = accessType.SelectedItem.Value;
            selectedRequest.classId    = classSelectedId.Text;


            ListResponse <RuleTrigger> selectedRuleTrigger = _companyStructureService.ChildGetAll <RuleTrigger>(selectedRequest);

            if (!selectedRuleTrigger.Success)
            {
                Common.errorMessage(selectedRuleTrigger);
                return;
            }

            //selectedRuleTrigger.Items.ForEach(x =>
            //{
            //    allRulesTrigger.Items.Remove(x);

            //});

            ruleSelectorStore.DataSource = allRulesTrigger.Items;
            ruleSelectorStore.DataBind();

            this.ruleSelector.SelectedItems.Clear();
            selectedRuleTrigger.Items.ForEach(x =>
            {
                this.ruleSelector.SelectedItems.Add(new Ext.Net.ListItem()
                {
                    Value = x.ruleId
                });
            });

            this.ruleSelector.UpdateSelectedItems();
            this.ruleSelector.Update();
        }
Пример #3
0
        protected void saveNewTrigger(object sender, DirectEventArgs e)
        {
            try
            {
                //Getting the id to check if it is an Add or an edit as they are managed within the same form.
                string classIdParameter    = e.ExtraParams["classId"];
                string accessTypeParameter = e.ExtraParams["accessType"];


                List <Model.Company.Structure.RuleTrigger> selectedRules = new List <Model.Company.Structure.RuleTrigger>();
                int count = 1;
                foreach (var item in ruleSelector.SelectedItems)
                {
                    selectedRules.Add(new Model.Company.Structure.RuleTrigger()
                    {
                        ruleId = item.Value, classId = classIdParameter, accessType = accessTypeParameter, seqNo = count.ToString()
                    });
                    count++;
                }

                RuleTriggerListRequset Listreq = new RuleTriggerListRequset();
                Listreq.ruleId     = "0";
                Listreq.accessType = accessTypeParameter;
                Listreq.classId    = classIdParameter;
                ListResponse <RuleTrigger> Listresp = _companyStructureService.ChildGetAll <RuleTrigger>(Listreq);
                if (!Listresp.Success)
                {
                    Common.errorMessage(Listresp);
                    return;
                }

                PostRequest <RuleTrigger> req = new PostRequest <RuleTrigger>();
                Listresp.Items.ForEach(x =>
                {
                    req.entity = x;
                    PostResponse <RuleTrigger> delresp = _companyStructureService.ChildDelete <RuleTrigger>(req);
                    if (!delresp.Success)
                    {
                        Common.errorMessage(delresp);
                        throw new Exception();
                    }
                });

                selectedRules.ForEach(x =>
                {
                    req.entity = x;
                    PostResponse <RuleTrigger> resp = _companyStructureService.ChildAddOrUpdate <RuleTrigger>(req);
                    if (!resp.Success)
                    {
                        Common.errorMessage(resp);
                        throw new Exception();
                    }
                });



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


                Store1.Reload();
            }
            catch (Exception exp)
            {
                X.MessageBox.Alert(Resources.Common.Error, exp.Message).Show();
            }
        }