/// <summary> /// 添加项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAdd_Click(object sender, EventArgs e) { var ruleName = cbRuleName.Text; if (String.IsNullOrWhiteSpace(ruleName)) { MsgBox.Show("规则名不能为空"); return; } var ruleList = this.bllObj.GetData(); var nowRule = ruleList.FirstOrDefault(tmp => tmp.Name == ruleName); if (nowRule != null) { MsgBox.Show("存在重复的规则名"); return; } var prefixList = ((BindingList <ReplaceItem>) this.gridPrefix.DataSource).ToList(); var stuffixList = ((BindingList <ReplaceItem>) this.gridSuffix.DataSource).ToList(); if (prefixList.Select(tmp => tmp.OriginValue.Trim()).Distinct().Count() != prefixList.Count) { MsgBox.Show("存在重复的前缀参数配置项", "提示"); return; } if (stuffixList.Select(tmp => tmp.OriginValue.Trim()).Distinct().Count() != stuffixList.Count) { MsgBox.Show("存在重复的后缀参数配置项", "提示"); return; } this.nowConfigItem = new NameRuleConfig(); this.nowConfigItem.Id = GetNextId(); this.nowConfigItem.Name = ruleName.Trim(); this.nowConfigItem.Seperator = txtSeperator.Text.Trim(); if (this.rdioFirstLower.Checked) { this.nowConfigItem.FirstCharHandleType = FirstCharHandleType.FirstCharLower; } else { this.nowConfigItem.FirstCharHandleType = FirstCharHandleType.FirstCharUp; } this.nowConfigItem.PrefixList = prefixList; this.nowConfigItem.StuffixList = stuffixList; // 添加项 this.bllObj.Insert(this.nowConfigItem); this.cbRuleName.Items.Add(this.nowConfigItem.Name); this.cbRuleName.SelectedItem = this.nowConfigItem.Name; MsgBox.Show("添加成功"); }
/// <summary> /// 构造函数 /// </summary> /// <param name="database">要使用的数据库</param> /// <param name="tableList">要使用的表列表</param> /// <param name="templateInfoList">要使用的模板列表</param> /// <param name="nameRuleConfig">命名规则</param> /// <param name="paramList">生成的参数信息</param> /// <param name="savePath">保存路径</param> /// <param name="typeMapConfigList">类型映射</param> public GenerateBase(SODatabase database, List <SOTable> tableList, List <TemplateInfo> templateInfoList, List <TypeMapConfig> typeMapConfigList, NameRuleConfig nameRuleConfig, List <ParamItem> paramList, String savePath) { this.TableList = tableList; this.Database = database; this.TemplateInfoList = templateInfoList; this.TypeMapConfigList = typeMapConfigList; this.NameRuleConfig = nameRuleConfig; this.ParamList = paramList; this.SavePath = savePath; }
/// <summary> /// 变更要编辑的项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cbRuleName_SelectedIndexChanged(object sender, EventArgs e) { var ruleName = cbRuleName.Text; if (String.IsNullOrEmpty(ruleName)) { this.nowConfigItem = null; this.Clear(); return; } this.nowConfigItem = this.bllObj.GetItem(ruleName); LoadItem(this.nowConfigItem); }
/// <summary> /// 加载项 /// </summary> private void LoadItem(NameRuleConfig configItem) { this.txtSeperator.Text = configItem.Seperator; if (configItem.FirstCharHandleType == FirstCharHandleType.FirstCharLower) { this.rdioFirstLower.Checked = true; } else { this.rdoFirstUpper.Checked = true; } this.gridPrefix.DataSource = new BindingList <ReplaceItem>(new List <ReplaceItem>(configItem.PrefixList)); this.gridSuffix.DataSource = new BindingList <ReplaceItem>(new List <ReplaceItem>(configItem.StuffixList)); }
/// <summary> /// 删除项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnDelete_Click(object sender, EventArgs e) { var ruleName = cbRuleName.Text.Trim(); if (String.IsNullOrWhiteSpace(ruleName)) { MsgBox.Show("规则名不能为空"); return; } if (this.nowConfigItem == null) { return; } this.bllObj.Delete(this.nowConfigItem.Id); this.nowConfigItem = null; this.Clear(); this.cbRuleName.Items.RemoveAt(this.cbRuleName.SelectedIndex); MsgBox.Show("删除成功"); }
/// <summary> /// 构造函数 /// </summary> /// <param name="nameRuleConfig"></param> /// <param name="typeMapConfigList"></param> /// <param name="tableList"></param> public MultTableHost(NameRuleConfig nameRuleConfig, List <TypeMapConfig> typeMapConfigList, List <SOTable> tableList) { this.nameRuleConfig = nameRuleConfig; this.typeMapConfigList = typeMapConfigList; this.TableList = tableList; }
/// <summary> /// 构造函数 /// </summary> /// <param name="nameRuleConfig"></param> /// <param name="typeMapConfigList"></param> /// <param name="table"></param> public TableHost(NameRuleConfig nameRuleConfig, List <TypeMapConfig> typeMapConfigList, SOTable table) { this.nameRuleConfig = nameRuleConfig; this.typeMapConfigList = typeMapConfigList; this.Table = table; }
/// <summary> /// 构造函数 /// </summary> /// <param name="database">要使用的数据库</param> /// <param name="tableList">要使用的表列表</param> /// <param name="templateInfoList">要使用的模板列表</param> /// <param name="nameRuleConfig">命名规则</param> /// <param name="savePath">保存路径</param> /// <param name="paramList">生成的参数信息</param> /// <param name="typeMapList">类型映射</param> public MultTableGenerate(SODatabase database, List <SOTable> tableList, List <TemplateInfo> templateInfoList, List <TypeMapConfig> typeMapConfigList, NameRuleConfig nameRuleConfig, List <ParamItem> paramList, String savePath) : base(database, tableList, templateInfoList, typeMapConfigList, nameRuleConfig, paramList, savePath) { }
/// <summary> /// 构造函数 /// </summary> /// <param name="database"></param> /// <param name="nameRuleConfig"></param> /// <param name="typeMapConfigList"></param> public DatabaseHost(SODatabase database, NameRuleConfig nameRuleConfig, List <TypeMapConfig> typeMapConfigList) { this.Database = database; this.nameRuleConfig = nameRuleConfig; this.typeMapConfigList = typeMapConfigList; }