private int PrimaryID()
        {
            DBInterface.CommandText = "SELECT MAX(" + idName + ") FROM " + tableName;
            DataTable tab = DBInterface.ExecuteSelection();

            if (tab.Rows.Count == 0)
            {
                return(0);
            }
            return(Convert.ToInt32(tab.Rows[0][0]) + 1);
        }
Esempio n. 2
0
        public void Execute()
        {
            string com   = "INSERT INTO " + tableName + " (";
            bool   first = true;

            foreach (var item in parameterValue.Keys)
            {
                if (!first)
                {
                    com += ", ";
                }
                com  += item;
                first = false;
            }
            com += ") VALUES (@";

            first = true;
            foreach (var item in parameterValue.Keys)
            {
                if (!first)
                {
                    com += ", @";
                }
                com  += item;
                first = false;
            }
            com += ");";

            DBInterface.CommandText = com;

            DBInterface.AddParameter("@tab", MySqlDbType.String, tableName);

            foreach (var item in parameterValue)
            {
                MySqlDbType DBType = MySqlDbType.String;
                if (parameterType.TryGetValue(item.Key, out DBType))
                {
                    DBInterface.AddParameter("@" + item.Key, DBType, item.Value);
                }
            }

            DBInterface.ExecuteTransaction();
        }