private void Button_Append_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(textBox1.Text)) { return; } Boolean Found = false; FormatStringGroup NowformatStringGroup = Groups[rButton_Style]; for (int i = 0; i < NowformatStringGroup.FormatInfos.Count; i++) { if (NowformatStringGroup.FormatInfos[i].ToString() == textBox1.Text) { Found = true; break; } } if (!Found) { FormatInfo fs = new FormatInfo(); fs.Format = textBox1.Text; fs.Style = rButton_Style; DepositoryReportFormat.UpdateReportFormats(fs); NowformatStringGroup.FormatInfos.Add(fs); lBox_FormatString.Items.Add(fs); tBox_FormatString.Text = lBox_FormatString.Items[0].ToString(); textBox1.Text = ""; } }
public FormatStringGroup InitReportFormats(FormatStyle FormatStyle) { String formatStyle = FormatStyle.ToString(); FormatStringGroup fsg = new FormatStringGroup(); StringBuilder Sql_Select = new StringBuilder(); //增加查询条件 Scdel=0 判断数据是否已删除 2013-10-17 Sql_Select.Append("Select ID,FormatStyle,FormatString From sys_biz_ReportFormatStrings Where Scdel=0 and FormatStyle='"); Sql_Select.Append(formatStyle.ToString()); Sql_Select.Append("'"); Sql_Select.Append(" ORDER BY FormatString ASC "); DataTable Data = GetDataTable(Sql_Select.ToString()); if (Data != null && Data.Rows.Count > 0) { for (int i = 0; i < Data.Rows.Count; i++) { FormatInfo fs = new FormatInfo(); DataRow Row = Data.Rows[i]; fs.Index = Row["ID"].ToString(); String FormatS = Row["FormatStyle"].ToString(); fs.Style = (FormatStyle)Enum.Parse(typeof(FormatStyle), FormatS); fs.Format = Row["FormatString"].ToString(); fsg.FormatInfos.Add(fs); } } return(fsg); }
private void ShowFormatString(FormatStyle formatStyle) { rButton_Style = formatStyle; #region 字典的实现 lBox_FormatString.Items.Clear(); tBox_FormatString.Text = ""; label_Example.Text = ""; FormatStringGroup NowformatStringGroup = Groups[formatStyle]; if (NowformatStringGroup != null) { for (int i = 0; i < NowformatStringGroup.FormatInfos.Count; i++) { lBox_FormatString.Items.Add(NowformatStringGroup.FormatInfos[i]); } if (lBox_FormatString.Items.Count > 0) { lBox_FormatString.SelectedIndex = 0; } } #endregion }
public static Dictionary <FormatStyle, FormatStringGroup> InitReportFormats() { Dictionary <FormatStyle, FormatStringGroup> Groups = new Dictionary <FormatStyle, FormatStringGroup>(); foreach (FormatStyle Format in Enum.GetValues(typeof(FormatStyle))) { FormatStringGroup group = InitReportFormats(Format); Groups.Add(Format, group); } return(Groups); }
private void Button_Delete_Click(object sender, EventArgs e) { FormatInfo fs = (FormatInfo)lBox_FormatString.SelectedItem; FormatStringGroup Fsg = Groups[rButton_Style]; if (fs != null) { if (DialogResult.Yes == MessageBox.Show("确定删除格式串 ‘" + fs.Format + "’ 吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { DepositoryReportFormat.DeleteReportFormats(fs); lBox_FormatString.Items.Remove(lBox_FormatString.SelectedItem); Fsg.FormatInfos.Remove(fs); if (lBox_FormatString.Items.Count > 0) { lBox_FormatString.SelectedIndex = 0; } else { tBox_FormatString.Text = ""; } } } }