Exemplo n.º 1
0
 // Set Data
 public void ClickEditName()
 {
     this.EditName.Click();
     editNameForm = new EditNameForm(manager);
 }
Exemplo n.º 2
0
        private void TableManagerForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (dataGridView1.Columns.Count == 0)
            {
                this.DialogResult = DialogResult.Cancel;
                return;
            }
            if (Operation == OperationType.Create)
            {
                if (MessageBox.Show("是否保存?", "保存", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (helper.ExistTable(TableName))
                    {
                        helper.DeleteTable(TableName);
                    }
                    helper.CreateTable(TableMode, TableName, "", GetTableFields(), false);
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                }
                return;
            }

            EditNameForm tnf = new EditNameForm(TableName)
            {
                LabelTableName = "报表名称", TemplateName = TemplateName
            };

            while (true)
            {
                if (tnf.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    if (tnf.TableName.Trim() == "")
                    {
                        MessageBox.Show("请输入表名");
                        continue;
                    }
                    if (tnf.TableName[0] <= 64)
                    {
                        MessageBox.Show("不能字母或汉字以外的字符做为表名开头!");
                        continue;
                    }

                    if (helper.ExistTable(tnf.TableName))
                    {
                        if (Operation == OperationType.Copy)
                        {
                            MessageBox.Show("复制的新表不能与原表重名,请重新命名");
                            continue;
                        }
                        else
                        {
                            helper.DeleteTable(tnf.TableName);
                        }
                        //helper.DelColumns(tnf.TextBoxValue, DelCol.ToArray());
                        //helper.AddColumns(tnf.TextBoxValue, AddCol.ToArray());
                    }
                    if (Directory.Exists(Application.StartupPath + "\\RDLC"))
                    {
                        if (Directory.GetFiles(Application.StartupPath + "\\RDLC").Select(f => Path.GetFileNameWithoutExtension(f)).Contains(tnf.TemplateName))
                        {
                            helper.CreateTable(TableMode, tnf.TableName, tnf.TemplateName, GetTableFields());
                            this.DialogResult = DialogResult.OK;
                            return;
                        }
                        else
                        if (MessageBox.Show("没有找到此报表的模板,将无法使用报表导出功能,请确认!", "确认", MessageBoxButtons.YesNo) == DialogResult.No)
                        {
                            continue;
                        }
                    }
                    helper.CreateTable(TableMode, tnf.TableName, GetTableFields());
                    this.DialogResult = DialogResult.OK;
                    return;
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                    return;
                }
            }
        }