Esempio n. 1
0
 private void ReaderDbTables_Load(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(TableName))
     {
         this.tables.AddItem(TableName);
     }
     else
     {
         ConnectionEntity connection = Global.GetProjectConnection();
         //绑定列表
         DbModelData   modelData  = DbModelDataFactory.GetDbModelData(connection.ConnectionType.ToString(), connection.ConnectionString);
         List <string> tableNames = modelData.GetNames(DbListType.UserTable);
         this.tables.DataBind(tableNames, true);
     }
 }
Esempio n. 2
0
        private void btnExportSql_Click(object sender, EventArgs e)
        {
            ConnectionEntity conn   = Global.GetProjectConnection();
            DbModelData      model  = DbModelDataFactory.GetDbModelData(conn.ConnectionType.ToString(), conn.ConnectionString);
            string           script = model.CreateInsertScript(this.filterData1.GetDataSource(), this.filterData1.IsDataKey);

            if (!string.IsNullOrEmpty(script))
            {
                string savePath = Dialog.GetSaveFile("insert-" + TableName + ".sql");
                if (!string.IsNullOrEmpty(savePath))
                {
                    FileHelper.WriteFile(savePath, script);
                    if (MsgBox.Confirm("导出完毕,是否打开文件?"))
                    {
                        FileHelper.OpenFile(savePath);
                    }
                }
            }
        }
Esempio n. 3
0
        //导入数据
        private void btnImport_Click(object sender, EventArgs e)
        {
            DataTable dt = this.gridImport.DataSource as DataTable;

            if (dt != null)
            {
                this.btnImport.Enabled = false;
                try
                {
                    ConnectionEntity conn   = Global.GetProjectConnection();
                    DbModelData      model  = DbModelDataFactory.GetDbModelData(conn.ConnectionType.ToString(), conn.ConnectionString);
                    bool             import = model.ImportData(dt, this.checkIsDataKey.Checked);
                    MsgBox.Alert(string.Format("导入数据成功,共导入{0}条数据", dt.Rows.Count));
                    this.Close();
                }
                catch (Exception ex) {
                    this.btnImport.Enabled = true;
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("导入数据失败,错误信息:");
                    sb.AppendLine(ex.Message);
                    Utils.ShowErrorDialog(sb.ToString() + " ");
                }
            }
        }