Пример #1
0
 public string GetParentTableName(string aTable)
 {
     return(string.IsNullOrEmpty(mDBName) || string.IsNullOrEmpty(aTable) ? string.Empty : TableM4Tables.GetParentTableName(aTable));
 }
Пример #2
0
 public bool TablesInsert(string aParentTable, string aTable)
 {
     return(string.IsNullOrEmpty(mDBName) || string.IsNullOrEmpty(aParentTable) || string.IsNullOrEmpty(aTable) ? false : TableM4Tables.Insert(aParentTable, aTable) >= 0);
 }
Пример #3
0
        // TABLES

        public bool IsTablesEmpty()
        {
            return(string.IsNullOrEmpty(mDBName) ? true : TableM4Tables.IsEmpty());
        }
Пример #4
0
 public bool TablesDelete()
 {
     return(string.IsNullOrEmpty(mDBName) ? false : TableM4Tables.Delete() >= 0);
 }
Пример #5
0
        public static bool CreateDB(string dbName)
        {
            bool          result = true;
            SqlCommand    myCommand;
            SqlConnection myConn = new SqlConnection(string.Format("Server={0};Integrated security=True;database=master", System.Environment.MachineName));

            if (!ExistDB())
            {
                string str;

                str = string.Format("CREATE DATABASE {0}", dbName);

                myCommand = new SqlCommand(str, myConn);
                try
                {
                    myConn.Open();
                    myCommand.ExecuteNonQuery();
                }
                catch (SqlException ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.Message, "CREATE DATABASE");
                }
                finally
                {
                    if (myConn.State == ConnectionState.Open)
                    {
                        myConn.Close();
                    }
                }
            }
            conn = new SqlConnection(Connection);
            conn.Open();
            if (!ExistDBTable("Fields"))
            {
                if (TableM4Fields.Create())
                {
                    result = false;
                }
            }
            if (!ExistDBTable("Tables"))
            {
                if (TableM4Tables.Create())
                {
                    result = false;
                }
            }
            if (!ExistDBTable("ControlsClasses"))
            {
                if (TableM4ControlsClasses.Create())
                {
                    result = false;
                }
            }
            if (!ExistDBTable("Controls"))
            {
                if (TableM4Controls.Create())
                {
                    result = false;
                }
            }
            if (!ExistDBTable("Label"))
            {
                if (TableM4Label.Create())
                {
                    result = false;
                }
            }
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
            return(result);
        }