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 = ""; } }
private void FormatStyleForm_Load(object sender, EventArgs e) { Groups = DepositoryReportFormat.InitReportFormats(); //给每一类赋一个示例 Groups[FormatStyle.General].Example = ""; Groups[FormatStyle.Number].Example = "1234.56789"; Groups[FormatStyle.Currency].Example = "1234.56789"; Groups[FormatStyle.Date].Example = DateTime.Now.ToString(); Groups[FormatStyle.Time].Example = DateTime.Now.ToString(); Groups[FormatStyle.Percent].Example = "1234.56789"; Groups[FormatStyle.ScientificCount].Example = "1234.56789"; Groups[FormatStyle.Text].Example = ""; if (_FormatStyle == FormatStyle.General) { rButton_General.Checked = true; } else if (_FormatStyle == FormatStyle.Number) { rButton_Number.Checked = true; } else if (_FormatStyle == FormatStyle.Currency) { rButton_Currency.Checked = true; } else if (_FormatStyle == FormatStyle.Percent) { rButton_Percent.Checked = true; } else if (_FormatStyle == FormatStyle.Date) { rButton_Date.Checked = true; } else if (_FormatStyle == FormatStyle.Time) { rButton_Time.Checked = true; } else if (_FormatStyle == FormatStyle.ScientificCount) { rButton_ScientificCount.Checked = true; } else if (_FormatStyle == FormatStyle.Text) { rButton_Text.Checked = true; } ShowFormatString(_FormatStyle); foreach (FormatInfo String in lBox_FormatString.Items) { if (String.Format.ToLower() == FormatString.ToLower()) { lBox_FormatString.SelectedIndex = lBox_FormatString.Items.IndexOf(String); break; } } }
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 = ""; } } } }