Пример #1
0
 public string getLayoutXmlSessionName(MB.WinBase.IFace.IClientRuleQueryBase baseRule, PivotGridEx xtraGrid)
 {
     if (xtraGrid.ParentForm == null)
     {
         return(null);
     }
     return(baseRule.GetType().FullName + "~" + xtraGrid.ParentForm.GetType().FullName + "~" + xtraGrid.Name);
 }
        void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //保存当前设置值
                List <DynamicColumnInfo> list = new List <DynamicColumnInfo>();
                if (!string.IsNullOrEmpty(this.cmbDynamicTemplate.Text))
                {
                    DataRow[] drs = _DsSource.Tables[0].Select("IsDynamic = true");
                    if (drs.Length == 0)
                    {
                        throw new MB.Util.APPException("请选择动态显示列,动态列数据不能为空!", Util.APPMessageType.DisplayToUser);
                    }


                    foreach (DataRow dr in drs)
                    {
                        DynamicColumnInfo col = new DynamicColumnInfo();
                        col = MB.Util.MyReflection.Instance.FillModelObject <DynamicColumnInfo>(col, dr);

                        list.Add(col);
                    }
                }

                string sectionName = _ClientRuleObject.GetType().FullName + " " + _ClientRuleObject.ClientLayoutAttribute.UIXmlConfigFile;
                List <GridColumnSettingInfo> gridColumnSettings = new MB.Util.Serializer.DataContractFileSerializer <List <GridColumnSettingInfo> >(GRID_COLUMN_SETTING_FULLNAME).Read();
                if (!string.IsNullOrEmpty(this.cmbDynamicTemplate.Text))
                {
                    GridColumnSettingInfo setting = null; GridDynamicColumnSettingInfo dynSetting = null;
                    if (gridColumnSettings == null)
                    {
                        gridColumnSettings = new List <GridColumnSettingInfo>();
                    }
                    else
                    {
                        setting    = gridColumnSettings.Find(o => o.Name.Equals(sectionName));
                        dynSetting = _Settings.Find(o => o.Name.Equals(this.cmbDynamicTemplate.Text.Trim()));
                    }
                    if (dynSetting == null)
                    {
                        dynSetting                = new GridDynamicColumnSettingInfo();
                        dynSetting.Name           = this.cmbDynamicTemplate.Text.Trim();
                        dynSetting.LastModifyDate = DateTime.Now;

                        _Settings.Add(dynSetting);
                    }
                    else
                    {
                        dynSetting.LastModifyDate = DateTime.Now;
                    }
                    if (setting == null)
                    {
                        setting      = new GridColumnSettingInfo();
                        setting.Name = sectionName;

                        gridColumnSettings.Add(setting);
                    }
                    setting.DynamicColumns = _Settings;
                }

                foreach (string name in _DeleteItems)
                {
                    var item = gridColumnSettings.Find(o => o.Name.Equals(sectionName));
                    if (item != null)
                    {
                        var dynamicCol = item.DynamicColumns.Find(o => o.Name.Equals(name));
                        if (dynamicCol != null)
                        {
                            item.DynamicColumns.Remove(dynamicCol);
                        }
                        if (item.DynamicColumns.Count == 0)
                        {
                            gridColumnSettings.Remove(item);
                        }
                    }

                    DynamicColumnSettingHelper.DeleteDynamicColumnSetting(_ClientRuleObject, name);
                }

                DynamicColumnSettingHelper.SaveDynamicColumnSettings(_ClientRuleObject, this.cmbDynamicTemplate.Text, list, gridColumnSettings);

                MB.WinBase.MessageBoxEx.Show("保存成功!");

                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                MB.WinBase.ApplicationExceptionTerminate.DefaultInstance.ExceptionTerminate(ex);
            }
        }