Exemple #1
0
        public void DeleteConfigData(ConfigData configdata)
        {
            _configDataList.Remove(configdata);

            if(File.Exists(configdata.FileName))
                File.Delete(configdata.FileName);
        }
Exemple #2
0
        /// <summary>
        /// 创建完整的数据文件路径
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public string CreateConfigDataFileName(ConfigData data)
        {
            if (!Directory.Exists(this.ConfigDataPath + "\\" + data.GetTemplate(this).Name))
                Directory.CreateDirectory(this.ConfigDataPath + "\\" + data.GetTemplate(this).Name);

            return this.ConfigDataPath + "\\" + data.GetTemplate(this).Name + "\\" + data.Name + ".dat";
        }
Exemple #3
0
        private void menuCreateData_Click(object sender, EventArgs e)
        {
            frmCreateData frm = new frmCreateData();
            DialogResult result = frm.ShowDialog();

            if (frm.IsValidate)
            {
                if (CurrentProject.Instance.GetConfigDataByCode(frm.ConfigDataCode) != null)
                {
                    MessageBox.Show("项目中已存在同名数据!");
                    return;
                }

                ConfigData configdata = new ConfigData();
                configdata.Name = frm.ConfigDataName;
                configdata.Code = frm.ConfigDataCode;
                configdata.TemplateCode = _selecedTemplate.Code;
                configdata.ProjectId = CurrentProject.Instance.ID;
                configdata.Order = 1;

                CurrentProject.Instance.AddConfigData(configdata, _selectedGroupName);
                this.FillTreeview(CurrentProject.Instance);
            }
        }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="configdata"></param>
        /// <param name="groupName"></param>
        public void AddConfigData(ConfigData configdata,string groupName)
        {
            var query = from template in this.TemplateList
                        where template.Code == configdata.TemplateCode
                        select template;
            if (query.Count() == 0)
                throw new Exception("在项目中未找到模板!");

            var queryConfigData = from data in this.ConfigDataList
                                  where data.Code == configdata.Code
                                  select data;
            if (queryConfigData.Count() > 0)
                throw new Exception("项目中已存在同名数据!");

            _configDataList.Add(configdata);

            string path = "";
            if (string.IsNullOrEmpty(groupName))
            {
                path=this.ConfigDataPath + "\\" + query.First<Template>().Name;
            }
            else
            {
                path=this.ConfigDataPath + "\\" + query.First<Template>().Name+"\\"+groupName;
            }

            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);

            configdata.Save(path + "\\" + configdata.Name + ".dat");
        }
Exemple #5
0
        private Control LoadFormControl(Item item , ConfigData configData)
        {
            Control control = null;
            Data data = configData.GetData(item.Code);
            switch (item.Type.ToString().ToLower())
            {
                case "list":
                    IList<ConfigData> list = new List<ConfigData>();
                    if (data != null)
                    {
                        foreach (string code in data.ClassValueList)
                        {
                            list.Add(CurrentProject.Instance.GetConfigDataByCode(code));
                        }
                    }
                    control = new ListCtrl(CurrentProject.Instance.GetTemplateByCode(item.ClassName), list);
                    break;
                case "int":
                    control = new NumericUpDown();
                    NumericUpDown numInt = (NumericUpDown)control;
                    numInt.Minimum = -65536;
                    if (data != null)
                    {
                        numInt.Value = int.Parse(data.Value);
                    }
                    break;
                case "decimal":
                    control = new NumericUpDown();
                    NumericUpDown numDecimal = (NumericUpDown)control;
                    numDecimal.DecimalPlaces = 2;
                    numDecimal.Minimum = -65536;
                    if (data != null)
                    {
                        numDecimal.Value = decimal.Parse(data.Value);
                    }
                    break;
                case "class":
                    control = new ComboBox();
                    ComboBox cboObject = (ComboBox)control;
                    cboObject.DisplayMember = "Name";
                    cboObject.ValueMember = "Code";
                    IList<ConfigData> dataList = CurrentProject.Instance.GetDataFromTemplate(CurrentProject.Instance.GetTemplateByCode(item.ClassName));
                    cboObject.DataSource = dataList;
                    cboObject.DropDownStyle = ComboBoxStyle.DropDownList;
                    if (data != null)
                    {
                        cboObject.SelectedValue = data.Value;
                    }
                    break;
                case "enum":
                    control = new ComboBox();
                    ComboBox cboEnum = (ComboBox) control;
                    cboEnum.DisplayMember = "CustomEnumText";
                    cboEnum.ValueMember = "CustomEnumValue";
                    IList<EnumType> enumTypes = item.EnumTypeList;
                    cboEnum.DataSource = enumTypes;
                    cboEnum.DropDownStyle = ComboBoxStyle.DropDownList;
                    if (data != null)
                    {
                        cboEnum.SelectedValue = data.Value;
                    }
                    break;
                case "text":
                    control = new TextBox();
                    if (data != null)
                    {
                        control.Text = data.Value;
                    }
                    break;
                case "date":
                    control = new DateTimePicker();
                    DateTimePicker dtp = (DateTimePicker)control;
                    if (data != null)
                    {
                        dtp.Value = DateTime.Parse(data.Value);
                    }
                    break;
                case "path":
                    control = new TextBox();
                    if (data != null)
                    {
                        control.Text = data.Value;
                    }
                    break;
                default:
                    control = new TextBox();
                    if (data != null)
                    {
                        control.Text = data.Value;
                    }
                    break;

            }

            control.Name = item.Code;
            control.Width = 330;

            return control;
        }