public void Save()
        {
            var duties = (this.listBoxDuty.ItemsSource as List <PP_Duty>).GetCheckedKeys();

            if (duties == null || duties.Length == 0)
            {
                throw new Exception("工作组职责不能为空!");
            }
            OrganizationTemplate orgTemplate = new OrganizationTemplate();

            orgTemplate.Guid         = this.editOrganization.Guid;
            orgTemplate.ParentGuid   = this.editOrganization.ParentGuid;
            orgTemplate.Name         = this.textBoxName.Text;
            orgTemplate.TemplateGuid = this.editOrganization.TemplateGuid;
            orgTemplate.Vehicle      = this.gridVehicle.DataContext as VehicleInfo;
            orgTemplate.DutyList     = new List <string>((this.listBoxDuty.ItemsSource as List <PP_Duty>).GetCheckedKeys());
            PT_BS_Service.Client.Framework.BeOperationInvoker.Invoke <I_CO_IA.PlanDatabase.I_CO_IA_Template>(channel =>
            {
                channel.SaveOrganizationTempate(orgTemplate);
            });
            this.editOrganization.IsNew    = false;
            this.editOrganization.Name     = orgTemplate.Name;
            this.editOrganization.Vehicle  = orgTemplate.Vehicle;
            this.editOrganization.DutyList = orgTemplate.DutyList;
        }
 private void OrganizationEditControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != null && e.NewValue is OrganizationTemplate)
     {
         editOrganization      = e.NewValue as OrganizationTemplate;
         this.textBoxName.Text = editOrganization.Name;
         (this.listBoxDuty.ItemsSource as IList <PP_Duty>).CheckItems(editOrganization.DutyList);
         this.gridVehicle.DataContext = editOrganization.Vehicle;
     }
 }
Esempio n. 3
0
        //private void listBoxDuty_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        //{
        //    if (e.NewValue is OrganizationTemplate)
        //    {
        //        (this.listBoxDuty.ItemsSource as IList<PP_Duty>).CheckItems((e.NewValue as OrganizationTemplate).DutyList);
        //    }
        //    //CheckableData<string>.CheckItems(this.listBoxDuty.ItemsSource as IList<PP_Duty>, (e.NewValue as OrganizationTemplate).DutyList);
        //}

        private void MenuItemCreateSubOrg_Click(object sender, RoutedEventArgs e)
        {
            var templateNode = (sender as MenuItem).DataContext as TreeNode <OrganizationTemplate>;

            if (templateNode != null)
            {
                var parentTemplate = templateNode.Value;
                OrganizationTemplate newTemplate = new OrganizationTemplate {
                    IsNew = true, ParentGuid = parentTemplate.Guid, Name = "新建小组"
                };
                newTemplate.TemplateGuid = parentTemplate.TemplateGuid;
                newTemplate.Guid         = CO_IA.Client.Utility.NewGuid();
                newTemplate.DutyList     = new List <string>();
                templateNode.SubTreeNodes.Add(new TreeNode <OrganizationTemplate> {
                    Value = newTemplate
                });
            }
        }